mise à jour des tests
This commit is contained in:
@@ -20,14 +20,14 @@ def clangName():
|
|||||||
|
|
||||||
clang = clangName()
|
clang = clangName()
|
||||||
|
|
||||||
def runTestNormalLevel(level):
|
def runNormalTestSuit(testSuit):
|
||||||
print(f"Running test of level {level}")
|
print(f"Running test suit : {testSuit}")
|
||||||
stats[level] = (0,0,0,0)
|
stats[testSuit] = (0,0,0,0)
|
||||||
for dirname, dirnames, filenames in os.walk(f'./tests/testlevel{level}'):
|
for dirname, dirnames, filenames in os.walk(testSuit):
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
runNormalTest(level, dirname, filename)
|
runNormalTest(testSuit, dirname, filename)
|
||||||
|
|
||||||
def runNormalTest(i, dirname,filename):
|
def runNormalTest(testSuit, dirname,filename):
|
||||||
vslToLLVM = False
|
vslToLLVM = False
|
||||||
llvmToBin = False
|
llvmToBin = False
|
||||||
executionCorrect = False
|
executionCorrect = False
|
||||||
@@ -55,29 +55,29 @@ def runNormalTest(i, dirname,filename):
|
|||||||
|
|
||||||
# Exe
|
# Exe
|
||||||
if llvmToBin :
|
if llvmToBin :
|
||||||
|
executionCorrect = True
|
||||||
try:
|
try:
|
||||||
|
input = ""
|
||||||
if os.path.isfile(f"{basename}.test_in"):
|
if os.path.isfile(f"{basename}.test_in"):
|
||||||
p = subprocess.run(f"./{basename} < {basename}.test_in", shell=True, stdout=subprocess.PIPE, timeout=10)
|
input = f"< {basename}.test_in"
|
||||||
else:
|
p = subprocess.run(f"./{basename} " + input, shell=True, stdout=subprocess.PIPE, timeout=5)
|
||||||
p = subprocess.run(f"./{basename}", shell=True, stdout=subprocess.PIPE, timeout=10)
|
|
||||||
except subprocess.TimeoutExpired:
|
except subprocess.TimeoutExpired:
|
||||||
executionCorrect = basename == "./tests/testlevel4/level4diverge"
|
executionCorrect = "diverge" in basename
|
||||||
|
|
||||||
# Check return code
|
# Check return code
|
||||||
if os.path.isfile(f"{basename}.test_ret"):
|
if os.path.isfile(f"{basename}.test_ret"):
|
||||||
with open(f"{basename}.test_ret", "r") as expected:
|
with open(f"{basename}.test_ret", "r") as expected:
|
||||||
executionCorrect = int(expected.read()) == p.returncode
|
executionCorrect = executionCorrect and int(expected.read()) == p.returncode
|
||||||
# Check stdout
|
# Check stdout
|
||||||
if os.path.isfile(f"{basename}.test_out"):
|
if os.path.isfile(f"{basename}.test_out"):
|
||||||
with open(f"{basename}.test_out", "rb") as expected:
|
with open(f"{basename}.test_out", "rb") as expected:
|
||||||
executionCorrect = executionCorrect and expected.read() == p.stdout
|
executionCorrect = executionCorrect and expected.read() == p.stdout
|
||||||
|
|
||||||
|
|
||||||
print(f"{colorFromBool(vslToLLVM)}\t\tVSL to LLVM : {'OK' if vslToLLVM else 'Fail'}{Style.RESET_ALL}")
|
print(f"{colorFromBool(vslToLLVM)}\t\tVSL to LLVM : {'OK' if vslToLLVM else 'Fail'}{Style.RESET_ALL}")
|
||||||
print(f"{colorFromBool(llvmToBin)}\t\tLLVM to Bin : {'OK' if llvmToBin else 'Fail'}{Style.RESET_ALL}")
|
print(f"{colorFromBool(llvmToBin)}\t\tLLVM to Bin : {'OK' if llvmToBin else 'Fail'}{Style.RESET_ALL}")
|
||||||
print(f"{colorFromBool(executionCorrect)}\t\tCorrect Execution : {'OK' if executionCorrect else 'Fail'}{Style.RESET_ALL}")
|
print(f"{colorFromBool(executionCorrect)}\t\tCorrect Execution : {'OK' if executionCorrect else 'Fail'}{Style.RESET_ALL}")
|
||||||
|
|
||||||
x,y,z,t = stats[i]
|
x,y,z,t = stats[testSuit]
|
||||||
if vslToLLVM :
|
if vslToLLVM :
|
||||||
x += 1
|
x += 1
|
||||||
if llvmToBin :
|
if llvmToBin :
|
||||||
@@ -85,7 +85,7 @@ def runNormalTest(i, dirname,filename):
|
|||||||
if executionCorrect :
|
if executionCorrect :
|
||||||
z += 1
|
z += 1
|
||||||
t += 1
|
t += 1
|
||||||
stats[i] = (x,y,z,t)
|
stats[testSuit] = (x,y,z,t)
|
||||||
|
|
||||||
def colorFromBool(b):
|
def colorFromBool(b):
|
||||||
if b:
|
if b:
|
||||||
@@ -104,7 +104,7 @@ def afficheStats(stat):
|
|||||||
nbError = 0
|
nbError = 0
|
||||||
nbErrorTests = 0
|
nbErrorTests = 0
|
||||||
|
|
||||||
def runErrorTest(dirname,filename):
|
def runErrorTest(testSuit, dirname,filename):
|
||||||
path = os.path.join(dirname, filename)
|
path = os.path.join(dirname, filename)
|
||||||
basename, ext = os.path.splitext(path)
|
basename, ext = os.path.splitext(path)
|
||||||
if ext != ".vsl":
|
if ext != ".vsl":
|
||||||
@@ -112,37 +112,51 @@ def runErrorTest(dirname,filename):
|
|||||||
|
|
||||||
print(f'\tRunning test {filename}')
|
print(f'\tRunning test {filename}')
|
||||||
|
|
||||||
global nbErrorTests
|
hasError = False
|
||||||
nbErrorTests = nbErrorTests + 1
|
|
||||||
|
|
||||||
p = subprocess.run(f"java -jar build/libs/TP2.jar < {path} 1>{basename}.ll", shell=True, stderr=subprocess.PIPE)
|
p = subprocess.run(f"java -jar build/libs/TP2.jar < {path} 1>{basename}.ll", shell=True, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
if p.returncode != 0 and p.stderr != b'':
|
if p.returncode != 0 and p.stderr != b'':
|
||||||
print(f"\t\t{Fore.GREEN}Error : Yes{Style.RESET_ALL}")
|
print(f"\t\t{Fore.GREEN}Error : Yes{Style.RESET_ALL}")
|
||||||
global nbError
|
hasError = True
|
||||||
nbError = nbError + 1
|
|
||||||
return 1
|
|
||||||
else:
|
else:
|
||||||
print(f"\t\t{Fore.RED}Error : No{Style.RESET_ALL}")
|
print(f"\t\t{Fore.RED}Error : No{Style.RESET_ALL}")
|
||||||
return 0
|
hasError = False
|
||||||
|
|
||||||
def runErrorLevelTests():
|
x,t = stats[testSuit]
|
||||||
print(f"Running test of level error")
|
if hasError :
|
||||||
for dirname, dirnames, filenames in os.walk(f'./tests/testlevelerror'):
|
x += 1
|
||||||
# print path to all filenames.
|
t += 1
|
||||||
|
stats[testSuit] = (x,t)
|
||||||
|
|
||||||
|
|
||||||
|
def runErrorLevelTests(testSuit):
|
||||||
|
print(f"Running test suit : {testSuit}")
|
||||||
|
stats[testSuit] = (0,0)
|
||||||
|
for dirname, dirnames, filenames in os.walk(testSuit):
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
runErrorTest( dirname, filename)
|
runErrorTest(testSuit, dirname, filename)
|
||||||
|
|
||||||
|
|
||||||
def runTests(testDirname):
|
def runTests(testDirName):
|
||||||
for i in range(1,5):
|
folderContent = [os.path.join(testDirName, d) for d in os.listdir(testDirName)]
|
||||||
runTestNormalLevel(i)
|
testSuits = [d for d in folderContent if os.path.isdir(d)]
|
||||||
runErrorLevelTests()
|
testSuits.sort()
|
||||||
|
|
||||||
|
for suit in testSuits:
|
||||||
|
if "error" in suit or "Error" in suit:
|
||||||
|
runErrorLevelTests(suit)
|
||||||
|
else:
|
||||||
|
runNormalTestSuit(suit)
|
||||||
|
|
||||||
|
for suit in testSuits:
|
||||||
|
print(f'Résumé du test {suit}')
|
||||||
|
if "error" in suit or "Error" in suit:
|
||||||
|
nbError, nbErrorTests = stats[suit]
|
||||||
|
print(f'{colorFromBool(nbError==nbErrorTests)}\t Nombre d\'erreurs : {nbError} / {nbErrorTests}{Style.RESET_ALL}')
|
||||||
|
else:
|
||||||
|
afficheStats(stats[suit])
|
||||||
|
|
||||||
for i in range(1,5):
|
|
||||||
print(f'Résumé du level {i}')
|
|
||||||
afficheStats(stats[i])
|
|
||||||
print(f'Résumé du level error')
|
|
||||||
print(f'{colorFromBool(nbError==nbErrorTests)}\t Nombre d\'erreurs : {nbError} / {nbErrorTests}{Style.RESET_ALL}')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
FUNC INT main() RETURN 0 + 1 + 2
|
FUNC INT main() RETURN 0 + 1
|
||||||
1
tests/fragment0/add0.test_ret
Normal file
1
tests/fragment0/add0.test_ret
Normal file
@@ -0,0 +1 @@
|
|||||||
|
15
|
||||||
1
tests/fragment0/add0.vsl
Normal file
1
tests/fragment0/add0.vsl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
FUNC INT main() RETURN 7 + 8
|
||||||
1
tests/fragment0/add1.test_ret
Normal file
1
tests/fragment0/add1.test_ret
Normal file
@@ -0,0 +1 @@
|
|||||||
|
50
|
||||||
1
tests/fragment0/add1.vsl
Normal file
1
tests/fragment0/add1.vsl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
FUNC INT main() RETURN 7 + 8 + 5 + 10+10+ 10
|
||||||
1
tests/fragment0/const1.test_ret
Normal file
1
tests/fragment0/const1.test_ret
Normal file
@@ -0,0 +1 @@
|
|||||||
|
42
|
||||||
1
tests/fragment0/const1.vsl
Normal file
1
tests/fragment0/const1.vsl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
FUNC INT main() RETURN 42
|
||||||
1
tests/fragment0/div0.test_ret
Normal file
1
tests/fragment0/div0.test_ret
Normal file
@@ -0,0 +1 @@
|
|||||||
|
4
|
||||||
1
tests/fragment0/div0.vsl
Normal file
1
tests/fragment0/div0.vsl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
FUNC INT main() RETURN 20/5
|
||||||
1
tests/fragment0/div1.test_ret
Normal file
1
tests/fragment0/div1.test_ret
Normal file
@@ -0,0 +1 @@
|
|||||||
|
2
|
||||||
1
tests/fragment0/div1.vsl
Normal file
1
tests/fragment0/div1.vsl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
FUNC INT main() RETURN 12 / 3 / 2
|
||||||
1
tests/fragment0/mod.vsl
Normal file
1
tests/fragment0/mod.vsl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
FUNC INT main() RETURN 21 % 5
|
||||||
1
tests/fragment0/mult1.test_ret
Normal file
1
tests/fragment0/mult1.test_ret
Normal file
@@ -0,0 +1 @@
|
|||||||
|
20
|
||||||
1
tests/fragment0/mult1.vsl
Normal file
1
tests/fragment0/mult1.vsl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
FUNC INT main() RETURN 4*5
|
||||||
1
tests/fragment0/mult2.test_ret
Normal file
1
tests/fragment0/mult2.test_ret
Normal file
@@ -0,0 +1 @@
|
|||||||
|
40
|
||||||
1
tests/fragment0/mult2.vsl
Normal file
1
tests/fragment0/mult2.vsl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
FUNC INT main() RETURN 4*5*2
|
||||||
1
tests/fragment0/paren.test_ret
Normal file
1
tests/fragment0/paren.test_ret
Normal file
@@ -0,0 +1 @@
|
|||||||
|
120
|
||||||
1
tests/fragment0/paren.vsl
Normal file
1
tests/fragment0/paren.vsl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
FUNC INT main() RETURN 4 * (6 + 4) * 3
|
||||||
1
tests/fragment0/priority1.test_ret
Normal file
1
tests/fragment0/priority1.test_ret
Normal file
@@ -0,0 +1 @@
|
|||||||
|
37
|
||||||
1
tests/fragment0/priority1.vsl
Normal file
1
tests/fragment0/priority1.vsl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
FUNC INT main() RETURN 4 + 6 * 5 + 3
|
||||||
1
tests/fragment0/priority2.test_ret
Normal file
1
tests/fragment0/priority2.test_ret
Normal file
@@ -0,0 +1 @@
|
|||||||
|
8
|
||||||
1
tests/fragment0/priority2.vsl
Normal file
1
tests/fragment0/priority2.vsl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
FUNC INT main() RETURN 1 + 2 * (4 + 5 % 3 + 2) - 3 - 16 / 8 - 4
|
||||||
1
tests/fragment0/sub0.test_ret
Normal file
1
tests/fragment0/sub0.test_ret
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3
|
||||||
1
tests/fragment0/sub0.vsl
Normal file
1
tests/fragment0/sub0.vsl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
FUNC INT main() RETURN 8-5
|
||||||
1
tests/fragment0/sub1.test_ret
Normal file
1
tests/fragment0/sub1.test_ret
Normal file
@@ -0,0 +1 @@
|
|||||||
|
85
|
||||||
1
tests/fragment0/sub1.vsl
Normal file
1
tests/fragment0/sub1.vsl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
FUNC INT main() RETURN 100 + (10 - 20 - 5)
|
||||||
5
tests/fragment1/assign1.vsl
Normal file
5
tests/fragment1/assign1.vsl
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FUNC INT main() {
|
||||||
|
INT x
|
||||||
|
x := 1
|
||||||
|
RETURN x
|
||||||
|
}
|
||||||
6
tests/fragment1/assign2.vsl
Normal file
6
tests/fragment1/assign2.vsl
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
FUNC INT main() {
|
||||||
|
INT x, y
|
||||||
|
x := 1
|
||||||
|
y := x
|
||||||
|
RETURN y
|
||||||
|
}
|
||||||
1
tests/fragment1/decl.test_ret
Normal file
1
tests/fragment1/decl.test_ret
Normal file
@@ -0,0 +1 @@
|
|||||||
|
2
|
||||||
4
tests/fragment1/decl.vsl
Normal file
4
tests/fragment1/decl.vsl
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
FUNC INT main() {
|
||||||
|
INT x
|
||||||
|
RETURN 2
|
||||||
|
}
|
||||||
1
tests/fragment1/if1.test_ret
Normal file
1
tests/fragment1/if1.test_ret
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
1
tests/fragment1/if2.test_ret
Normal file
1
tests/fragment1/if2.test_ret
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
1
tests/fragment1/print2.test_out
Normal file
1
tests/fragment1/print2.test_out
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
@@ -5,3 +5,4 @@
|
|||||||
5+1 = 6
|
5+1 = 6
|
||||||
5* (5+7) = 60
|
5* (5+7) = 60
|
||||||
5* 5+7 = 32
|
5* 5+7 = 32
|
||||||
|
-2 = -2
|
||||||
@@ -6,5 +6,6 @@ FUNC VOID main() {
|
|||||||
PRINT 5,"+",1," = ", 5+1 ,"\n"
|
PRINT 5,"+",1," = ", 5+1 ,"\n"
|
||||||
PRINT 5,"* (",5,"+",7,") = ", 5*(5+7) ,"\n"
|
PRINT 5,"* (",5,"+",7,") = ", 5*(5+7) ,"\n"
|
||||||
PRINT 5,"* ",5,"+",7," = ", 5 * 5 + 7 ,"\n"
|
PRINT 5,"* ",5,"+",7," = ", 5 * 5 + 7 ,"\n"
|
||||||
|
PRINT "-2 = ", -2
|
||||||
}
|
}
|
||||||
|
|
||||||
3
tests/fragment1/read2.test_in
Normal file
3
tests/fragment1/read2.test_in
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
2
|
||||||
|
7
|
||||||
|
|
||||||
1
tests/fragment1/read2.test_out
Normal file
1
tests/fragment1/read2.test_out
Normal file
@@ -0,0 +1 @@
|
|||||||
|
x vaut 2 et y vaut 7
|
||||||
5
tests/fragment1/read2.vsl
Normal file
5
tests/fragment1/read2.vsl
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FUNC VOID main() {
|
||||||
|
INT x,y
|
||||||
|
READ x, y
|
||||||
|
PRINT "x vaut ",x," et y vaut ",y
|
||||||
|
}
|
||||||
1
tests/fragment1/while2.test_ret
Normal file
1
tests/fragment1/while2.test_ret
Normal file
@@ -0,0 +1 @@
|
|||||||
|
84
|
||||||
10
tests/fragment1/while2.vsl
Normal file
10
tests/fragment1/while2.vsl
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
FUNC INT main() {
|
||||||
|
INT x, y x :=
|
||||||
|
42 y:=0
|
||||||
|
WHILE x DO {
|
||||||
|
x := x - 1
|
||||||
|
y := y + 2
|
||||||
|
} DONE
|
||||||
|
RETURN y
|
||||||
|
}
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user