mirror of
https://github.com/pesde-pkg/tooling.git
synced 2025-05-04 10:43:58 +01:00
tests: run before change manifest, with a new version parameter
This commit is contained in:
parent
eff55f9a6d
commit
e3c4215569
2 changed files with 18 additions and 14 deletions
|
@ -79,7 +79,7 @@ local BINS_SRC_DIR = pathfs.getAbsolutePathOf(pathfs.Path.from("bins"))
|
||||||
|
|
||||||
for _, binSrc in pathfs.readDir(BINS_SRC_DIR) do
|
for _, binSrc in pathfs.readDir(BINS_SRC_DIR) do
|
||||||
local absPath = BINS_SRC_DIR:join(binSrc)
|
local absPath = BINS_SRC_DIR:join(binSrc)
|
||||||
local testsPath = absPath:join("tests/init.spec.luau")
|
local testsPath = absPath:join("tests/run.luau")
|
||||||
local binEntrypoint = absPath:join("init.luau")
|
local binEntrypoint = absPath:join("init.luau")
|
||||||
local manifestPath = absPath:join("pesde.toml")
|
local manifestPath = absPath:join("pesde.toml")
|
||||||
local readmePath = absPath:join("README.md")
|
local readmePath = absPath:join("README.md")
|
||||||
|
@ -136,6 +136,21 @@ for _, binSrc in pathfs.readDir(BINS_SRC_DIR) do
|
||||||
)}{newVersion}{stdio.style("reset")}`
|
)}{newVersion}{stdio.style("reset")}`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
-- Check if the tool has any tests, and run them if they do
|
||||||
|
if pathfs.isFile(testsPath) then
|
||||||
|
local success, result = pcall(require, testsPath:toString())
|
||||||
|
if not success then
|
||||||
|
continue
|
||||||
|
end
|
||||||
|
|
||||||
|
success, result = pcall(result, newVersion)
|
||||||
|
if not success then
|
||||||
|
continue
|
||||||
|
end
|
||||||
|
else
|
||||||
|
warn(`Unit tests not found for {binSrc}, assuming that they pass`)
|
||||||
|
end
|
||||||
|
|
||||||
-- HACK: To prevent messing with our existing toml ordering and formatting
|
-- HACK: To prevent messing with our existing toml ordering and formatting
|
||||||
-- we just replace the old version field string with the new version field
|
-- we just replace the old version field string with the new version field
|
||||||
-- string
|
-- string
|
||||||
|
@ -171,18 +186,6 @@ for _, binSrc in pathfs.readDir(BINS_SRC_DIR) do
|
||||||
|
|
||||||
pathfs.writeFile(manifestPath, updatedManifest)
|
pathfs.writeFile(manifestPath, updatedManifest)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if the tool has any tests, and run them if they do
|
|
||||||
if pathfs.isFile(testsPath) then
|
|
||||||
local success, result = pcall(require, testsPath:toString())
|
|
||||||
if not success then
|
|
||||||
warn(`Rollbacking tool {binSrc} version due failed tests:`, result)
|
|
||||||
pathfs.writeFile(manifestPath, manifestContents)
|
|
||||||
continue
|
|
||||||
end
|
|
||||||
else
|
|
||||||
warn(`Unit tests not found for {binSrc}, assuming that they pass`)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Fetch README for the tool repo, if present
|
-- Fetch README for the tool repo, if present
|
||||||
|
|
|
@ -2,7 +2,7 @@ local toolchainlib = require("../lune_packages/core")
|
||||||
local process = require("@lune/process")
|
local process = require("@lune/process")
|
||||||
local fs = require("@lune/fs")
|
local fs = require("@lune/fs")
|
||||||
|
|
||||||
-- not working, needing support
|
return function(version)
|
||||||
-- process.args = { "bins/zap/tests/input.zap" }
|
-- process.args = { "bins/zap/tests/input.zap" }
|
||||||
local success, err = pcall(require, "bins/zap/init.luau")
|
local success, err = pcall(require, "bins/zap/init.luau")
|
||||||
|
|
||||||
|
@ -10,3 +10,4 @@ assert(success, `failed to execute zap: {err}`)
|
||||||
|
|
||||||
assert(fs.isFile("tests/output/client.luau"), `invalid output`)
|
assert(fs.isFile("tests/output/client.luau"), `invalid output`)
|
||||||
assert(fs.isFile("tests/output/server.luau"), `invalid output`)
|
assert(fs.isFile("tests/output/server.luau"), `invalid output`)
|
||||||
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue