Skip to content

Commit

Permalink
Remove printing of expected scores
Browse files Browse the repository at this point in the history
  • Loading branch information
MasloMaslane committed Sep 24, 2023
1 parent b87fbc3 commit 3ae39f1
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 108 deletions.
17 changes: 1 addition & 16 deletions src/sinol_make/commands/run/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,6 @@ def configure_subparser(self, subparser):
help=f'tool to measure time and memory usage (default: {default_timetool})')
parser.add_argument('--oiejq-path', dest='oiejq_path', type=str,
help='path to oiejq executable (default: `~/.local/bin/oiejq`)')
parser.add_argument('-p', '--print-expected-scores', dest='print_expected_scores', action='store_true',
help='print whole expected scores report')
parser.add_argument('-a', '--apply-suggestions', dest='apply_suggestions', action='store_true',
help='apply suggestions from expected scores report')
add_compilation_arguments(parser)
Expand Down Expand Up @@ -731,10 +729,6 @@ def _convert(obj):
return obj
return _convert(dictionary)

def print_expected_scores(self, expected_scores):
yaml_dict = { "sinol_expected_scores": self.convert_status_to_string(expected_scores) }
print(yaml.dump(yaml_dict, default_flow_style=None))

def get_whole_groups(self):
"""
Returns a list of groups for which all tests were run.
Expand Down Expand Up @@ -833,14 +827,6 @@ def validate_expected_scores(self, results):
if len(expected_scores[solution]["expected"]) == 0:
del expected_scores[solution]

if self.args.print_expected_scores:
if self.args.tests is not None:
print("Showing expected scores only for groups with all tests run.")
print(util.bold("Expected scores from config:"))
self.print_expected_scores(expected_scores)
print(util.bold("\nExpected scores based on results:"))
self.print_expected_scores(new_expected_scores)

expected_scores_diff = dictdiffer.diff(expected_scores, new_expected_scores)
added_solutions = set()
removed_solutions = set()
Expand Down Expand Up @@ -976,8 +962,7 @@ def set_group_result(solution, group, result):
util.save_config(self.config)
print(util.info("Saved suggested expected scores description."))
else:
util.exit_with_error("To see expected scores from config and results, run sinol-make with flag --print-expected-scores.\n"
"Use flag --apply-suggestions to apply suggestions.")
util.exit_with_error("Use flag --apply-suggestions to apply suggestions.")


def set_constants(self):
Expand Down
64 changes: 0 additions & 64 deletions tests/commands/run/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,70 +151,6 @@ def test_flag_tests(create_package, time_tool):
assert command.tests == [test]


@pytest.mark.parametrize("create_package", [get_checker_package_path()], indirect=True)
def test_groups_in_flag_test(capsys, create_package, time_tool):
"""
Test flag --tests with whole and partial groups.
"""
package_path = create_package
create_ins_outs(package_path)

parser = configure_parsers()

# Test with only one test from group 1.
args = parser.parse_args(["run", "--tests", "in/chk1a.in", "--print-expected-scores", "--time-tool", time_tool])
command = Command()
command.run(args)
out = capsys.readouterr().out
assert "Showing expected scores only for groups with all tests run." in out
assert "sinol_expected_scores: {}" in out
assert "Expected scores are correct!" in out

# Test with all tests from group 1.
args = parser.parse_args(["run", "--tests", "in/chk1a.in", "in/chk1b.in", "in/chk1c.in", "--print-expected-scores",
"--time-tool", time_tool])
command = Command()
command.run(args)
out = capsys.readouterr().out
assert 'sinol_expected_scores:\n' \
' chk.cpp:\n' \
' expected:\n' \
' 1: {points: 50, status: OK}\n' \
' points: 50\n' \
' chk1.cpp:\n' \
' expected:\n' \
' 1: {points: 0, status: WA}\n' \
' points: 0\n' \
' chk2.cpp:\n' \
' expected:\n' \
' 1: {points: 25, status: OK}\n' \
' points: 25\n' \
' chk3.cpp:\n' \
' expected:\n' \
' 1: {points: 50, status: OK}\n' \
' points: 50' in out

# Test with incorrect expected scores for first group.
with open(os.path.join(package_path, "config.yml"), "r") as config_file:
correct_config = yaml.load(config_file, Loader=yaml.SafeLoader)
config = copy.deepcopy(correct_config)
config["sinol_expected_scores"]["chk.cpp"]["expected"][1] = {"status": "WA", "points": 0}
config["sinol_expected_scores"]["chk.cpp"]["points"] = 50
with open(os.path.join(package_path, "config.yml"), "w") as config_file:
config_file.write(yaml.dump(config))

args = parser.parse_args(["run", "--tests", "in/chk1a.in", "in/chk1b.in", "in/chk1c.in", "--time-tool", time_tool,
"--apply-suggestions"])
command = Command()
command.run(args)
out = capsys.readouterr().out
sys.stdout.write(out)
assert "Solution chk.cpp passed group 1 with status OK while it should pass with status WA." in out
with open(os.path.join(package_path, "config.yml"), "r") as config_file:
config = yaml.load(config_file, Loader=yaml.SafeLoader)
assert config == correct_config


@pytest.mark.parametrize("create_package", [get_simple_package_path(), get_verify_status_package_path(),
get_checker_package_path(), get_icpc_package_path()], indirect=True)
def test_flag_solutions(capsys, create_package, time_tool):
Expand Down
28 changes: 0 additions & 28 deletions tests/commands/run/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,34 +89,6 @@ def flatten_results(results):
}


def test_print_expected_scores(capsys):
os.chdir(get_simple_package_path())
command = get_command()
expected_scores = """sinol_expected_scores:
abc.cpp:
expected: {1: "OK", 2: "OK", 3: "OK", 4: "OK"}
points: 100
abc1.cpp:
expected: {1: "OK", 2: "OK", 3: "OK", 4: "WA"}
points: 75
abc2.cpp:
expected: {1: "OK", 2: "WA", 3: "WA", 4: "TL"}
points: 25
abc3.cpp:
expected: {1: "OK", 2: "WA", 3: "WA", 4: "ML"}
points: 25
abc4.cpp:
expected: {1: "OK", 2: "OK", 3: "WA", 4: "RE"}
points: 50
"""

expected_scores_dict = yaml.load(expected_scores, Loader=yaml.FullLoader)
command.print_expected_scores(expected_scores_dict["sinol_expected_scores"])
out = capsys.readouterr().out
assert expected_scores.replace('"', '') in out


def test_validate_expected_scores_success():
os.chdir(get_simple_package_path())
command = get_command()
Expand Down

0 comments on commit 3ae39f1

Please sign in to comment.