Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: make test run suite_scripts also when no test_data, so can test … #133

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions tests/test_SuiteScripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,6 @@ def can_tests_run(self):
import psana # noqa: F401
except ImportError:
return False

# check for submodule
data_path = self.git_repo_root + "/tests/test_data"
if not os.path.exists(data_path):
return False
# check for some expected folder to be sure submodule initalized
if not os.path.exists(data_path + "/test_roi"):
return False
return True

def run_command(self, command):
Expand All @@ -173,10 +165,19 @@ def test_command(self, command, output_location):
if result.returncode != 0:
assert False, f"Script failed with error: {result.stderr}"

# let's not diff output files if user doesn't have download the /tests/test_data submodule,
# since the exact output of scripts can often change a small amount so diffing the output files
# is mainly useful when refactoring or when sure output data won't change.
# testing without diffing output will still test if scripts can run to completion without error!
data_path = self.git_repo_root + "/tests/test_data"
if not os.path.exists(data_path) or not os.path.exists(data_path + "/test_roi"):
print("/tests/test_data submodule not setup, not diffing output against expected output files")
return

real_output_location = self.git_repo_root + "/suite_scripts/" + output_location
expected_output_location = self.git_repo_root + "/tests/test_data/" + output_location

# Compare files in directories
# diff real output vs expected output files
for root, dirs, files in os.walk(real_output_location):
for file in files:
real_file_path = real_output_location + "/" + file
Expand Down