Skip to content

Commit 495d1cc

Browse files
Fixed tests access denied error
1 parent 39b49ee commit 495d1cc

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

runtests.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import re
55
import subprocess
66
import sys
7-
import tempfile
7+
8+
from tempfile import mkstemp
89

910
from colorama import init, Fore, Style
1011

@@ -53,14 +54,17 @@ def make_test(filename):
5354
translator = Translator()
5455
lua_code = translator.translate(content)
5556

56-
tmp_file = tempfile.NamedTemporaryFile("w")
57+
file_desc, filename = mkstemp()
58+
59+
tmp_file = os.fdopen(file_desc, "w")
5760
tmp_file.write(Translator.get_luainit()+ "\n")
5861
tmp_file.write(lua_code)
5962
tmp_file.flush()
63+
tmp_file.close()
6064

6165
output = []
6266

63-
proc = subprocess.Popen([LUA_PATH, tmp_file.name],
67+
proc = subprocess.Popen([LUA_PATH, filename],
6468
stdout=subprocess.PIPE,
6569
stderr=subprocess.PIPE,)
6670
while True:
@@ -72,6 +76,15 @@ def make_test(filename):
7276

7377
output = "".join(output)
7478

79+
os.remove(filename)
80+
81+
output = [item.strip() for item in output.split("\n")]
82+
expected = [item.strip() for item in expected.split("\n")]
83+
84+
if output != expected:
85+
print("output: ", output)
86+
print("expected: ", expected)
87+
7588
result = output == expected
7689
except RuntimeError:
7790
result = False

0 commit comments

Comments
 (0)