Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
* remove `test_peru_file_and_sync_dir_must_be_set_together` since that rule is removed

* fix the behavior and formatting of `--cache-dir` and `--state-dir` params
  • Loading branch information
Araxeus committed Feb 23, 2023
1 parent 50d5540 commit 7e27bd3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
14 changes: 10 additions & 4 deletions peru/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,17 @@ def _set_paths(self, args, env):
self.peru_file = find_project_file(os.getcwd(), basename)
self.sync_dir = os.path.dirname(self.peru_file)

self.state_dir = os.path.abspath(
args['--state-dir']) if args['--state-dir'] else os.path.join(self.sync_dir, '.peru')
if args['--state-dir']:
self.state_dir = os.path.abspath(args['--state-dir'])
else:
self.state_dir = os.path.join(self.sync_dir, '.peru')

self.cache_dir = os.path.abspath(
args['--cache-dir']) if args['--cache-dir'] else os.path.join(self.state_dir, 'cache')
if args['--cache-dir']:
self.cache_dir = os.path.abspath(args['--cache-dir'])
elif env.get('PERU_CACHE_DIR'):
self.cache_dir = env.get('PERU_CACHE_DIR')
else:
self.cache_dir = os.path.join(self.state_dir, 'cache')

def tmp_dir(self):
dir = tempfile.TemporaryDirectory(dir=self._tmp_root)
Expand Down
5 changes: 0 additions & 5 deletions tests/test_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ def test_unmodified_sync(self):
shared.run_peru_command(['sync'], self.cwd)
self.assert_success(self.project_dir, self.state_dir, self.cache_dir)

def test_peru_file_and_sync_dir_must_be_set_together(self):
for command in [['--sync-dir=junk', 'sync'], ['--file=junk', 'sync']]:
with self.assertRaises(CommandLineError):
shared.run_peru_command(command, cwd=self.cwd)

def test_file_and_file_basename_incompatible(self):
with self.assertRaises(CommandLineError):
shared.run_peru_command([
Expand Down

0 comments on commit 7e27bd3

Please sign in to comment.