Spaces:
Sleeping
Sleeping
Muennighoff
commited on
Commit
•
9382ca3
1
Parent(s):
2e80bdf
Fix cpp
Browse files- execute.py +31 -35
execute.py
CHANGED
@@ -100,44 +100,40 @@ def unsafe_execute_cpp(check_program, result, timeout):
|
|
100 |
with create_tempdir():
|
101 |
open(f"test.cpp", 'w').write(check_program)
|
102 |
|
103 |
-
#
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
)
|
113 |
-
if compilation_result.returncode != 0:
|
114 |
-
if compilation_result.stderr:
|
115 |
-
err = compilation_result.stderr.decode()
|
116 |
-
else:
|
117 |
-
err = compilation_result.stdout.decode()
|
118 |
-
result.append(f"failed: compilation error: {err}")
|
119 |
else:
|
120 |
-
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
123 |
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
else:
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
except:
|
136 |
-
err = exec_result.stdout
|
137 |
-
result.append(f"failed: {err}")
|
138 |
-
|
139 |
-
except TimeoutException:
|
140 |
-
result.append("timed out")
|
141 |
|
142 |
def unsafe_execute_js(check_program, result, timeout):
|
143 |
|
|
|
100 |
with create_tempdir():
|
101 |
open(f"test.cpp", 'w').write(check_program)
|
102 |
|
103 |
+
# -lcrypto & -lssl are needed for the crypto library required by HumanEval-X-Bugs Task 162
|
104 |
+
compilation_result = subprocess.run(
|
105 |
+
["/usr/bin/g++", "-std=c++11", "test.cpp", "-lcrypto", "-lssl"],
|
106 |
+
timeout=timeout,
|
107 |
+
capture_output=True,
|
108 |
+
)
|
109 |
+
if compilation_result.returncode != 0:
|
110 |
+
if compilation_result.stderr:
|
111 |
+
err = compilation_result.stderr.decode()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
else:
|
113 |
+
err = compilation_result.stdout.decode()
|
114 |
+
result.append(f"failed: compilation error: {err}")
|
115 |
+
else:
|
116 |
+
try:
|
117 |
+
with time_limit(timeout):
|
118 |
+
exec_result = subprocess.run(["./a.out"], timeout=timeout, capture_output=True)
|
119 |
|
120 |
+
if exec_result.returncode == 0:
|
121 |
+
result.append("passed")
|
122 |
+
else:
|
123 |
+
if exec_result.stderr:
|
124 |
+
try:
|
125 |
+
err = exec_result.stderr.decode()
|
126 |
+
except:
|
127 |
+
err = exec_result.stderr
|
128 |
else:
|
129 |
+
try:
|
130 |
+
err = exec_result.stdout.decode()
|
131 |
+
except:
|
132 |
+
err = exec_result.stdout
|
133 |
+
result.append(f"failed: {err}")
|
134 |
+
|
135 |
+
except TimeoutException:
|
136 |
+
result.append("timed out")
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
def unsafe_execute_js(check_program, result, timeout):
|
139 |
|