Skip to content

Commit

Permalink
Merge branch 'main' into verify-command
Browse files Browse the repository at this point in the history
  • Loading branch information
MasloMaslane authored Apr 15, 2024
2 parents d4c5231 + 7a0a94d commit f1ec107
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 @@ -304,6 +304,8 @@ def configure_subparser(self, subparser):
parser.add_argument('--ignore-expected', dest='ignore_expected', action='store_true',
help='ignore expected scores from config.yml. When this flag is set, '
'the expected scores are not compared with the actual scores.')
parser.add_argument('--no-outputs', dest='allow_no_outputs', action='store_true',
help='allow running the script without full outputs')
parsers.add_compilation_arguments(parser)
return parser

Expand Down Expand Up @@ -1126,9 +1128,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 f1ec107

Please sign in to comment.