Skip to content
Snippets Groups Projects
Commit 3c42d6f8 authored by Nicholas Robinson's avatar Nicholas Robinson
Browse files

Test.py only output errors

parent 592614d8
No related branches found
No related tags found
No related merge requests found
...@@ -40,16 +40,27 @@ def a2Multiple(): ...@@ -40,16 +40,27 @@ def a2Multiple():
testCases = [f.path for f in scandir(testDirectory) if f.is_dir()] testCases = [f.path for f in scandir(testDirectory) if f.is_dir()]
for c in testCases: for c in testCases:
print("**********************************************************") # print("**********************************************************")
print("DIRECTORY") # print("DIRECTORY")
print(c) # print(c)
print("**********************************************************") # print("**********************************************************")
# get all files from stdlib folder # get all files from stdlib folder
testFiles = [join(dp, f) for dp, dn, filenames in walk('stdlib/2.0/java/') for f in filenames] testFiles = [join(dp, f) for dp, dn, filenames in walk('stdlib/2.0/java/') for f in filenames]
# get all files in the folder recursively # get all files in the folder recursively
testFiles += [join(dp, f) for dp, dn, filenames in walk(c) for f in filenames] testFiles += [join(dp, f) for dp, dn, filenames in walk(c) for f in filenames]
run(testFiles) ret = run(testFiles)
print("\n \n\n ") if ret == "":
# print(c)
if 'Je_' in c:
print(c)
print("JE Passed without error")
print("**********************************************************")
else:
if not 'Je_' in c:
print(c)
print(ret)
print("**********************************************************")
# print("\n \n\n ")
...@@ -57,7 +68,7 @@ def run(testFiles): ...@@ -57,7 +68,7 @@ def run(testFiles):
parseTrees = [] parseTrees = []
for f in testFiles: for f in testFiles:
print(f) # print(f)
content = open(f, "r").read() content = open(f, "r").read()
# Scanning # Scanning
...@@ -65,6 +76,7 @@ def run(testFiles): ...@@ -65,6 +76,7 @@ def run(testFiles):
# Error in Scanning # Error in Scanning
if tokens is None: if tokens is None:
print(f)
print("ERROR in Scanning: " + error) print("ERROR in Scanning: " + error)
print("**********************************************************") print("**********************************************************")
continue continue
...@@ -79,6 +91,7 @@ def run(testFiles): ...@@ -79,6 +91,7 @@ def run(testFiles):
# No weeds if everything is good (weeds = None) # No weeds if everything is good (weeds = None)
weeds = Weeding.fileNameCheck(tokens, f) weeds = Weeding.fileNameCheck(tokens, f)
if weeds: if weeds:
print(f)
print("ERROR in Weeding after Scanning:") print("ERROR in Weeding after Scanning:")
print(weeds) print(weeds)
print("**********************************************************") print("**********************************************************")
...@@ -94,7 +107,7 @@ def run(testFiles): ...@@ -94,7 +107,7 @@ def run(testFiles):
# Error in Parsing # Error in Parsing
if tree is None: if tree is None:
# print(f) print(f)
print("ERROR in Parsing: " + error.args[0]) print("ERROR in Parsing: " + error.args[0])
# for n in error.args[1]: # the parse tree # for n in error.args[1]: # the parse tree
# print(n) # print(n)
...@@ -103,8 +116,8 @@ def run(testFiles): ...@@ -103,8 +116,8 @@ def run(testFiles):
parseTrees.append((f, tree)) parseTrees.append((f, tree))
print("Scan and Parse Succeeded") # print("Scan and Parse Succeeded")
print("**********************************************************") # print("**********************************************************")
ASTs = astBuild(parseTrees) ASTs = astBuild(parseTrees)
...@@ -119,9 +132,9 @@ def run(testFiles): ...@@ -119,9 +132,9 @@ def run(testFiles):
buildEnvAndLink(ASTs) buildEnvAndLink(ASTs)
except Exception as e: except Exception as e:
# print(testFiles) # print(testFiles)
print("error at environment building and linking") # print("error at environment building and linking")
print(e) # print(e)
return return "buildEnvAndLink: " + e.args[0]
# print("<<<<------- after buildEnvAndLink -------->>>>>>") # print("<<<<------- after buildEnvAndLink -------->>>>>>")
# for (n, t) in ASTs: # for (n, t) in ASTs:
...@@ -130,7 +143,8 @@ def run(testFiles): ...@@ -130,7 +143,8 @@ def run(testFiles):
# t.printTree() # t.printTree()
# print("\n \n\n \n") # print("\n \n\n \n")
print("Succeeded") # print("Succeeded")
print("**********************************************************") # print("**********************************************************")
return ""
main() main()
...@@ -126,7 +126,7 @@ class ClassNode(ASTNode): ...@@ -126,7 +126,7 @@ class ClassNode(ASTNode):
# check if not acyclic # check if not acyclic
if self.name in hierarchy: if self.name in hierarchy:
raise Exception("ERROR: The hierarchy is not acyclic '{}'".format(hierarchy)) raise Exception("ERROR: The hierarchy is not acyclic '{}', saw '{}'".format(hierarchy, self.name))
hierarchy.append(self.name) hierarchy.append(self.name)
# get contains # get contains
contains = self.methods contains = self.methods
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment