-
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.
Add testing suite using frktest and lune
- Loading branch information
1 parent
882147c
commit 83b29ab
Showing
10 changed files
with
182 additions
and
3 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,3 +1,6 @@ | ||
[submodule "luau"] | ||
path = luau | ||
url = https://github.com/luau-lang/luau.git | ||
[submodule "src/tests/frktest"] | ||
path = src/tests/frktest | ||
url = https://github.com/itsfrank/frktest.git |
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,7 @@ | ||
# This file lists tools managed by Aftman, a cross-platform toolchain manager. | ||
# For more information, see https://github.com/LPGhatguy/aftman | ||
|
||
# To add a new tool, add an entry to this table. | ||
[tools] | ||
lune = "lune-org/[email protected]" | ||
# rojo = "rojo-rbx/[email protected]" |
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,10 @@ | ||
{ | ||
"languageMode": "strict", | ||
"lint": { | ||
"LocalShadow": false, | ||
"LocalUnused": false | ||
}, | ||
"aliases": { | ||
"frktest": "./frktest/src" | ||
} | ||
} |
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,15 @@ | ||
local frktest = require("@frktest/frktest") | ||
local lune_console_reporter = require("@frktest/reporters/lune_console_reporter") | ||
local fs = require("@lune/fs") | ||
local process = require("@lune/process") | ||
|
||
for _, name in fs.readDir("./suites") do | ||
local ok = require(`./suites/{name}`) :: any | ||
assert(ok, `could not load suite {name}`) | ||
end | ||
|
||
lune_console_reporter.init() | ||
local testOk = frktest.run() | ||
if (not testOk) then | ||
process.exit(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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
local frktest = require("@frktest/frktest") | ||
local test = frktest.test | ||
local check = frktest.assert.check | ||
local req = frktest.assert.require | ||
local msg = frktest.assert.msg | ||
|
||
test.suite("Compiler", function() | ||
local Compiler = require("../../../build/Luau.LuauCeption.Compiler") | ||
for opt = 1, 3 do | ||
for dbg = 1, 3 do | ||
for cov = 1, 3 do | ||
test.case(`should be able to compile valid Luau code without erroring with opt {opt} dbg {dbg} cov {cov}`, function() | ||
check.should_not_error(function() | ||
Compiler.luau_compile(`print("Hello world!")\nprint({opt},{dbg},{cov})`, opt, dbg, cov) | ||
return | ||
end) | ||
end) | ||
|
||
test.case(`shouldn't be able to compile invalid Luau code without erroring with opt {opt} dbg {dbg} cov {cov}`, function() | ||
check.should_not_error(function() | ||
Compiler.luau_compile(`whar`, opt, dbg, cov) | ||
return | ||
end) | ||
end) | ||
|
||
test.case("first byte for invalid code from compiler should be null (0) with opt {opt} dbg {dbg} cov {cov}", function() | ||
local bc, bcs = Compiler.luau_compile(`whar`, opt, dbg, cov) | ||
msg(`bc: "{bc}", bcs: {bcs}, first byte: {string.byte(string.sub(bc, 1, 1))}`) | ||
check.equal(string.byte(string.sub(bc, 1, 1)), 0) | ||
end) | ||
end | ||
end | ||
end | ||
end) | ||
|
||
return true |
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,52 @@ | ||
local frktest = require("@frktest/frktest") | ||
local test = frktest.test | ||
local check = frktest.assert.check | ||
local req = frktest.assert.require | ||
local msg = frktest.assert.msg | ||
|
||
test.suite("Compiler", function() | ||
local Full = require("../../../build/Luau.LuauCeption.Full") | ||
for opt = 1, 3 do | ||
for dbg = 1, 3 do | ||
for cov = 1, 3 do | ||
test.case(`should be able to compile valid Luau code without erroring with opt {opt} dbg {dbg} cov {cov}`, function() | ||
check.should_not_error(function() | ||
Full.luau_compile(`print("Hello world!")\nprint({opt},{dbg},{cov})`, opt, dbg, cov) | ||
return | ||
end) | ||
end) | ||
|
||
test.case(`shouldn't be able to compile invalid Luau code without erroring with opt {opt} dbg {dbg} cov {cov}`, function() | ||
check.should_not_error(function() | ||
Full.luau_compile(`whar`, opt, dbg, cov) | ||
return | ||
end) | ||
end) | ||
|
||
test.case("first byte for invalid code from compiler should be null (0) with opt {opt} dbg {dbg} cov {cov}", function() | ||
local bc, bcs = Full.luau_compile(`whar`, opt, dbg, cov) | ||
msg(`bc: "{bc}", bcs: {bcs}, first byte: {string.byte(string.sub(bc, 1, 1))}`) | ||
check.equal(string.byte(string.sub(bc, 1, 1)), 0) | ||
end) | ||
|
||
test.case(`should be able to run valid Luau code without erroring with opt {opt} dbg {dbg} cov {cov}`, function() | ||
local bc, bcs = Full.luau_compile(`print("Hello world!")\nprint({opt},{dbg},{cov})`, opt, dbg, cov) | ||
|
||
msg(`no safe env, bcs: {bcs}`) | ||
check.should_not_error(function() | ||
Full.luau_run(bc, `LuauCeptionTest_VM_NSF_{opt},{dbg},{cov}`, false) | ||
return | ||
end) | ||
|
||
msg(`safe env, bcs: {bcs}`) | ||
check.should_not_error(function() | ||
Full.luau_run(bc, `LuauCeptionTest_VM_WSF_{opt},{dbg},{cov}`, true) | ||
return | ||
end) | ||
end) | ||
end | ||
end | ||
end | ||
end) | ||
|
||
return true |
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,33 @@ | ||
local frktest = require("@frktest/frktest") | ||
local test = frktest.test | ||
local check = frktest.assert.check | ||
local req = frktest.assert.require | ||
local msg = frktest.assert.msg | ||
|
||
test.suite("Compiler", function() | ||
local Compiler = require("../../../build/Luau.LuauCeption.Compiler") | ||
local VM = require("../../../build/Luau.LuauCeption.VM") | ||
for opt = 1, 3 do | ||
for dbg = 1, 3 do | ||
for cov = 1, 3 do | ||
test.case(`should be able to run valid Luau code without erroring with opt {opt} dbg {dbg} cov {cov}`, function() | ||
local bc, bcs = Compiler.luau_compile(`print("Hello world!")\nprint({opt},{dbg},{cov})`, opt, dbg, cov) | ||
|
||
msg(`no safe env, bcs: {bcs}`) | ||
check.should_not_error(function() | ||
VM.luau_run(bc, `LuauCeptionTest_VM_NSF_{opt},{dbg},{cov}`, false) | ||
return | ||
end) | ||
|
||
msg(`safe env, bcs: {bcs}`) | ||
check.should_not_error(function() | ||
VM.luau_run(bc, `LuauCeptionTest_VM_WSF_{opt},{dbg},{cov}`, true) | ||
return | ||
end) | ||
end) | ||
end | ||
end | ||
end | ||
end) | ||
|
||
return true |