mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-16 21:31:58 +01:00
* Run /ship test lanes on test files under hidden folders like .github (GST-2640)
Bun reads a bare relative path as a name filter that skips hidden folders, so the pregate lane ran nothing for .github/scripts tests and failed. Pass every relative test path to bun test as ./<path>.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* Add ./ to test paths for bun runners that pass flags before test, and cover the remaining callers
The lanes check now also anchors paths when the runner is written as bun --no-env-file test {files}, the form gstack's own docs show. New tests cover the base-red select, the CI carry per-file command and the remote-gate command a small machine records.
Review-Finding: p1/red-team#1 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
---------
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
16 lines
1.1 KiB
TypeScript
16 lines
1.1 KiB
TypeScript
/**
|
|
* Test file arguments for `bun test`. Bun reads a bare relative path as a name filter, and that filter's search skips
|
|
* hidden folders, so `bun test .github/scripts/x.test.mjs` finds nothing and exits 1 (GST-2640, Bun 1.4.4). A path that
|
|
* starts with `./`, `../` or `/` is read as a path. Bun still drops a missing path from a run of several files without
|
|
* an error, so a caller rejects a missing file before Bun runs.
|
|
*/
|
|
|
|
/** A command that runs `bun test` as a whole command word, with or without Bun's own flags before `test`. */
|
|
export const BUN_TEST = /(?:^|[\s;&|(])bun(?:\s+--?[\w-]+(?:=\S+)?)*\s+test\b/;
|
|
|
|
/** `file` as a path Bun reads as a path: `./` added unless it already starts with `./`, `../` or `/`. */
|
|
export const explicitPath = (file: string): string => (/^\.{0,2}\//.test(file) ? file : `./${file}`);
|
|
|
|
/** The file arguments for `command`: explicit paths when it runs `bun test`, the files unchanged for any other runner. */
|
|
export const testFileArgs = (command: string, files: readonly string[]): string[] => (BUN_TEST.test(command) ? files.map(explicitPath) : [...files]);
|