File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 4
4
import re
5
5
import subprocess
6
6
import sys
7
- import tempfile
7
+
8
+ from tempfile import mkstemp
8
9
9
10
from colorama import init , Fore , Style
10
11
@@ -53,14 +54,17 @@ def make_test(filename):
53
54
translator = Translator ()
54
55
lua_code = translator .translate (content )
55
56
56
- tmp_file = tempfile .NamedTemporaryFile ("w" )
57
+ file_desc , filename = mkstemp ()
58
+
59
+ tmp_file = os .fdopen (file_desc , "w" )
57
60
tmp_file .write (Translator .get_luainit ()+ "\n " )
58
61
tmp_file .write (lua_code )
59
62
tmp_file .flush ()
63
+ tmp_file .close ()
60
64
61
65
output = []
62
66
63
- proc = subprocess .Popen ([LUA_PATH , tmp_file . name ],
67
+ proc = subprocess .Popen ([LUA_PATH , filename ],
64
68
stdout = subprocess .PIPE ,
65
69
stderr = subprocess .PIPE ,)
66
70
while True :
@@ -72,6 +76,15 @@ def make_test(filename):
72
76
73
77
output = "" .join (output )
74
78
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
+
75
88
result = output == expected
76
89
except RuntimeError :
77
90
result = False
You can’t perform that action at this time.
0 commit comments