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

Modify missing outputs #234

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
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
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
Loading