Skip to content

Commit f6d64ea

Browse files
committed
Fix parallel tests
1 parent a9e3df3 commit f6d64ea

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

tested/manual.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from tested.main import run
1414
from tested.testsuite import SupportedLanguage
1515

16-
exercise_dir = "/IdeaProjects/universal-judge/tests/exercises/echo"
16+
exercise_dir = "/IdeaProjects/universal-judge/tests/exercises/isbn"
1717

1818

1919
def read_config() -> DodonaConfig:
@@ -24,10 +24,10 @@ def read_config() -> DodonaConfig:
2424
programming_language=SupportedLanguage("cpp"),
2525
natural_language="nl",
2626
resources=Path(exercise_dir, "evaluation"),
27-
source=Path(exercise_dir, "solution/comp-error.cpp"),
27+
source=Path(exercise_dir, "solution/solution.cpp"),
2828
judge=Path("."),
2929
workdir=Path("workdir"),
30-
test_suite="one.tson",
30+
test_suite="full.tson",
3131
options=Options(
3232
linter=False,
3333
),

tests/exercises/isbn/solution/solution.cpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ bool is_isbn10(const std::string &code) {
2727
return check_digit(code) == code[9];
2828
}
2929

30-
template <typename T> bool is_isbn10(const T &code) {
31-
return false;
32-
}
33-
34-
template <typename ...Ts> bool is_isbn10(const std::variant<Ts...> &code) {
35-
return std::visit(is_isbn10, code);
36-
}
37-
3830
bool is_isbn13(const std::string &code) {
3931
// Helper function for computing ISBN-13 check digit
4032
auto check_digit = [](const std::string &code) -> char {
@@ -58,12 +50,24 @@ bool is_isbn13(const std::string &code) {
5850
return check_digit(code) == code[12];
5951
}
6052

61-
template <typename T> bool is_isbn13(const T &code) {
53+
template <typename T>
54+
bool is_isbn10(const T &code) {
55+
return false;
56+
}
57+
58+
template <typename ...Ts>
59+
bool is_isbn10(const std::variant<Ts...> &code) {
60+
return std::visit([](const auto& value) { return is_isbn10(value); }, code);
61+
}
62+
63+
template <typename T>
64+
bool is_isbn13(const T &code) {
6265
return false;
6366
}
6467

65-
template <typename ...Ts> bool is_isbn13(const std::variant<Ts...> &code) {
66-
return std::visit(is_isbn10, code);
68+
template <typename ...Ts>
69+
bool is_isbn13(const std::variant<Ts...> &code) {
70+
return std::visit([](const auto& value) { return is_isbn13(value); }, code);
6771
}
6872

6973
template <typename T>
@@ -76,15 +80,16 @@ bool _is_isbn(const std::string &code) {
7680
return is_isbn(code, isbn13);
7781
}
7882

79-
template <typename T> bool _is_isbn(const T &code) {
83+
template <typename T>
84+
bool _is_isbn(const T &code) {
8085
return false;
8186
}
8287

83-
template <typename ...Ts> bool _is_isbn(const std::variant<Ts...> &code) {
88+
template <typename ...Ts>
89+
bool _is_isbn(const std::variant<Ts...> &code) {
8490
return std::visit([](const auto& value) { return _is_isbn(value); }, code);
8591
}
8692

87-
8893
template <typename T>
8994
std::vector<bool> are_isbn(const std::vector<T> &codes) {
9095
std::vector<bool> checks;

tests/test_parallel_execution.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from tests.manual_utils import assert_valid_output, configuration, execute_config
1111

1212

13-
@pytest.mark.parametrize("lang", ["python", "java", "kotlin"])
13+
@pytest.mark.parametrize("lang", ["python", "java", "kotlin", "cpp"])
1414
def test_parallel_isbn(lang: str, tmp_path: Path, pytestconfig: pytest.Config):
1515
config_ = {"options": {"parallel": True}}
1616
conf = configuration(
@@ -30,6 +30,7 @@ def test_parallel_isbn(lang: str, tmp_path: Path, pytestconfig: pytest.Config):
3030
"kotlin",
3131
"haskell",
3232
"runhaskell",
33+
"cpp"
3334
],
3435
)
3536
def test_parallel_isbn_list(lang: str, tmp_path: Path, pytestconfig: pytest.Config):
@@ -49,7 +50,7 @@ def test_parallel_isbn_list(lang: str, tmp_path: Path, pytestconfig: pytest.Conf
4950
assert updates.find_status_enum() == ["correct"] * 100
5051

5152

52-
@pytest.mark.parametrize("lang", ["java", "python", "kotlin"])
53+
@pytest.mark.parametrize("lang", ["java", "python", "kotlin", "cpp"])
5354
def test_parallel_lotto(lang: str, tmp_path: Path, pytestconfig: pytest.Config):
5455
config_ = {"options": {"parallel": True}}
5556
conf = configuration(

0 commit comments

Comments
 (0)