Compare commits

...

24 Commits

Author SHA1 Message Date
Meghan Denny
01e3212950 per the last commit undo the bun-install-registry.test.ts change 2024-10-30 18:05:11 -07:00
Meghan Denny
b3ca036903 only exit 0 when --all is used 2024-10-30 16:56:19 -07:00
Meghan Denny
7d3b23743f fix 2024-10-29 20:31:59 -07:00
Meghan Denny
801f46b2c5 mark these 3 failings as todo 2024-10-29 20:17:33 -07:00
Meghan Denny
8a028b0eab add .only() to TestBuilder for dev 2024-10-29 20:17:24 -07:00
Meghan Denny
368a2bcb5f Merge branch 'main' into nektro-patch-4612 2024-10-29 18:05:52 -07:00
Meghan Denny
c5dac668c0 Merge branch 'main' into nektro-patch-4612 2024-10-21 17:33:26 -07:00
Meghan Denny
a2a7716c26 Merge branch 'main' into nektro-patch-4612 2024-10-15 16:37:34 -07:00
Meghan Denny
07cd629586 skip node-oauth on windows 2024-10-11 04:06:42 -07:00
Meghan Denny
c19e840a8b skip broccoli-merge-trees on windows 2024-10-11 04:05:39 -07:00
Meghan Denny
dc9c8a4d8f add more passing packages to the corpus 2024-10-11 03:35:22 -07:00
Meghan Denny
b39e00748a remove .git from clone urls 2024-10-11 03:11:42 -07:00
Meghan Denny
202ebea628 always try to run a file if script name starts with ./ 2024-10-11 03:11:07 -07:00
Meghan Denny
c805b7fbcb fix typo 2024-10-11 03:10:17 -07:00
Meghan Denny
6b62afa201 accidentally committed skipping the regular tests 2024-10-10 03:14:56 -07:00
Meghan Denny
8ae0d1a734 also fail if there's an Error 2024-10-10 02:49:52 -07:00
Meghan Denny
62cb95111a make timeout a bit shorter 2024-10-10 02:48:35 -07:00
Meghan Denny
e82f9a09b4 skip binary-split on windows 2024-10-09 22:04:26 -07:00
Meghan Denny
a4e7fd98e4 this empty log was extra 2024-10-09 22:03:52 -07:00
Meghan Denny
dc2f1addf0 windows doesnt like running js with shebangs 2024-10-09 21:36:19 -07:00
Meghan Denny
f1ed5a5732 dont actually need Array.fromAsync here 2024-10-09 21:05:51 -07:00
Meghan Denny
177c96491b only run citgm tests once 2024-10-09 20:32:36 -07:00
Meghan Denny
5a97a8e53b fixes 2024-10-09 19:51:09 -07:00
Meghan Denny
b040b454ac ci: start running some of the citgm projects [v2] 2024-10-09 19:21:34 -07:00
6 changed files with 261 additions and 10 deletions

45
scripts/citgm-items.mjs Normal file
View File

@@ -0,0 +1,45 @@
export default [
// index key:
// mode, clone_url, skipWindows
// 0
[0, "https://github.com/maxogden/binary-split.git", 1], //binary-split
[0, "https://github.com/mafintosh/blake2b-wasm"], //blake2b-wasm
[0, "https://github.com/mafintosh/flush-write-stream"], //flush-write-stream
[0, "https://github.com/hughsk/from2"], //from2
[0, "https://github.com/unicode-org/full-icu-test"], //full-icu-test
// 5
[0, "https://github.com/mafintosh/pumpify"], //pumpify
[0, "https://github.com/ForbesLindesay/thread-sleep"], //thread-sleep
[0, "https://github.com/juliangruber/isarray"], //isarray
[0, "https://github.com/justmoon/node-extend"],
[0, "https://github.com/Raynos/xtend"],
// 10
[0, "https://github.com/dominictarr/through"],
[0, "https://github.com/chrisdickinson/raf"],
[0, "https://github.com/standard/eslint-plugin-standard"],
[0, "https://github.com/cryptocoinjs/bs58"],
[0, "https://github.com/broccolijs/broccoli-merge-trees", 1],
// 15
[0, "https://github.com/hughsk/vinyl-source-stream"],
[0, "https://github.com/mariocasciaro/object-path"],
[0, "https://github.com/babel/eslint-plugin-babel"],
[0, "https://github.com/ciaranj/node-oauth", 1],
[0, "https://github.com/mathiasbynens/he"],
// 20
[0, "https://github.com/hughsk/vinyl-buffer"],
[0, "https://github.com/mathiasbynens/base64"],
[0, "https://github.com/dreamerslab/node.extend"],
[0, "https://github.com/mathiasbynens/utf8.js"],
[0, "https://github.com/jxson/front-matter"],
// 25
[0, "https://github.com/jonschlinkert/extend-shallow"],
[0, "https://github.com/enricomarino/is"],
[0, "https://github.com/stevemao/left-pad"],
[0, "https://github.com/hughsk/envify"],
[0, "https://github.com/ljharb/object.assign"],
// 30
[0, "https://github.com/jonschlinkert/word-wrap"],
[0, "https://github.com/goto100/xpath"],
// [0, "https://github.com/moment/moment-timezone"],//popular and passing but suite takes >8m to complete
];

11
scripts/pkgname-to-github.ts Executable file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bun
let result = await fetch(`https://registry.npmjs.org/${Bun.argv[2]}`);
result = await result.json();
result = result.repository.url;
result = result.replace("git:", "https:");
result = result.replace("git+", "");
result = result.replace("ssh://git@", "https://");
console.log(result);
export {};

126
scripts/run-citgm-test.ts Executable file
View File

@@ -0,0 +1,126 @@
#!/usr/bin/env bun
import fs from "node:fs";
import path from "node:path";
import os from "node:os";
import { spawnSync } from "node:child_process";
function tmpdirSync(pattern = "bun.citgm.") {
return fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), pattern));
}
const exec_path = Bun.argv[2];
console.log("exec path:", exec_path);
console.log("---");
const clone_url = Bun.argv[3];
const clone_dir = tmpdirSync();
const test_script = Bun.argv[4] ?? "test";
{
console.log();
const cmd = "git";
const args = ["clone", clone_url, clone_dir];
console.log("", [cmd, ...args]);
const result = spawnSync(cmd, args, { stdio: ["ignore", "inherit", "inherit"] });
if (result.signal) {
console.log("-", "command exited with abnormal signal:", result.signal);
process.exit(1);
}
if (result.status) {
console.log("-", "command exited with non-zero status:", result.status);
process.exit(1);
}
console.log("---");
}
{
console.log();
const cmd = exec_path;
const args = ["--revision"];
console.log("", [cmd, ...args]);
const result = spawnSync(cmd, args, { stdio: ["ignore", "inherit", "inherit"] });
if (result.signal) {
console.log("-", "command exited with abnormal signal:", result.signal);
process.exit(1);
}
if (result.status) {
console.log("-", "command exited with non-zero status:", result.status);
process.exit(1);
}
console.log("---");
}
{
console.log(`${clone_dir}/package.json`);
console.log();
const cmd = exec_path;
const args = ["install"];
console.log("", [cmd, ...args]);
const result = spawnSync(cmd, args, { stdio: ["ignore", "inherit", "inherit"], cwd: clone_dir });
if (result.signal) {
console.log("-", "command exited with abnormal signal:", result.signal);
process.exit(1);
}
if (result.status) {
console.log("-", "command exited with non-zero status:", result.status);
process.exit(1);
}
if (result.error) {
process.exit(1);
}
console.log("---");
}
const package_json = require(`${clone_dir}/package.json`);
const deps = Object.keys(package_json.dependencies ?? {});
const devDeps = Object.keys(package_json.devDependencies ?? {});
if (deps.length || devDeps.length) {
console.log(`${clone_dir}/package.json`);
console.log();
const cmd = exec_path;
const args = ["pm", "trust", "--all"];
console.log("", [cmd, ...args]);
const result = spawnSync(cmd, args, { stdio: ["ignore", "inherit", "inherit"], cwd: clone_dir });
if (result.signal) {
console.log("-", "command exited with abnormal signal:", result.signal);
process.exit(1);
}
if (result.status) {
console.log("-", "command exited with non-zero status:", result.status);
process.exit(1);
}
if (result.error) {
process.exit(1);
}
console.log("---");
}
{
console.log(`${clone_dir}/package.json`);
console.log();
const cmd = exec_path;
const args = ["--bun", "run", test_script];
console.log("", [cmd, ...args]);
const result = spawnSync(cmd, args, { stdio: ["ignore", "inherit", "inherit"], cwd: clone_dir });
if (result.signal) {
console.log("-", "command exited with abnormal signal:", result.signal);
process.exit(1);
}
if (result.status) {
console.log("-", "command exited with non-zero status:", result.status);
process.exit(1);
}
if (result.error) {
process.exit(1);
}
console.log("---");
}
fs.rmSync(clone_dir, { recursive: true, force: true });

View File

@@ -21,7 +21,7 @@ import {
} from "node:fs";
import { spawn, spawnSync } from "node:child_process";
import { tmpdir, hostname, userInfo, homedir } from "node:os";
import { join, basename, dirname, relative, sep } from "node:path";
import { join, basename, dirname, relative, sep, resolve } from "node:path";
import { normalize as normalizeWindows } from "node:path/win32";
import { isIP } from "node:net";
import { parseArgs } from "node:util";
@@ -168,7 +168,7 @@ async function runTests() {
const revision = getRevision(execPath);
console.log("Revision:", revision);
const tests = getRelevantTests(testsPath);
const tests = await getRelevantTests(testsPath);
console.log("Running tests:", tests.length);
let i = 0;
@@ -221,6 +221,11 @@ async function runTests() {
if (results.every(({ ok }) => ok)) {
for (const testPath of tests) {
if (testPath.startsWith("https://")) {
// ecosystem tests
await runTest(testPath, async () => spawnCitgmTest(execPath, testPath));
continue;
}
const title = relative(cwd, join(testsPath, testPath)).replace(/\\/g, "/");
await runTest(title, async () => spawnBunTest(execPath, join("test", testPath)));
}
@@ -563,6 +568,52 @@ async function spawnBunTest(execPath, testPath) {
};
}
/**
* @param {string} execPath
* @param {string} testPath
* @returns {Promise<TestResult>}
*/
async function spawnCitgmTest(execPath, testPath) {
const timeout = testTimeout;
const tmpdirPath = mkdtempSync(join(tmpPath, "buntmp-"));
const bunEnv = {
...process.env,
GITHUB_ACTIONS: "true", // always true so annotations are parsed
FORCE_COLOR: "1",
BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING: "1",
BUN_DEBUG_QUIET_LOGS: "1",
BUN_GARBAGE_COLLECTOR_LEVEL: "1",
BUN_JSC_randomIntegrityAuditRate: "1.0",
BUN_ENABLE_CRASH_REPORTING: "0", // change this to '1' if https://github.com/oven-sh/bun/issues/13012 is implemented
BUN_RUNTIME_TRANSPILER_CACHE_PATH: "0",
BUN_INSTALL_CACHE_DIR: tmpdirPath,
SHELLOPTS: isWindows ? "igncr" : undefined, // ignore "\r" on Windows
TEST_TMPDIR: tmpdirPath, // Used in Node.js tests.
};
const result = await spawnSafe({
command: execPath,
args: [resolve(join(import.meta.dirname, "run-citgm-test.ts")), execPath, testPath],
cwd: cwd,
timeout: timeout,
env: bunEnv,
stdout: chunk => pipeTestStdout(process.stdout, chunk),
stderr: chunk => pipeTestStdout(process.stderr, chunk),
});
const { ok, error, stdout } = result;
return {
testPath: testPath,
ok,
status: ok ? "pass" : "fail",
error: error,
errors: [],
tests: [],
stdout: stdout,
stdoutPreview: stdout,
};
}
/**
* @param {string} testPath
* @returns {number}
@@ -824,6 +875,7 @@ function isJavaScript(path) {
function isTest(path) {
if (path.replaceAll(sep, "/").includes("/test-cluster-") && path.endsWith(".js")) return true;
if (path.replaceAll(sep, "/").startsWith("js/node/cluster/test-") && path.endsWith(".ts")) return true;
if (path.startsWith("https://")) return true; // ecosystem tests
return isTestStrict(path);
}
@@ -843,7 +895,7 @@ function isHidden(path) {
* @param {string} cwd
* @returns {string[]}
*/
function getTests(cwd) {
async function getTests(cwd) {
function* getFiles(cwd, path) {
const dirname = join(cwd, path);
for (const entry of readdirSync(dirname, { encoding: "utf-8", withFileTypes: true })) {
@@ -859,15 +911,21 @@ function getTests(cwd) {
}
}
}
return [...getFiles(cwd, "")].sort();
// prettier-ignore
return [
...Array.from(getFiles(cwd, "")),
...(await import("./citgm-items.mjs")).default
.filter(v => !(v[2] && isWindows))
.map(v => v[1]),
].sort();
}
/**
* @param {string} cwd
* @returns {string[]}
*/
function getRelevantTests(cwd) {
const tests = getTests(cwd);
async function getRelevantTests(cwd) {
const tests = await getTests(cwd);
const availableTests = [];
const filteredTests = [];

View File

@@ -169,15 +169,17 @@ pub const TrustCommand = struct {
Global.crash();
}
fn printErrorZeroUntrustedDependenciesFound(trust_all: bool, packages_to_trust: []const string) void {
fn printErrorZeroUntrustedDependenciesFound(trust_all: bool, packages_to_trust: []const string) noreturn {
Output.print("\n", .{});
if (trust_all) {
Output.errGeneric("0 scripts ran. This means all dependencies are already trusted or none have scripts.", .{});
Output.warn("0 scripts ran. This means all dependencies are already trusted or none have scripts.", .{});
Global.exit(0);
} else {
Output.errGeneric("0 scripts ran. The following packages are already trusted, don't have scripts to run, or don't exist:\n\n", .{});
for (packages_to_trust) |arg| {
Output.prettyError(" <d>-<r> {s}\n", .{arg});
}
Global.exit(1);
}
}
@@ -225,7 +227,6 @@ pub const TrustCommand = struct {
if (untrusted_dep_ids.count() == 0) {
printErrorZeroUntrustedDependenciesFound(trust_all, packages_to_trust.items);
Global.crash();
}
// Instead of running them right away, we group scripts by depth in the node_modules
@@ -314,7 +315,6 @@ pub const TrustCommand = struct {
if (scripts_at_depth.count() == 0 or package_names_to_add.count() == 0) {
printErrorZeroUntrustedDependenciesFound(trust_all, packages_to_trust.items);
Global.crash();
}
var root_node: *Progress.Node = undefined;

View File

@@ -43,6 +43,7 @@ export function createTestBuilder(path: string) {
_skipExecOnUnknownType: boolean = false;
__todo: boolean | string = false;
__only: boolean = false;
constructor(_scriptStr: TemplateStringsArray, _expressions: any[]) {
this._scriptStr = _scriptStr;
@@ -297,6 +298,11 @@ export function createTestBuilder(path: string) {
return this;
}
only(): this {
this.__only = true;
return this;
}
runAsTest(name: string) {
// biome-ignore lint/complexity/noUselessThisAlias: <explanation>
const tb = this;
@@ -305,6 +311,11 @@ export function createTestBuilder(path: string) {
await tb.run();
});
return;
} else if (this.__only) {
test.only(name, async () => {
await tb.run();
});
return;
} else {
if (!this._onlyMini) {
test(