Skip to content

Commit

Permalink
Modify missing outputs (#234)
Browse files Browse the repository at this point in the history
Stricter no outs verification
Fix script crashing on lack of any outputs
  • Loading branch information
adespawn authored Apr 10, 2024
1 parent 4543c1b commit 7a0a94d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/sinol_make/commands/run/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ def configure_subparser(self, subparser):
help='path to oiejq executable (default: `~/.local/bin/oiejq`)')
parser.add_argument('-a', '--apply-suggestions', dest='apply_suggestions', action='store_true',
help='apply suggestions from expected scores report')
parser.add_argument('--no-outputs', dest='allow_no_outputs', action='store_true',
help='allow running the script without full outputs')
add_compilation_arguments(parser)

def parse_time(self, time_str):
Expand Down Expand Up @@ -1121,9 +1123,14 @@ def validate_existence_of_outputs(self):

print(util.warning('Missing output files for tests: ' + ', '.join(
[self.extract_file_name(test) for test in missing_tests])))
if self.args.allow_no_outputs != True:
util.exit_with_error('There are tests without outputs. \n'
'Run outgen to fix this issue or add the --no-outputs flag to ignore the issue.')
print(util.warning('Running only on tests with output files.'))
self.tests = valid_input_files
self.groups = self.get_groups(self.tests)
if len(self.groups) < 1:
util.exit_with_error('No tests with valid outputs.')

def check_are_any_tests_to_run(self):
"""
Expand Down
29 changes: 29 additions & 0 deletions tests/commands/run/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,35 @@ def test_missing_output_files(capsys, create_package):

out = capsys.readouterr().out
assert f'Missing output files for tests: {out1}, {out2}' in out
assert 'There are tests without outputs.' in out
assert 'Run outgen to fix this issue or add the --no-outputs flag to ignore the issue.' in out
assert 'An error occurred while running the command.' not in out


@pytest.mark.parametrize("create_package", [get_simple_package_path(), get_verify_status_package_path()], indirect=True)
def test_missing_output_files_allow_missing(capsys, create_package):
"""
Test with missing output files.
"""
package_path = create_package
command = get_command()
create_ins_outs(package_path)

outs = glob.glob(os.path.join(package_path, "out", "*.out"))
for i in outs:
os.unlink(i)

parser = configure_parsers()
args = parser.parse_args(["run", "--time-tool", "time", "--no-outputs"])
command = Command()
with pytest.raises(SystemExit):
command.run(args)

out = capsys.readouterr().out
assert 'No tests with valid outputs.' in out
assert 'An error occurred while running the command.' not in out
assert 'There are tests without outputs.' not in out
assert 'Run outgen to fix this issue or add the --no-outputs flag to ignore the issue.' not in out


@pytest.mark.parametrize("create_package", [get_limits_package_path()], indirect=True)
Expand Down

0 comments on commit 7a0a94d

Please sign in to comment.