-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Fix config utilisation for SQL compatibility
Signed-off-by: Lucas Bajolet <[email protected]>
- Loading branch information
Showing
2 changed files
with
109 additions
and
102 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 |
---|---|---|
|
@@ -13,52 +13,56 @@ var opts = new AppOptions.from_args(args) | |
var config = new AppConfig.from_options(opts) | ||
|
||
# clean bd | ||
config.db.drop | ||
#config.db.drop | ||
|
||
# Load nit | ||
config.load_track("tracks/nit") | ||
#config.load_track("tracks/nit") | ||
|
||
# Create a dummy user | ||
var player = new Player("John", "Doe") | ||
config.players.save player | ||
with ctx = new DBContext do | ||
# Create a dummy user | ||
var player = new Player(ctx, "nit_doe", "Nit Doe", "[email protected]", "avatar.cx") | ||
player.commit | ||
|
||
# Run some submission on the missions | ||
var mission = config.missions.find_all.first | ||
|
||
print "Mission {mission} {mission.testsuite.length}" | ||
var i = 0 | ||
for source in [ | ||
""" | ||
""", | ||
""" | ||
echo Hello, World! | ||
""", | ||
""" | ||
print "hello world" | ||
""", | ||
""" | ||
class Hello | ||
fun hi: String do return "Hello, World!" | ||
end | ||
print((new Hello).hi) | ||
""", | ||
""" | ||
print "Hello, World!" | ||
""" | ||
] do | ||
print "## Try source {i} ##" | ||
var prog = new Submission(player, mission, source) | ||
var runner = config.engine_map["nitc"] | ||
runner.run(prog, config) | ||
print "** {prog.status} errors={prog.test_errors}/{prog.results.length} size={prog.size_score or else "-"} time={prog.time_score or else "-"}" | ||
var msg = prog.compilation.message | ||
if msg != null then print "{msg}" | ||
for res in prog.results do | ||
var msg_test = res.error | ||
if msg_test != null then print "test {res.testcase.number}: {msg_test}" | ||
# Run some submission on the missions | ||
var mission = ctx.mission_by_slug("nit:hello_world") | ||
if mission == null then return | ||
|
||
print "Mission {mission} {mission.testsuite.length}" | ||
var i = 0 | ||
for source in [ | ||
""" | ||
""", | ||
""" | ||
echo Hello, World! | ||
""", | ||
""" | ||
print "hello world" | ||
""", | ||
""" | ||
class Hello | ||
fun hi: String do return "Hello, World!" | ||
end | ||
for e in prog.star_results do | ||
print e | ||
print((new Hello).hi) | ||
""", | ||
""" | ||
print "Hello, World!" | ||
""" | ||
] do | ||
print "## Try source {i} ##" | ||
var prog = new Submission(ctx, player.id, mission.id, source) | ||
var runner = config.engine_map["nitc"] | ||
runner.run(prog) | ||
print "** {prog.status} errors={prog.test_errors}/{prog.results.length} size={prog.size_score or else "-"} time={prog.time_score or else "-"}" | ||
var msg = prog.compilation.message | ||
if msg != null then print "{msg}" | ||
for res in prog.results do | ||
var msg_test = res.error | ||
if msg_test != null then print "test {res.testcase.number}: {msg_test}" | ||
end | ||
for e in prog.star_results do | ||
print e | ||
end | ||
i += 1 | ||
end | ||
i += 1 | ||
end |
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 |
---|---|---|
|
@@ -12,71 +12,74 @@ var opts = new AppOptions.from_args(args) | |
var config = new AppConfig.from_options(opts) | ||
|
||
# clean bd | ||
config.db.drop | ||
#config.db.drop | ||
|
||
# Load pep8 | ||
config.load_track("tracks/pep8") | ||
#config.load_track("tracks/pep8") | ||
|
||
# Create a dummy user | ||
var player = new Player("John", "Doe") | ||
config.players.save player | ||
with ctx = new DBContext do | ||
# Create a dummy user | ||
var player = new Player(ctx, "pep_doe", "Pep Doe", "[email protected]", "avatar.cx") | ||
player.commit | ||
|
||
# Run some submission on the missions | ||
var mission = config.missions.find_all.first | ||
do | ||
print "Mission {mission} {mission.testsuite.length}" | ||
var i = 0 | ||
for source in [ | ||
""" | ||
""", | ||
""" | ||
DECO 10,i | ||
.END | ||
""", | ||
""" | ||
DECI n,d | ||
LDA n,d | ||
ADDA 10,i | ||
STA n,d | ||
DECO n,d | ||
STOP | ||
n: .BLOCK 3 | ||
.END | ||
""", | ||
""" | ||
DECI n,d | ||
LDA n,d | ||
ADDA 10,i | ||
STA n,d | ||
DECO n,d | ||
STOP | ||
n: .BLOCK 2 | ||
.END | ||
""", | ||
""" | ||
DECI 0,d | ||
LDA 0,d | ||
ADDA 10,i | ||
STA 0,d | ||
DECO 0,d | ||
STOP | ||
.END | ||
""" | ||
] do | ||
print "## Try source {i} ##" | ||
var sub = new Submission(player, mission, source) | ||
var runner = config.engine_map["pep8term"] | ||
runner.run(sub, config) | ||
print "** {sub.status} errors={sub.test_errors}/{sub.results.length} size={sub.size_score or else "-"} time={sub.time_score or else "-"}" | ||
var msg = sub.compilation.message | ||
if msg != null then print "{msg}" | ||
for res in sub.results do | ||
var msg_test = res.error | ||
if msg_test != null then print "test {res.testcase.number}. {msg_test}" | ||
# Run some submission on the missions | ||
var mission = ctx.mission_by_slug("pep8:addition_simple") | ||
if mission == null then return | ||
do | ||
print "Mission {mission} {mission.testsuite.length}" | ||
var i = 0 | ||
for source in [ | ||
""" | ||
""", | ||
""" | ||
DECO 10,i | ||
.END | ||
""", | ||
""" | ||
DECI n,d | ||
LDA n,d | ||
ADDA 10,i | ||
STA n,d | ||
DECO n,d | ||
STOP | ||
n: .BLOCK 3 | ||
.END | ||
""", | ||
""" | ||
DECI n,d | ||
LDA n,d | ||
ADDA 10,i | ||
STA n,d | ||
DECO n,d | ||
STOP | ||
n: .BLOCK 2 | ||
.END | ||
""", | ||
""" | ||
DECI 0,d | ||
LDA 0,d | ||
ADDA 10,i | ||
STA 0,d | ||
DECO 0,d | ||
STOP | ||
.END | ||
""" | ||
] do | ||
print "## Try source {i} ##" | ||
var sub = new Submission(ctx, player.id, mission.id, source) | ||
var runner = config.engine_map["pep8term"] | ||
runner.run(sub) | ||
print "** {sub.status} errors={sub.test_errors}/{sub.results.length} size={sub.size_score or else "-"} time={sub.time_score or else "-"}" | ||
var msg = sub.compilation.message | ||
if msg != null then print "{msg}" | ||
for res in sub.results do | ||
var msg_test = res.error | ||
if msg_test != null then print "test {res.testcase.number}. {msg_test}" | ||
end | ||
for e in sub.star_results do | ||
print e | ||
end | ||
i += 1 | ||
end | ||
for e in sub.star_results do | ||
print e | ||
end | ||
i += 1 | ||
end | ||
end |