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

Add flag for ignoring expected scores #232

Merged
merged 2 commits into from
Apr 5, 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
8 changes: 8 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,9 @@ 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('--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.')
add_compilation_arguments(parser)
return parser

Expand Down Expand Up @@ -1238,6 +1241,11 @@ def run(self, args):

results, all_results = self.compile_and_run(solutions)
self.check_errors(all_results)
if self.args.ignore_expected:
print(util.warning("Ignoring expected scores."))
self.exit()
return

try:
validation_results = self.validate_expected_scores(results)
except Exception:
Expand Down
4 changes: 4 additions & 0 deletions src/sinol_make/commands/verify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def configure_subparser(self, subparser):
help=f'number of cpus that sinol-make will use '
f'(default: {util.default_cpu_count()})',
default=util.default_cpu_count())
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. '
'This flag will be passed to the run command.')
parsers.add_compilation_arguments(parser)

def remove_cache(self):
Expand Down
27 changes: 27 additions & 0 deletions tests/commands/run/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,3 +785,30 @@ def test_ghost_checker(create_package):
with pytest.raises(SystemExit) as e:
command.run(args)
assert e.value.code == 1


@pytest.mark.parametrize("create_package", [get_simple_package_path()], indirect=True)
def test_ignore_expected_flag(create_package, capsys):
"""
Test flag --ignore-expected.
"""
config = package_util.get_config()
del config["sinol_expected_scores"]
util.save_config(config)

package_path = create_package
create_ins_outs(package_path)
parser = configure_parsers()
args = parser.parse_args(["run"])
command = Command()

with pytest.raises(SystemExit):
command.run(args)
out = capsys.readouterr().out
assert "Use flag --apply-suggestions to apply suggestions." in out

args = parser.parse_args(["run", "--ignore-expected"])
command = Command()
command.run(args)
out = capsys.readouterr().out
assert "Ignoring expected scores." in out
Loading