-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial * Update README.md restored * Update run-tests-in-docker.sh restore * Update run-tests.sh remove debug line * t -> test_case
- Loading branch information
Showing
20 changed files
with
272 additions
and
34 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 |
---|---|---|
@@ -1 +1,7 @@ | ||
/tests/**/*/results.json | ||
/tests/all-fail/backup | ||
/tests/empty-file/backup | ||
/tests/partial-fail/backup | ||
/tests/success/backup | ||
/tests/syntax-error/backup | ||
/bin/backup |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
requires("1.0.5") -- (assert(a&b&c) bug, -nopause) | ||
without trace | ||
include builtins/json.e | ||
|
||
procedure process() | ||
sequence cl = command_line() | ||
integer cll = length(cl) | ||
if cll<4 then | ||
puts(1, "usage: p ./bin/run.exw slug input_dir output_dir\n") | ||
return | ||
end if | ||
string exercise_folder = cl[4], -- eg exercism/phix/exercises/practice/acronym | ||
slug = split_path(exercise_folder)[$], -- eg acronym | ||
sol_dir = get_proper_path(exercise_folder), | ||
out_dir = get_proper_path(cl[5]), | ||
test_src = join_path({sol_dir, "test.exw"}), | ||
res_file = join_path({out_dir, "results.json"}) | ||
|
||
if not file_exists(sol_dir) then | ||
crash("%s does not exist",{sol_dir}) | ||
end if | ||
if not file_exists(out_dir) then | ||
assert(create_directory(out_dir),"cannot create directory "&out_dir) | ||
end if | ||
|
||
-- printf(1, "%s: testing...\n", {slug}) | ||
|
||
assert(chdir(sol_dir),"cannot chdir to %s",{sol_dir}) | ||
string cmd = sprintf(`p -nopause %s > "%s" 2>&1`, {test_src, res_file}) | ||
--?cmd | ||
|
||
integer res = system_exec(cmd,4) -- (4 === result/wait and redirect/builtin) | ||
--?res | ||
|
||
sequence lines = get_text(res_file,GT_LF_STRIPPED) | ||
--?lines | ||
|
||
string status = "pass", message = "" | ||
|
||
--printf(1,"DATA:\n%s\n",{join(lines,"<\n")}) | ||
integer begins_hat = 0, begins_3 = 0, crashmsg = false | ||
for i,l in lines do | ||
if begins_hat=0 | ||
and begins("^",trim_head(l)) then | ||
begins_hat = i | ||
elsif begins("... called from ",l) | ||
or begins("...included by ",l) | ||
or begins("Global & Local Variables",l) then | ||
begins_3 = i-1 | ||
exit | ||
elsif match("passed: ",l) then | ||
lines[i] = "" | ||
elsif i=5 and begins("--> see ",l) then | ||
crashmsg = true | ||
exit | ||
end if | ||
end for | ||
if crashmsg then | ||
status = "error" | ||
message = lines[3] | ||
elsif begins_3 | ||
or begins_hat then | ||
-- compilation error | ||
status = "error" | ||
if begins_3=0 then begins_3 = begins_hat end if | ||
-- We might want to limit this to, say, 8 lines? | ||
message = join(filter(lines[2..begins_3],"!=",""),'\n') | ||
else | ||
-- check for unit test errors or success | ||
integer first_failure = 0 | ||
lines = filter(lines,"!=","") | ||
for i,l in lines do | ||
if match("100% success", l) then exit end if // all good | ||
if match("% success", l) then // < 100% then... | ||
status = "fail" | ||
if first_failure==0 then first_failure = i end if | ||
message = trim(lines[first_failure]) | ||
exit | ||
end if | ||
if first_failure==0 and match("failed:", l) then | ||
first_failure = i | ||
end if | ||
end for | ||
end if | ||
// if status is still "pass" then res //must// be 0, shirley: | ||
assert(status!="pass" or res==0,"pass with res=%d??",{res}) | ||
|
||
sequence json = {JSON_OBJECT, {"version", 1}, {"status", status}, {"message", message}} | ||
integer ofn = open(res_file,"w") | ||
object pjres = print_json(ofn, json) -- (separate line so available for debugging) | ||
assert(pjres!=0,"bad json??") | ||
close(ofn) | ||
--temp: | ||
--{} = print_json(1,json) | ||
--?{res,status} | ||
-- if res!=0 then crash(status) end if | ||
|
||
end procedure | ||
|
||
process() | ||
|
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,5 +1,5 @@ | ||
{ | ||
"version": 1, | ||
"status": "fail", | ||
"message": "TODO: replace with correct output" | ||
"version":1, | ||
"status":"fail", | ||
"message":"failed: year not divisible by 4 in common year: 1 should equal 0" | ||
} |
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,7 @@ | ||
local function good_leap(integer year) | ||
return rmdr(year,4)=0 and (rmdr(year,100)!=0 or rmdr(year,400)=0) | ||
end function | ||
|
||
global function leap(integer year) | ||
return not good_leap(year) | ||
end function |
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,22 @@ | ||
include leap.e | ||
|
||
--<do not edit> | ||
constant canonical_data = { | ||
{2015,false,"year not divisible by 4 in common year"}, | ||
{1970,false,"year divisible by 2, not divisible by 4 in common year"}, | ||
{1996,true,"year divisible by 4, not divisible by 100 in leap year"}, | ||
{1960,true,"year divisible by 4 and 5 is still a leap year"}, | ||
{2100,false,"year divisible by 100, not divisible by 400 in common year"}, | ||
{1900,false,"year divisible by 100 but not by 3 is still not a leap year"}, | ||
{2000,true,"year divisible by 400 is leap year"}, | ||
{2400,true,"year divisible by 400 but not by 125 is still a leap year"}, | ||
{1800,false,"year divisible by 200, not divisible by 400 in common year"}, | ||
} | ||
--</do not edit> | ||
|
||
set_test_verbosity(TEST_SHOW_ALL) | ||
for test_case in canonical_data do | ||
{integer year, bool expected, string desc} = test_case | ||
test_equal(leap(year),expected,desc) | ||
end for | ||
test_summary() |
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,5 +1,7 @@ | ||
{ | ||
"version": 1, | ||
"status": "fail", | ||
"message": "TODO: replace with correct output" | ||
"status": "error", | ||
"message": "/opt/test-runner/tests/empty-file/test.exw:20 | ||
test_equal(leap(year),expected,desc) | ||
^ undefined identifier leap" | ||
} |
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 @@ | ||
|
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,22 @@ | ||
include leap.e | ||
|
||
--<do not edit> | ||
constant canonical_data = { | ||
{2015,false,"year not divisible by 4 in common year"}, | ||
{1970,false,"year divisible by 2, not divisible by 4 in common year"}, | ||
{1996,true,"year divisible by 4, not divisible by 100 in leap year"}, | ||
{1960,true,"year divisible by 4 and 5 is still a leap year"}, | ||
{2100,false,"year divisible by 100, not divisible by 400 in common year"}, | ||
{1900,false,"year divisible by 100 but not by 3 is still not a leap year"}, | ||
{2000,true,"year divisible by 400 is leap year"}, | ||
{2400,true,"year divisible by 400 but not by 125 is still a leap year"}, | ||
{1800,false,"year divisible by 200, not divisible by 400 in common year"}, | ||
} | ||
--</do not edit> | ||
|
||
set_test_verbosity(TEST_SHOW_ALL) | ||
for test_case in canonical_data do | ||
{integer year, bool expected, string desc} = test_case | ||
test_equal(leap(year),expected,desc) | ||
end for | ||
test_summary() |
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,5 +1,5 @@ | ||
{ | ||
"version": 1, | ||
"status": "fail", | ||
"message": "TODO: replace with correct output" | ||
"message": "failed: year divisible by 100, not divisible by 400 in common year: 1 should equal 0" | ||
} |
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,4 @@ | ||
global function leap(integer year) | ||
return rmdr(year,4)=0 -- and (rmdr(year,100)!=0 or rmdr(year,400)=0) | ||
end function | ||
|
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,22 @@ | ||
include leap.e | ||
|
||
--<do not edit> | ||
constant canonical_data = { | ||
{2015,false,"year not divisible by 4 in common year"}, | ||
{1970,false,"year divisible by 2, not divisible by 4 in common year"}, | ||
{1996,true,"year divisible by 4, not divisible by 100 in leap year"}, | ||
{1960,true,"year divisible by 4 and 5 is still a leap year"}, | ||
{2100,false,"year divisible by 100, not divisible by 400 in common year"}, | ||
{1900,false,"year divisible by 100 but not by 3 is still not a leap year"}, | ||
{2000,true,"year divisible by 400 is leap year"}, | ||
{2400,true,"year divisible by 400 but not by 125 is still a leap year"}, | ||
{1800,false,"year divisible by 200, not divisible by 400 in common year"}, | ||
} | ||
--</do not edit> | ||
|
||
set_test_verbosity(TEST_SHOW_ALL) | ||
for test_case in canonical_data do | ||
{integer year, bool expected, string desc} = test_case | ||
test_equal(leap(year),expected,desc) | ||
end for | ||
test_summary() |
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,4 +1,5 @@ | ||
{ | ||
"version": 1, | ||
"status": "pass" | ||
"status": "pass", | ||
"message": "" | ||
} |
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,4 @@ | ||
global function leap(integer year) | ||
return rmdr(year,4)=0 and (rmdr(year,100)!=0 or rmdr(year,400)=0) | ||
end function | ||
|
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,22 @@ | ||
include leap.e | ||
|
||
--<do not edit> | ||
constant canonical_data = { | ||
{2015,false,"year not divisible by 4 in common year"}, | ||
{1970,false,"year divisible by 2, not divisible by 4 in common year"}, | ||
{1996,true,"year divisible by 4, not divisible by 100 in leap year"}, | ||
{1960,true,"year divisible by 4 and 5 is still a leap year"}, | ||
{2100,false,"year divisible by 100, not divisible by 400 in common year"}, | ||
{1900,false,"year divisible by 100 but not by 3 is still not a leap year"}, | ||
{2000,true,"year divisible by 400 is leap year"}, | ||
{2400,true,"year divisible by 400 but not by 125 is still a leap year"}, | ||
{1800,false,"year divisible by 200, not divisible by 400 in common year"}, | ||
} | ||
--</do not edit> | ||
|
||
set_test_verbosity(TEST_SHOW_ALL) | ||
for test_case in canonical_data do | ||
{integer year, bool expected, string desc} = test_case | ||
test_equal(leap(year),expected,desc) | ||
end for | ||
test_summary() |
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,5 +1,7 @@ | ||
{ | ||
"version": 1, | ||
"status": "error", | ||
"message": "TODO: replace with correct output" | ||
"message": "/opt/test-runner/tests/syntax-error/leap.e:1 | ||
global function leap[integer year] | ||
^ '(' expected" | ||
} |
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,4 @@ | ||
global function leap[integer year] | ||
return rmdr(year,4)=0 and (rmdr(year,100)!=0 or rmdr(year,400)=0) | ||
end function | ||
|
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,22 @@ | ||
include leap.e | ||
|
||
--<do not edit> | ||
constant canonical_data = { | ||
{2015,false,"year not divisible by 4 in common year"}, | ||
{1970,false,"year divisible by 2, not divisible by 4 in common year"}, | ||
{1996,true,"year divisible by 4, not divisible by 100 in leap year"}, | ||
{1960,true,"year divisible by 4 and 5 is still a leap year"}, | ||
{2100,false,"year divisible by 100, not divisible by 400 in common year"}, | ||
{1900,false,"year divisible by 100 but not by 3 is still not a leap year"}, | ||
{2000,true,"year divisible by 400 is leap year"}, | ||
{2400,true,"year divisible by 400 but not by 125 is still a leap year"}, | ||
{1800,false,"year divisible by 200, not divisible by 400 in common year"}, | ||
} | ||
--</do not edit> | ||
|
||
set_test_verbosity(TEST_SHOW_ALL) | ||
for test_case in canonical_data do | ||
{integer year, bool expected, string desc} = test_case | ||
test_equal(leap(year),expected,desc) | ||
end for | ||
test_summary() |