red1bluelost
commited on
Commit
•
7b93847
1
Parent(s):
903ed69
Updates constrain usage.
Browse files- execute.py +44 -27
execute.py
CHANGED
@@ -4,6 +4,10 @@ import os
|
|
4 |
import subprocess
|
5 |
import tempfile
|
6 |
|
|
|
|
|
|
|
|
|
7 |
|
8 |
def check_correctness(candidate, reference, cpp_type, task_id, completion_id):
|
9 |
"""
|
@@ -30,15 +34,18 @@ def check_correctness(candidate, reference, cpp_type, task_id, completion_id):
|
|
30 |
base_run_result,
|
31 |
"c++17",
|
32 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
result = {
|
34 |
**result,
|
35 |
**dict(
|
36 |
-
base_run_passed=
|
37 |
-
base_run_compiled=
|
38 |
-
|
39 |
-
or base_run_result[0].startswith("failed: runtime error:")
|
40 |
-
),
|
41 |
-
base_run_result=base_run_result[0],
|
42 |
),
|
43 |
}
|
44 |
elif cpp_type == "sfinae":
|
@@ -58,17 +65,23 @@ def check_correctness(candidate, reference, cpp_type, task_id, completion_id):
|
|
58 |
sfinae_constrain_result,
|
59 |
"c++17",
|
60 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
result = {
|
62 |
**result,
|
63 |
**dict(
|
64 |
-
sfinae_run_passed=
|
65 |
-
sfinae_run_compiled=
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
sfinae_run_result=sfinae_run_result[0],
|
70 |
-
sfinae_constrain_passed=sfinae_constrain_result[0] == "passed",
|
71 |
-
sfinae_constrain_result=sfinae_constrain_result[0],
|
72 |
),
|
73 |
}
|
74 |
elif cpp_type == "concepts":
|
@@ -88,20 +101,24 @@ def check_correctness(candidate, reference, cpp_type, task_id, completion_id):
|
|
88 |
concepts_constrain_result,
|
89 |
"c++20",
|
90 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
result = {
|
92 |
**result,
|
93 |
**dict(
|
94 |
-
concepts_run_passed=
|
95 |
-
concepts_run_compiled=
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
)
|
100 |
-
),
|
101 |
-
concepts_run_result=concepts_run_result[0],
|
102 |
-
concepts_constrain_passed=concepts_constrain_result[0]
|
103 |
-
== "passed",
|
104 |
-
concepts_constrain_result=concepts_constrain_result[0],
|
105 |
),
|
106 |
}
|
107 |
else:
|
@@ -129,7 +146,7 @@ def process_case(target, candidate, reference, result, cppstd):
|
|
129 |
|
130 |
def unsafe_execute_cpp(candidate, reference, result, timeout, cppstd):
|
131 |
with create_tempdir():
|
132 |
-
code = "
|
133 |
open(f"test.cpp", "w").write(code)
|
134 |
|
135 |
cpp_compiler = os.getenv("GENERICIFY_CLANG")
|
@@ -171,7 +188,7 @@ def unsafe_execute_cpp(candidate, reference, result, timeout, cppstd):
|
|
171 |
|
172 |
def invalid_compile_cpp(candidate, reference, result, timeout, cppstd):
|
173 |
with create_tempdir():
|
174 |
-
code = "
|
175 |
open(f"invalid.cpp", "w").write(code)
|
176 |
|
177 |
cpp_compiler = os.getenv("GENERICIFY_CLANG")
|
|
|
4 |
import subprocess
|
5 |
import tempfile
|
6 |
|
7 |
+
HEADERS: str = """
|
8 |
+
#include <bits/stdc++.h>
|
9 |
+
"""
|
10 |
+
|
11 |
|
12 |
def check_correctness(candidate, reference, cpp_type, task_id, completion_id):
|
13 |
"""
|
|
|
34 |
base_run_result,
|
35 |
"c++17",
|
36 |
)
|
37 |
+
base_run_result = base_run_result[0]
|
38 |
+
base_run_passed = base_run_result == "passed"
|
39 |
+
base_run_compiled = (
|
40 |
+
base_run_result == "passed"
|
41 |
+
or base_run_result.startswith("failed: runtime error:")
|
42 |
+
)
|
43 |
result = {
|
44 |
**result,
|
45 |
**dict(
|
46 |
+
base_run_passed=base_run_passed,
|
47 |
+
base_run_compiled=base_run_compiled,
|
48 |
+
base_run_result=base_run_result,
|
|
|
|
|
|
|
49 |
),
|
50 |
}
|
51 |
elif cpp_type == "sfinae":
|
|
|
65 |
sfinae_constrain_result,
|
66 |
"c++17",
|
67 |
)
|
68 |
+
sfinae_run_result = sfinae_run_result[0]
|
69 |
+
sfinae_constrain_result = sfinae_constrain_result[0]
|
70 |
+
sfinae_run_passed = sfinae_run_result == "passed"
|
71 |
+
sfinae_run_compiled = sfinae_run_passed or sfinae_run_result.startswith(
|
72 |
+
"failed: runtime error:"
|
73 |
+
)
|
74 |
+
sfinae_constrain_passed = (
|
75 |
+
sfinae_constrain_result == "passed" and sfinae_run_compiled
|
76 |
+
)
|
77 |
result = {
|
78 |
**result,
|
79 |
**dict(
|
80 |
+
sfinae_run_passed=sfinae_run_passed,
|
81 |
+
sfinae_run_compiled=sfinae_run_compiled,
|
82 |
+
sfinae_run_result=sfinae_run_result,
|
83 |
+
sfinae_constrain_passed=sfinae_constrain_passed,
|
84 |
+
sfinae_constrain_result=sfinae_constrain_result,
|
|
|
|
|
|
|
85 |
),
|
86 |
}
|
87 |
elif cpp_type == "concepts":
|
|
|
101 |
concepts_constrain_result,
|
102 |
"c++20",
|
103 |
)
|
104 |
+
concepts_run_result = concepts_run_result[0]
|
105 |
+
concepts_constrain_result = concepts_constrain_result[0]
|
106 |
+
concepts_run_passed = concepts_run_result == "passed"
|
107 |
+
concepts_run_compiled = (
|
108 |
+
concepts_run_passed
|
109 |
+
or concepts_run_result.startswith("failed: runtime error:")
|
110 |
+
)
|
111 |
+
concepts_constrain_passed = (
|
112 |
+
concepts_constrain_result == "passed" and concepts_run_compiled
|
113 |
+
)
|
114 |
result = {
|
115 |
**result,
|
116 |
**dict(
|
117 |
+
concepts_run_passed=concepts_run_passed,
|
118 |
+
concepts_run_compiled=concepts_run_compiled,
|
119 |
+
concepts_run_result=concepts_run_result,
|
120 |
+
concepts_constrain_passed=concepts_constrain_passed,
|
121 |
+
concepts_constrain_result=concepts_constrain_result,
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
),
|
123 |
}
|
124 |
else:
|
|
|
146 |
|
147 |
def unsafe_execute_cpp(candidate, reference, result, timeout, cppstd):
|
148 |
with create_tempdir():
|
149 |
+
code = "\n".join([HEADERS, candidate, reference])
|
150 |
open(f"test.cpp", "w").write(code)
|
151 |
|
152 |
cpp_compiler = os.getenv("GENERICIFY_CLANG")
|
|
|
188 |
|
189 |
def invalid_compile_cpp(candidate, reference, result, timeout, cppstd):
|
190 |
with create_tempdir():
|
191 |
+
code = "\n".join([HEADERS, candidate, reference])
|
192 |
open(f"invalid.cpp", "w").write(code)
|
193 |
|
194 |
cpp_compiler = os.getenv("GENERICIFY_CLANG")
|