Skip to content

Commit

Permalink
Fix disable cache (Bug: #260) (#261).
Browse files Browse the repository at this point in the history
Fixes a bug introduced with --pex-root that raised an exception on when --disable-cache was used.
  • Loading branch information
digwanderlust authored and kwlzn committed May 23, 2016
1 parent 31f4814 commit ec63631
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pex/bin/pex.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def increment_verbosity(option, opt_str, _, parser):


def process_disable_cache(option, option_str, option_value, parser):
setattr(parser.values, option.dest, [])
setattr(parser.values, option.dest, None)


def process_pypi_option(option, option_str, option_value, parser, builder):
Expand Down Expand Up @@ -530,7 +530,9 @@ def main(args=None):
else:
options.pex_root = ENV.PEX_ROOT # If option not specified fallback to env variable.

options.cache_dir = make_relative_to_root(options.cache_dir)
# Don't alter cache if it is disabled.
if options.cache_dir:
options.cache_dir = make_relative_to_root(options.cache_dir)
options.interpreter_cache_dir = make_relative_to_root(options.interpreter_cache_dir)

with ENV.patch(PEX_VERBOSE=str(options.verbosity)):
Expand Down
22 changes: 22 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ def test_pex_root():
assert 'build' in os.listdir(td), 'Expected build directory in tmp pex root.'


def test_cache_disable():
with temporary_dir() as tmp_home:
with environment_as(HOME=tmp_home):
with temporary_dir() as td:
with temporary_dir() as output_dir:
env = os.environ.copy()
env['PEX_INTERPRETER'] = '1'

output_path = os.path.join(output_dir, 'pex.pex')
args = [
'pex',
'-o', output_path,
'--not-zip-safe',
'--disable-cache',
'--pex-root={0}'.format(td),
]
results = run_pex_command(args=args, env=env)
results.assert_success()
assert ['pex.pex'] == os.listdir(output_dir), 'Expected built pex file.'
assert [] == os.listdir(tmp_home), 'Expected empty temp home dir.'


def test_pex_interpreter():
with named_temporary_file() as fp:
fp.write(b"print('Hello world')")
Expand Down

0 comments on commit ec63631

Please sign in to comment.