-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
89 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,3 +64,4 @@ testcases/string | |
testcases/string | ||
testcases/string.xsharp.bc | ||
testcases/string.xsharp.o | ||
LLVMIR/test/temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,66 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import difflib | ||
import os | ||
|
||
parser = argparse.ArgumentParser(); | ||
parser = argparse.ArgumentParser() | ||
allgroup = parser.add_mutually_exclusive_group() | ||
parser.add_argument_group() | ||
|
||
parser.add_argument('-v', '--verbose', help="Print test information in detail", action="store_false") | ||
|
||
allgroup.add_argument('-a', '--all', help="Test all testsuites", action="store_true") | ||
allgroup.add_argument('--ast', help="Test generating AST", action="store_false"), | ||
allgroup.add_argument('--llvm', help="Test generating LLVM-IR", action="store_false"), | ||
allgroup.add_argument('--java', help="Test generating Java bytecode (Not supported)", action="store_true") | ||
parser.add_argument( | ||
"-v", "--verbose", help="Print test information in detail", action="store_true" | ||
) | ||
allgroup.add_argument("-a", "--all", help="Test all testsuites", action="store_true") | ||
allgroup.add_argument("--ast", help="Test generating AST", action="store_false"), | ||
allgroup.add_argument("--llvm", help="Test generating LLVM-IR", action="store_false"), | ||
allgroup.add_argument( | ||
"--java", help="Test generating Java bytecode (Not supported)", action="store_true" | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
project_path = os.path.split(os.path.split(os.path.realpath(__file__))[0])[0] | ||
bin_path = os.path.join(project_path, "bin") | ||
xsharpc_path = os.path.join(bin_path, "xsharpc") | ||
|
||
total_test = 0 | ||
failure_test = 0 | ||
|
||
# Test LLVM-IR generation | ||
llvm_test_path = os.path.join(project_path, "LLVMIR/test") | ||
files = os.listdir(llvm_test_path) | ||
|
||
for file in files: | ||
file_path = os.path.join(llvm_test_path, file) | ||
|
||
if file.endswith(".xsharp"): | ||
source_path = file_path | ||
ir_path = file_path + ".ll" | ||
total_test += 1 | ||
|
||
with open(source_path, mode="r") as source: | ||
os.makedirs(os.path.join(llvm_test_path, "temp"), exist_ok=True) | ||
temp_path = os.path.join(llvm_test_path, "temp", file + ".ll") | ||
os.popen(xsharpc_path + " --emit-llvm-ir " + file_path + " -o " + temp_path) | ||
|
||
with open(temp_path, mode="r") as temp: | ||
temp_lines = temp.readlines() | ||
|
||
with open(ir_path, mode="r") as ir: | ||
ir_lines = ir.readlines() | ||
|
||
if ir_lines != temp_lines: | ||
failure_test += 1 | ||
print("[{}] Test failed at {}:".format(total_test,source_path)) | ||
|
||
if args.verbose: | ||
print(''.join(list(difflib.ndiff(ir_lines, temp_lines)))) | ||
else: | ||
print("[{}] Test passed {}:".format(total_test,source_path)) | ||
|
||
print(project_path) | ||
|
||
print("===================Test Completed=======================") | ||
print("Total {} tests".format(total_test)) | ||
print("Passed {} tests".format(total_test - failure_test)) | ||
print("Failed {} tests".format(failure_test)) |