mirror of
https://github.com/0x5eal/wg-lua.git
synced 2024-12-12 04:40:36 +00:00
chore(tests): include test runner powered by lune
This commit is contained in:
parent
e50a64797a
commit
46b7949422
3 changed files with 58 additions and 2 deletions
57
.lune/tests.lua
Normal file
57
.lune/tests.lua
Normal file
|
@ -0,0 +1,57 @@
|
|||
local process = require("@lune/process")
|
||||
local fs = require("@lune/fs")
|
||||
local stdio = require("@lune/stdio")
|
||||
|
||||
local OK = stdio.color("green")
|
||||
.. stdio.style("bold")
|
||||
.. " OK"
|
||||
.. stdio.style("reset")
|
||||
.. stdio.color("reset")
|
||||
.. "\n"
|
||||
.. ""
|
||||
local FAILED = stdio.color("red")
|
||||
.. stdio.style("bold")
|
||||
.. " FAILED"
|
||||
.. stdio.style("reset")
|
||||
.. stdio.color("reset")
|
||||
.. "\n"
|
||||
|
||||
-- Adapted from https://github.com/4x8Matrix/Package-Index/blob/Master/.lune/type-check.luau#L10
|
||||
local function execute(exe, ...): (boolean, string, string)
|
||||
local res = process.spawn(exe, { ... }, {
|
||||
stdio = "default",
|
||||
})
|
||||
|
||||
return res.ok, res.stdout, res.stderr
|
||||
end
|
||||
|
||||
function main()
|
||||
local results = {
|
||||
passed = 0,
|
||||
failed = 0,
|
||||
}
|
||||
|
||||
for _, test in fs.readDir("tests/") do
|
||||
stdio.write(`Running wg::{test:gsub(".luau", "")}...`)
|
||||
|
||||
local ok, _out, err = execute("lune", "run", "tests/" .. test)
|
||||
|
||||
if ok then
|
||||
stdio.write(OK)
|
||||
results.passed += 1
|
||||
else
|
||||
stdio.write(FAILED)
|
||||
print(err:split("\n")[1])
|
||||
|
||||
results.failed += 1
|
||||
end
|
||||
end
|
||||
|
||||
print(`\nResults: passed: {results.passed}; failed: {results.failed}`)
|
||||
|
||||
if results.failed > 0 then
|
||||
process.exit(1)
|
||||
end
|
||||
end
|
||||
|
||||
return main()
|
|
@ -10,6 +10,7 @@
|
|||
"check_fmt": "prettier -c src/",
|
||||
"check": "pnpm lint && pnpm check_fmt",
|
||||
"fmt": "prettier -w src/",
|
||||
"test": "lune run tests",
|
||||
"postinstall": "patch -f node_modules/@rbxts/types/include/roblox.d.ts < lune_require_patch.diff",
|
||||
"prepublishOnly": "pnpm run build"
|
||||
},
|
||||
|
|
|
@ -19,8 +19,6 @@ export const wireguard: Wireguard = {
|
|||
const privateKey = generatePrivateKey();
|
||||
const publicKey = generatePublicKey(privateKey);
|
||||
|
||||
print(privateKey);
|
||||
|
||||
return {
|
||||
publicKey: atob(publicKey),
|
||||
privateKey: atob(privateKey),
|
||||
|
|
Loading…
Reference in a new issue