diff --git a/src/sinol_make/commands/run/__init__.py b/src/sinol_make/commands/run/__init__.py index 79612732..c7c6190e 100644 --- a/src/sinol_make/commands/run/__init__.py +++ b/src/sinol_make/commands/run/__init__.py @@ -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): @@ -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): """ diff --git a/tests/commands/run/test_integration.py b/tests/commands/run/test_integration.py index da17eb97..6d47dab4 100644 --- a/tests/commands/run/test_integration.py +++ b/tests/commands/run/test_integration.py @@ -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)