Skip to content

Commit

Permalink
Pass circular_symlink unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
hwikle-lanl committed Sep 26, 2024
1 parent 45f2288 commit 461cceb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
9 changes: 7 additions & 2 deletions lib/pavilion/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,17 @@ def _create_build_hash(self) -> str:

if src_path is not None:
if src_path.is_file():
self.status.set(STATES.INFO, f"Hashing file {src_path}.")
hash_obj.update(self._hash_file(src_path))
elif src_path.is_dir():
self.status.set(STATES.INFO, f"Hashing directory {src_path}.")
hash_obj.update(self._hash_dir(src_path, exclude=CONFIG_FNAMES))
else:
raise TestBuilderError(
"Invalid src location {}."
.format(src_path))
else:
self.status.set(STATES.INFO, "No files to hash.")

# Hash all the given template files.
for tmpl_src in sorted(self._templates.keys()):
Expand Down Expand Up @@ -1015,6 +1019,7 @@ def _hash_dir(cls, path: Path, exclude: List[str] = None) -> str:
# Order is indeterminate, so sort the files
files = sorted(path.rglob('*'))
except OSError:
# This will typically be caught earlier by _date_dir
raise TestBuilderError(f"Unable to hash directory: {path}. Possible circular symlink.")

files = filter(lambda x: x.name not in exclude, files)
Expand Down Expand Up @@ -1054,8 +1059,8 @@ def _date_dir(base_path):
dir_stat = path.stat()
except OSError as err:
raise TestBuilderError(
"Could not stat file in test source dir '{}'"
.format(base_path), err)
(f"Could not stat file in test source dir '{base_path}'. "
"Possible circular symlink."), err)
if dir_stat.st_mtime > latest:
latest = dir_stat.st_mtime

Expand Down
11 changes: 8 additions & 3 deletions test/tests/builder_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,12 @@ def test_hash_circular_symlinks(self):
'circular_symlinks'
])

build_cmd = commands.get_command(args.command_name)
run_cmd = commands.get_command(args.command_name)

with self.assertRaises(TestBuilderError):
build_cmd.run(self.pav_cfg, args)
run_cmd.run(self.pav_cfg, args)

last_series = run_cmd.last_series

last_series.wait()

self.assertEqual(last_series.status.current().state, "ERROR")
2 changes: 1 addition & 1 deletion test/tests/suites_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def setUp(self):
plugins.initialize_plugins(self.pav_cfg)
run_cmd = commands.get_command('run')
build_cmd = commands.get_command('build')
# run_cmd.silence()
run_cmd.silence()

def test_suite_run_from_suite_directory(self):
"""Test that Pavilion can find and run a test from
Expand Down

0 comments on commit 461cceb

Please sign in to comment.