-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move tests into visible 'tests' folder. make test_all python script, …
…and also update target-generating script (which helps with generating tests). reduce github-specific part to simply installing relevant dependencies and running the the test_all script.
- Loading branch information
Showing
21 changed files
with
228 additions
and
107 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# python3 .github/workflows/tests/make_tgts.py | ||
# !!!!! FOR RUNNING ON 'CORRECT' REPL | ||
import os | ||
|
||
|
||
testpath = "tests" | ||
inpath = testpath+"/in" | ||
outpath = testpath+"/out" | ||
tgtpath = testpath+"/tgt" | ||
libtestspath = testpath+"/broken_libs" | ||
libspath = libtestspath+"/lib" | ||
libtgtspath = libtestspath+"/tgt" | ||
liboutspath = libtestspath+"/out" | ||
|
||
curr_path_marker = "[current]" | ||
|
||
|
||
REPL_path = "RASP_support/REPL.py" | ||
rasplib_path = "RASP_support/rasplib.rasp" | ||
|
||
def things_in_path(path): | ||
if not os.path.exists(path): | ||
return [] | ||
return [p for p in os.listdir(path) if not p==".DS_Store"] | ||
|
||
def joinpath(*a): | ||
return "/".join(a) | ||
|
||
for p in [tgtpath,libtgtspath]: | ||
if not os.path.exists(p): | ||
os.makedirs(p) | ||
|
||
all_names = things_in_path(inpath) | ||
|
||
def fix_file_paths(filename,curr_path_marker): | ||
mypath = os.path.abspath(".") | ||
|
||
with open(filename,"r") as f: | ||
filecontents = "".join(f) | ||
|
||
filecontents = filecontents.replace(mypath,curr_path_marker) | ||
|
||
with open(filename,"w") as f: | ||
print(filecontents,file=f) | ||
|
||
|
||
def run_input(name): | ||
os.system("python3 "+REPL_path+" <"+inpath+"/"+name+" >"+tgtpath+"/"+name) | ||
fix_file_paths(tgtpath+"/"+name,curr_path_marker) | ||
|
||
def run_inputs(): | ||
print("making the target outputs!") | ||
for n in all_names: | ||
run_input(n) | ||
|
||
|
||
def run_broken_lib(l): | ||
os.system("cp "+joinpath(libspath,l)+" "+rasplib_path) | ||
os.system("python3 "+REPL_path+" <"+joinpath(libtestspath,"empty.txt")+ " >"+joinpath(libtgtspath,l)) | ||
|
||
|
||
real_rasplib_safe_place = "make_tgts_helper/temp" | ||
safe_rasplib_name = "safe_rasplib.rasp" | ||
|
||
def save_rasplib(): | ||
if not os.path.exists(real_rasplib_safe_place): | ||
os.makedirs(real_rasplib_safe_place) | ||
os.system("mv "+rasplib_path+" "+joinpath(real_rasplib_safe_place,safe_rasplib_name)) | ||
|
||
def restore_rasplib(): | ||
os.system("mv "+joinpath(real_rasplib_safe_place,safe_rasplib_name)+" "+rasplib_path) | ||
|
||
|
||
def run_broken_libs(): | ||
print("making the broken lib targets!") | ||
save_rasplib() | ||
all_libs = things_in_path(libspath) | ||
for l in all_libs: | ||
run_broken_lib(l) | ||
restore_rasplib() | ||
|
||
|
||
if __name__ == "__main__": | ||
run_inputs() | ||
run_broken_libs() |
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import os | ||
from make_tgts import fix_file_paths, curr_path_marker, joinpath, things_in_path, \ | ||
testpath, inpath, outpath, tgtpath, libtestspath, libspath, libtgtspath, liboutspath, \ | ||
save_rasplib, restore_rasplib | ||
|
||
|
||
def check_equal(f1,f2): | ||
res = os.system("diff "+f1+" "+f2) | ||
return res == 0 # 0 = diff found no differences | ||
|
||
|
||
for p in [outpath,liboutspath]: | ||
if not os.path.exists(p): | ||
os.makedirs(p) | ||
|
||
def run_input(name): | ||
os.system("python3 RASP_support/REPL.py <"+joinpath(inpath,name)+" >"+joinpath(outpath,name)) | ||
fix_file_paths(joinpath(outpath,name),curr_path_marker) | ||
return check_equal(joinpath(outpath,name),joinpath(tgtpath,name)) | ||
|
||
def run_inputs(): | ||
all_names = things_in_path(inpath) | ||
passed = True | ||
for n in all_names: | ||
success = run_input(n) | ||
print("input",n,"passed:",success) | ||
if not success: | ||
passed = False | ||
return passed | ||
|
||
def test_broken_lib(l): | ||
os.system("cp "+joinpath(libspath,l)+" RASP_support/rasplib.rasp") | ||
os.system("python3 RASP_support/REPL.py <"+joinpath(libtestspath,"empty.txt")+ " >"+joinpath(liboutspath,l)) | ||
return check_equal(joinpath(liboutspath,l),joinpath(libtgtspath,l)) | ||
|
||
def run_broken_libs(): | ||
save_rasplib() | ||
all_libs = things_in_path(libspath) | ||
passed = True | ||
for l in all_libs: | ||
success = test_broken_lib(l) | ||
print("lib",l,"passed (i.e., properly errored):",success) | ||
if not success: | ||
passed = False | ||
restore_rasplib() | ||
return passed | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
passed_inputs = run_inputs() | ||
print("passed all inputs:",passed_inputs) | ||
print("=====\n\n=====") | ||
passed_broken_intialisations = run_broken_libs() | ||
print("properly reports broken initialisations:",passed_broken_intialisations) | ||
print("=====\n\n=====") | ||
|
||
|
||
passed_everything = False not in [passed_inputs,passed_broken_intialisations] | ||
print("=====\npassed everything:",passed_everything) | ||
if passed_everything: | ||
exit(0) | ||
else: | ||
exit(1) |
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import os | ||
from make_tgts import fix_file_paths, curr_path_marker, joinpath, things_in_path, \ | ||
testpath, inpath, outpath, tgtpath, libtestspath, libspath, libtgtspath, liboutspath, \ | ||
save_rasplib, restore_rasplib | ||
|
||
|
||
def check_equal(f1,f2): | ||
res = os.system("diff "+f1+" "+f2) | ||
return res == 0 # 0 = diff found no differences | ||
|
||
|
||
for p in [outpath,liboutspath]: | ||
if not os.path.exists(p): | ||
os.makedirs(p) | ||
|
||
def run_input(name): | ||
os.system("python3 RASP_support/REPL.py <"+joinpath(inpath,name)+" >"+joinpath(outpath,name)) | ||
fix_file_paths(joinpath(outpath,name),curr_path_marker) | ||
return check_equal(joinpath(outpath,name),joinpath(tgtpath,name)) | ||
|
||
def run_inputs(): | ||
all_names = things_in_path(inpath) | ||
passed = True | ||
for n in all_names: | ||
success = run_input(n) | ||
print("input",n,"passed:",success) | ||
if not success: | ||
passed = False | ||
return passed | ||
|
||
def test_broken_lib(l): | ||
os.system("cp "+joinpath(libspath,l)+" RASP_support/rasplib.rasp") | ||
os.system("python3 RASP_support/REPL.py <"+joinpath(libtestspath,"empty.txt")+ " >"+joinpath(liboutspath,l)) | ||
return check_equal(joinpath(liboutspath,l),joinpath(libtgtspath,l)) | ||
|
||
def run_broken_libs(): | ||
save_rasplib() | ||
all_libs = things_in_path(libspath) | ||
passed = True | ||
for l in all_libs: | ||
success = test_broken_lib(l) | ||
print("lib",l,"passed (i.e., properly errored):",success) | ||
if not success: | ||
passed = False | ||
restore_rasplib() | ||
return passed | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
passed_inputs = run_inputs() | ||
print("passed all inputs:",passed_inputs) | ||
print("=====\n\n=====") | ||
passed_broken_intialisations = run_broken_libs() | ||
print("properly reports broken initialisations:",passed_broken_intialisations) | ||
print("=====\n\n=====") | ||
|
||
|
||
passed_everything = False not in [passed_inputs,passed_broken_intialisations] | ||
print("=====\npassed everything:",passed_everything) | ||
if passed_everything: | ||
exit(0) | ||
else: | ||
exit(1) |
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 |
---|---|---|
|
@@ -8,3 +8,4 @@ running example is: hello | |
>> .. .. value: e = 13 | ||
value: f = 5 | ||
>> | ||
|
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ running example is: hello | |
>> s-op: tokens | ||
Example: tokens("hello") = [h, e, l, l, o] (strings) | ||
>> .. .. .. | ||
|
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 |
---|---|---|
|
@@ -13,3 +13,4 @@ running example is: hello | |
l | 1 1 1 | ||
o | 1 1 1 1 | ||
>> | ||
|