diff --git a/.github/workflows/bun-linux-build.yml b/.github/workflows/bun-linux-build.yml index 75c84c7f62..07d7703545 100644 --- a/.github/workflows/bun-linux-build.yml +++ b/.github/workflows/bun-linux-build.yml @@ -188,9 +188,7 @@ jobs: # if: ${{github.event.inputs.use_bun == 'false'}} run: | bun install - bun install --cwd test/bun.js - bun install --cwd test/bun.js/third-party/body-parser-test - #bun install --cwd test/bun.js/third-party/napi_create_external + bun install --cwd test bun install --cwd packages/bun-internal-test node packages/bun-internal-test/src/runner.node.mjs || true - name: Comment on PR diff --git a/.github/workflows/bun-mac-x64-baseline.yml b/.github/workflows/bun-mac-x64-baseline.yml index c4309a66c1..b2430e93b7 100644 --- a/.github/workflows/bun-mac-x64-baseline.yml +++ b/.github/workflows/bun-mac-x64-baseline.yml @@ -428,9 +428,7 @@ jobs: # if: ${{github.event.inputs.use_bun == 'false'}} run: | bun install - bun install --cwd test/bun.js - bun install --cwd test/bun.js/third-party/body-parser-test - #bun install --cwd test/bun.js/third-party/napi_create_external + bun install --cwd test bun install --cwd packages/bun-internal-test node packages/bun-internal-test/src/runner.node.mjs || true - name: Comment on PR diff --git a/.gitignore b/.gitignore index 79930b44e7..49fb9c41d5 100644 --- a/.gitignore +++ b/.gitignore @@ -112,3 +112,5 @@ src/deps/c-ares/build src/bun.js/debug-bindings-obj failing-tests.txt +test.txt +myscript.sh \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index b9249b91c4..464309eabd 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,11 +1,4 @@ src/fallback.html -# src/test -test/bun.js/solid-dom-fixtures -test/bun.js/bundled -#src/bun.js/builtins -# src/api/demo -test/snapshots -test/snapshots-no-hmr src/bun.js/WebKit src/bun.js/builtins/js src/*.out.js @@ -13,3 +6,5 @@ src/*out.*.js src/deps src/test/fixtures src/react-refresh.js +test/snapshots +test/snapshots-no-hmr diff --git a/Makefile b/Makefile index c76eddd21d..4df8567ddb 100644 --- a/Makefile +++ b/Makefile @@ -590,8 +590,7 @@ release-types: .PHONY: format format: ## to format the code - -$(PRETTIER) --write 'test/bun.js/*.{js,jsx,ts,tsx}' - -$(PRETTIER) --write 'test/bun.js/solid-dom-fixtures/**/*.{js,jsx,ts,tsx}' + -$(PRETTIER) --write 'test/**/*.{js,jsx,ts,tsx}' .PHONY: lolhtml @@ -619,7 +618,7 @@ boringssl-debug: boringssl-build-debug boringssl-copy .PHONY: compile-ffi-test compile-ffi-test: - clang $(OPTIMIZATION_LEVEL) -shared -undefined dynamic_lookup -o /tmp/bun-ffi-test.dylib -fPIC ./test/bun.js/ffi-test.c + clang $(OPTIMIZATION_LEVEL) -shared -undefined dynamic_lookup -o /tmp/bun-ffi-test.dylib -fPIC ./test/js/bun/ffi/ffi-test.c sqlite: @@ -1095,45 +1094,8 @@ dev: mkdir-dev dev-obj bun-link-lld-debug mkdir-dev: mkdir -p $(DEBUG_PACKAGE_DIR)/bin -test-install: - cd test/scripts && $(NPM_CLIENT) install - -.PHONY: test-bun-dev -test-bun-dev: - BUN_BIN=$(RELEASE_BUN) bash test/apps/bun-dev.sh - BUN_BIN=$(RELEASE_BUN) bash test/apps/bun-dev-index-html.sh - -.PHONY: test-dev-bun-dev -test-dev-bun-dev: - BUN_BIN=$(DEBUG_BUN) bash test/apps/bun-dev.sh - BUN_BIN=$(DEBUG_BUN) bash test/apps/bun-dev-index-html.sh - -.PHONY: test-bun-snapshot -test-bun-snapshot: - rm -rf test/bun.js/snapshots.js - touch test/bun.js/snapshots.js - $(foreach i,$(wildcard test/bun.js/*.snapshot.*),echo "" >> test/bun.js/snapshots.js; echo "// $i" >> test/bun.js/snapshots.js; $(RELEASE_BUN) build $i --platform=bun >> test/bun.js/snapshots.js;) - -.PHONY: test-dev-bun-snapshot -test-dev-bun-snapshot: - rm -rf test/bun.js/snapshots.debug.js - touch test/bun.js/snapshots.debug.js - $(foreach i,$(wildcard test/bun.js/*.snapshot.*),echo "" >> test/bun.js/snapshots.debug.js; echo "// $i" >> test/bun.js/snapshots.debug.js; $(DEBUG_BUN) build $i --platform=bun >> test/bun.js/snapshots.debug.js;) - -.PHONY: test-bun-init -test-bun-init: - BUN_BIN=$(RELEASE_BUN) bash test/apps/bun-init-check.sh - -.PHONY: test-dev-bun-init -test-dev-bun-init: - BUN_BIN=$(DEBUG_BUN) bash test/apps/bun-init-check.sh - -.PHONY: test-bun-wiptest -test-bun-wiptest: test/wiptest/run - cd test/wiptest && BUN_BIN=$(DEBUG_BUN) ./run ./fixtures - -.PHONY: test-all -test-all: test-install test-bun-snapshot test-with-hmr test-no-hmr test-create-next test-create-react test-bun-run test-bun-install test-bun-dev test-bun-init +test-all: + $(RELEASE_BUN) test .PHONY: copy-test-node-modules copy-test-node-modules: @@ -1144,73 +1106,6 @@ copy-test-node-modules: kill-bun: -killall -9 bun bun-debug -.PHONY: test-dev-create-next -test-dev-create-next: - BUN_BIN=$(DEBUG_BUN) bash test/apps/bun-create-next.sh - -.PHONY: test-dev-create-react -test-dev-create-react: - BUN_BIN=$(DEBUG_BUN) bash test/apps/bun-create-react.sh - -.PHONY: test-create-next -test-create-next: - BUN_BIN=$(RELEASE_BUN) bash test/apps/bun-create-next.sh - -.PHONY: test-bun-run -test-bun-run: - cd test/apps && BUN_BIN=$(RELEASE_BUN) bash ./bun-run-check.sh - -.PHONY: test-bun-install -test-bun-install: test-bun-install-git-status - cd test/apps && JS_RUNTIME=$(RELEASE_BUN) NPM_CLIENT=$(RELEASE_BUN) bash ./bun-install.sh - cd test/apps && BUN_BIN=$(RELEASE_BUN) bash ./bun-install-utf8.sh - -.PHONY: test-bun-install-git-status -test-bun-install-git-status: - cd test/apps && JS_RUNTIME=$(RELEASE_BUN) BUN_BIN=$(RELEASE_BUN) bash ./bun-install-lockfile-status.sh - -.PHONY: test-dev-bun-install -test-dev-bun-install: test-dev-bun-install-git-status - cd test/apps && JS_RUNTIME=$(DEBUG_BUN) NPM_CLIENT=$(DEBUG_BUN) bash ./bun-install.sh - cd test/apps && BUN_BIN=$(DEBUG_BUN) bash ./bun-install-utf8.sh - -.PHONY: test-dev-bun-install-git-status -test-dev-bun-install-git-status: - cd test/apps && BUN_BIN=$(DEBUG_BUN) bash ./bun-install-lockfile-status.sh - -.PHONY: test-create-react -test-create-react: - BUN_BIN=$(RELEASE_BUN) bash test/apps/bun-create-react.sh - -.PHONY: test-with-hmr -test-with-hmr: kill-bun copy-test-node-modules - BUN_BIN=$(RELEASE_BUN) node test/scripts/browser.js - -.PHONY: test-no-hmr -test-no-hmr: kill-bun copy-test-node-modules - -killall bun -9; - DISABLE_HMR="DISABLE_HMR" BUN_BIN=$(RELEASE_BUN) node test/scripts/browser.js - -.PHONY: test-dev-with-hmr -test-dev-with-hmr: copy-test-node-modules - -killall bun-debug -9; - BUN_BIN=$(DEBUG_BUN) node test/scripts/browser.js - -.PHONY: test-dev-no-hmr -test-dev-no-hmr: copy-test-node-modules - -killall bun-debug -9; - DISABLE_HMR="DISABLE_HMR" BUN_BIN=$(DEBUG_BUN) node test/scripts/browser.js - -.PHONY: test-dev-bun-hmr -test-dev-bun-run: - cd test/apps && BUN_BIN=$(DEBUG_BUN) bash bun-run-check.sh - -.PHONY: test-dev-all -test-dev-all: test-install test-dev-bun-snapshot test-dev-with-hmr test-dev-no-hmr test-dev-create-next test-dev-create-react test-dev-bun-run test-dev-bun-install test-dev-bun-dev test-dev-bun-init -test-dev-bunjs: - -test-dev: test-dev-with-hmr - jsc-copy-headers: cp $(WEBKIT_DIR)/Source/JavaScriptCore/heap/WeakHandleOwner.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/WeakHandleOwner.h cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/LazyClassStructureInlines.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/LazyClassStructureInlines.h diff --git a/bunfig.toml b/bunfig.toml index 8c6c75190a..4e205af4f0 100644 --- a/bunfig.toml +++ b/bunfig.toml @@ -1,8 +1,8 @@ [test] # Large monorepos (like Bun) may want to specify the test directory more specifically -# By default, `bun wiptest` scans every single folder recurisvely which, if you +# By default, `bun test` scans every single folder recurisvely which, if you # have a gigantic submodule (like WebKit), it has to do lots of directory # traversals # # Instead, we can just make it scan only the test directory for Bun's runtime tests -root = "test/bun.js" +root = "test" diff --git a/packages/bun-internal-test/package.json b/packages/bun-internal-test/package.json index 6504f57b48..accc76f77d 100644 --- a/packages/bun-internal-test/package.json +++ b/packages/bun-internal-test/package.json @@ -1,5 +1,6 @@ { "private": true, + "type": "module", "dependencies": { "@actions/core": "^1.10.0" }, @@ -8,6 +9,6 @@ "prettier": "^2.8.2" }, "scripts": { - "test": "bun run src/runner.ts" + "test": "node src/runner.node.mjs" } } diff --git a/packages/bun-internal-test/src/runner.node.mjs b/packages/bun-internal-test/src/runner.node.mjs index 135ee246e8..eca8a9bb14 100644 --- a/packages/bun-internal-test/src/runner.node.mjs +++ b/packages/bun-internal-test/src/runner.node.mjs @@ -129,7 +129,7 @@ function findErrors(data) { } var tests = []; var testFileNames = []; -for (const path of findTests(resolve(cwd, "test/bun.js"))) { +for (const path of findTests(resolve(cwd, "test"))) { testFileNames.push(path); tests.push(runTest(path).catch(console.error)); } diff --git a/packages/bun-internal-test/src/runner.ts b/packages/bun-internal-test/src/runner.ts deleted file mode 100644 index 4b660fe23e..0000000000 --- a/packages/bun-internal-test/src/runner.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { ArrayBufferSink, spawn } from "bun"; -import { readdirSync, openSync, writeSync, truncateSync } from "node:fs"; -import { resolve } from "node:path"; -import * as action from "@actions/core"; -import { StringDecoder } from "node:string_decoder"; - -const cwd = resolve("../.."); -process.chdir(cwd); - -const isAction = !!process.env["GITHUB_ACTION"]; -const errorPattern = /error: ([\S\s]*?)(?=\n.*?at (\/.*):(\d+):(\d+))/gim; - -function* findTests(dir: string, query?: string): Generator { - for (const entry of readdirSync(resolve(dir), { encoding: "utf-8", withFileTypes: true })) { - const path = resolve(dir, entry.name); - if (path.includes("node_modules")) continue; - - if (entry.isDirectory()) { - yield* findTests(path, query); - } else if (entry.isFile() && entry.name.includes(".test.")) { - yield path; - } - } -} - -async function runTest(path: string): Promise { - const name = path.replace(cwd, "").slice(1); - const runner = spawn({ - cmd: ["bun", "test", path], - stdout: "pipe", - stderr: "pipe", - stdin: "ignore", - env: { - ...process.env, - FORCE_COLOR: "1", - }, - }); - const exitCode = await Promise.race([ - new Promise(resolve => { - setTimeout(() => { - runner.kill(); - resolve(124); // Timed Out - }, 60_000); - }), - runner.exited, - ]); - if (isAction) { - const prefix = exitCode === 0 ? "PASS" : `FAIL (exit code ${exitCode})`; - action.startGroup(`${prefix} - ${name}`); - } - for (const stdout of [runner.stdout, runner.stderr]) { - if (!stdout) { - continue; - } - const reader = stdout.getReader(); - while (true) { - const { value, done } = await reader.read(); - if (value) { - console.write(value); - if (isAction) { - findErrors(value); - } - } - if (done) { - break; - } - } - } - if (isAction) { - action.endGroup(); - } -} - -let failed = false; - -function findErrors(data: Uint8Array): void { - const text = new StringDecoder().write(new Buffer(data.buffer)); - for (const [message, _, path, line, col] of text.matchAll(errorPattern)) { - failed = true; - action.error(message, { - file: path.replace(cwd, "").slice(1), - startLine: parseInt(line), - startColumn: parseInt(col), - }); - } - Bun.gc(true); -} - -const tests = []; -for (const path of findTests(resolve(cwd, "test/bun.js"))) { - tests.push(runTest(path).catch(console.error)); -} -await Promise.allSettled(tests); -process.exit(failed ? 1 : 0); diff --git a/packages/bun-internal-test/tsconfig.json b/packages/bun-internal-test/tsconfig.json index 1b2f412201..860a9d3651 100644 --- a/packages/bun-internal-test/tsconfig.json +++ b/packages/bun-internal-test/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "noEmit": true, "lib": ["ESNext"], "module": "ESNext", "target": "ESNext", diff --git a/test/fixtures/bun-link-pkg-fixture/.gitignore b/test/.prettierignore similarity index 54% rename from test/fixtures/bun-link-pkg-fixture/.gitignore rename to test/.prettierignore index 6455d29a68..3c3629e647 100644 --- a/test/fixtures/bun-link-pkg-fixture/.gitignore +++ b/test/.prettierignore @@ -1,2 +1 @@ node_modules -*.bunlockb diff --git a/test/README.md b/test/README.md index 274b19fbfb..36fe3b0057 100644 --- a/test/README.md +++ b/test/README.md @@ -1,145 +1,73 @@ -# Tests in Bun +# Tests -Bun currently has four different kinds of tests +## Finding tests -To run all the tests: +Tests are located in the [`test/`](test/) directory and are organized using the following structure: -```bash -make test-all -bun --cwd=test/bun.js wiptest +* `test/` + * `js/` - tests for JavaScript APIs. + * `cli/` - tests for commands, configs, and stdout. + * `bundler/` - tests for the transpiler/bundler. + * `regression/` - tests that reproduce a specific issue. + * `harness.ts` - utility functions that can be imported from any test. + +The tests in [`test/js/`](test/js/) directory are further categorized by the type of API. + +* `test/js/` + * `bun/` - tests for `Bun`-specific APIs. + * `node/` - tests for Node.js APIs. + * `web/` - tests for Web APIs, like `fetch()`. + * `first_party/` - tests for npm packages that are built-in, like `undici`. + * `third_party/` - tests for npm packages that are not built-in, but are popular, like `esbuild`. + +## Running tests + +To run a test, use Bun's built-in test command: `bun test`. + +```sh +bun test # Run all tests +bun test js/bun # Only run tests in a directory +bun test sqlite.test.ts # Only run a specific test ``` -### Runtime tests +If you encounter lots of errors, try running `bun install`, then trying again. -To run the runtime tests: +## Writing tests -```bash -cd test/bun.js -bun wiptest -``` - -These tests are in [./bun.js](./bun.js) and are files with `.test.js` or `.test.ts` in the filename. - -These test that the runtime behaves as expected. These also test the transpiler, both because test files are transpiled and directly by running the transpiler via `Bun.Transpiler`. - -#### Adding a new test - -1. Create a new file in [./bun.js](./bun.js/) with `.test` in the name. - -These test use `bun:test` as the import (though you can also import from `vitest` or jest and it will work). - -This will eventually be a public test runner for bun, but the reporter isn't very good yet and it doesn't run in parallel. - -The syntax intends for Jest compatibility. +Tests are written in TypeScript (preferred) or JavaScript using Jest's `describe()`, `test()`, and `expect()` APIs. ```ts -import { describe, expect, it } from "bun:test"; +import { describe, test, expect } from "bun:test"; +import { gcTick } from "harness"; -describe("Example", () => { - it("should work", () => { - expect(1).toBe(1); +describe("TextEncoder", () => { + test("can encode a string", async () => { + const encoder = new TextEncoder(); + const actual = encoder.encode("bun"); + await gcTick(); + expect(actual).toBe(new Uint8Array([0x62, 0x75, 0x6E])); }); }); ``` -### Browser tests +If you are fixing a bug that was reported from a GitHub issue, remember to add a test in the `test/regression/` directory. -Browser tests run end-to-end inside of Puppeteer and execute code transpiled by `bun dev`. These tests are in [./snippets](./snippets). +```ts +// test/regression/issue/02005.test.ts -The interface is: +import { it, expect } from "bun:test"; -```js -// this function is called after import() -// if testDone() is never called, the test fails -export function test() { - return testDone(import.meta.url); -} +it("regex literal should work with non-latin1", () => { + const text = "这是一段要替换的文字"; + expect(text.replace(new RegExp("要替换"), "")).toBe("这是一段的文字"); + expect(text.replace(/要替换/, "")).toBe("这是一段的文字"); +}); ``` -On success, it saves a snapshot to [./snapshots](./snapshots) which is checked into git. +In the future, a bot will automatically close or re-open issues when a regression is detected or resolved. -#### Adding a new test - -1. Create a new file in the `snippets` directory. -2. Append the filename to [./scripts/snippets.json](./scripts/snippets.json) -3. Run `bun dev` inside this folder in one terminal window -4. Run `make integration-test-dev` - -These tests are run twice. Once with HMR enabled and once with HMR disabled. HMR changes the output enough to warrant it's own special treatment. - -#### Running the tests - -To run the browser tests with HMR on a production build: - -```bash -make test-with-hmr -``` - -To run the browser tests without HMR on a production build: - -```bash -make test-with-no-hmr -``` - -To run the browser tests with HMR on a debug build: - -```bash -make test-dev-with-hmr -``` - -To run the browser tests without HMR on a debug build: - -```bash -make test-dev-no-hmr -``` - -To run the browser tests on whatever version of bun is running on port 3000: - -```bash -make integration-test-dev -``` - -These were the first tests bun started with - -#### Running the tests - -Run `bun wiptest ${part-of-file-name}` - -If you run the test in the top-level bun repo directory, it will take an extra couple seconds because `bun wiptest` will scan through all of WebKit recursively. Consider running it in the `bun.js` directory instead. - -### CLI tests - -These run the bash files in the `apps` directory. - -They check end-to-end that the CLI works as expected. - -```bash -# Install dependencies for running tests -# Does not run tests -make test-install - -# Check a Create React App created via `bun create react ./foo` returns HTML -make test-create-react - -# Check a Next.js app created via `bun create next ./foo` SSRs successfully -make test-create-next - -# Check that bun run works for the same CLI args passed to npm run -make test-bun-run - -# Check that "react" installed via bun install loads successfully -# and that deleting/adding updates the lockfile as expected -make test-bun-install - -# Check that serving public paths works correctly -# and that files which should be transpiled are transpiled and files which shouldn't be aren't -make test-bun-dev -``` - -### Zig tests +## Zig tests These tests live in various `.zig` files throughout Bun's codebase, leveraging Zig's builtin `test` keyword. -Currently, they're not run automatically nor is there a simple way to run all of them. - -This is an area bun needs to improve in. +Currently, they're not run automatically nor is there a simple way to run all of them. We will make this better soon. diff --git a/test/apps/bun-create-next.sh b/test/apps/bun-create-next.sh deleted file mode 100644 index d8e148282c..0000000000 --- a/test/apps/bun-create-next.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# The important part of this test: make sure that bun.js successfully loads -# The most likely reason for this test to fail is that something broke in the JavaScriptCore <> bun integration -killall -9 $(basename $BUN_BIN) || echo "" - -rm -rf /tmp/next-app -mkdir -p /tmp/next-app -$BUN_BIN create next /tmp/next-app - -if (($?)); then - echo "bun create failed" - exit 1 -fi - -echo "hi!" >/tmp/next-app/public/file.txt -echo "export default 'string';" >/tmp/next-app/file.js - -cd /tmp/next-app -BUN_CRASH_WITHOUT_JIT=1 $BUN_BIN dev --port 8087 & -sleep 0.1 -curl --fail -Ss http://localhost:8087/ - -if [[ "$(curl --fail -sS http://localhost:8087/file.txt)" != "hi!" ]]; then - echo "" - echo "" - echo "" - echo "ERR: Expected 'hi!', got '$(curl --fail -sS http://localhost:8087/file.txt)'" - killall -9 $(basename $BUN_BIN) || echo "" - exit 1 -fi - -if [[ "$(curl --fail -sS http://localhost:8087/file.js)" != *"string"* ]]; then - echo "" - echo "" - echo "" - echo "ERR: Expected file to contain string got '$(curl --fail -sS http://localhost:8087/file.js)'" - killall -9 $(basename $BUN_BIN) || echo "" - exit 1 -fi - -# very simple HMR test -echo "export default 'string';" >/tmp/next-app/file2.js -sleep 0.1 - -if [[ "$(curl --fail -sS http://localhost:8087/file2.js)" != *"string"* ]]; then - echo "" - echo "" - echo "" - echo "ERR: Expected file to contain string got '$(curl --fail -sS http://localhost:8087/file2.js)'" - killall -9 $(basename $BUN_BIN) || echo "" - exit 1 -fi - -killall -9 $(basename $BUN_BIN) || echo "" diff --git a/test/apps/bun-create-react.sh b/test/apps/bun-create-react.sh deleted file mode 100644 index 564a59d35e..0000000000 --- a/test/apps/bun-create-react.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -killall -9 $(basename $BUN_BIN) || echo "" - -rm -rf /tmp/react-app -mkdir -p /tmp/react-app -$BUN_BIN create react /tmp/react-app - - -if (($?)); then - echo "bun create failed" - exit 1 -fi - -cd /tmp/react-app -BUN_CRASH_WITHOUT_JIT=1 $BUN_BIN dev --port 8087 & -sleep 0.005 - -curl --fail http://localhost:8087/ && curl --fail http://localhost:8087/src/index.jsx && killall -9 $(basename $BUN_BIN) && echo "✅ bun create react passed." -exit $? diff --git a/test/apps/bun-dev-index-html.sh b/test/apps/bun-dev-index-html.sh deleted file mode 100644 index f22f8df514..0000000000 --- a/test/apps/bun-dev-index-html.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -killall -9 $(basename $BUN_BIN) || echo "" - -dir=$(mktemp -d) - -index_content="index.html" -bacon_content="bacon.html" -js_content="if(0) { var foo = 'TEST FAILED'; }" -static_content="PASS" -css_not_transpiled_content="@import url(/index.js); @import url(/i-dont-exist.css); @import url('/i-dont-exist.css'); @import url(\"/i-dont-exist.css\");" -css_is_transpiled_import="*{background-color:red;}" -css_is_transpiled="@import url(./css_is_transpiled_import.css);" - -echo $index_content >"$dir/index.html" -echo $js_content >"$dir/index.js" -echo $bacon_content >"$dir/bacon.html" -echo $static_content >"$dir/static.txt" -echo $css_not_transpiled_content >"$dir/css_not_transpiled_content.css" - -cd $dir -$BUN_BIN dev --port 8087 & -sleep 0.005 - -if [[ "$(curl --fail -sS http://localhost:8087/)" != "$index_content" ]]; then - echo "ERR: Expected '$index_content', got '$(curl --fail -sS http://localhost:8087/)'" - exit 1 -fi - -if [[ "$(curl --fail -sS http://localhost:8087/index)" != "$index_content" ]]; then - echo "ERR: Expected '$index_content', got '$(curl --fail -sS http://localhost:8087/index)'" - exit 1 -fi - -if [[ "$(curl --fail -sS http://localhost:8087/static.txt)" != "PASS" ]]; then - echo "ERR: Expected static file, got '$(curl --fail -sS http://localhost:8087/static.txt)'" - exit 1 -fi - -# Check that the file is actually transpiled -if [[ "$(curl --fail -sS http://localhost:8087/index.js)" == *"TEST FAILED"* ]]; then - echo "ERR: Expected file to be transpiled, got '$(curl --fail -sS http://localhost:8087/index.js)'" - exit 1 -fi - -if [[ "$(curl --fail -sS http://localhost:8087/index.html)" != "$index_content" ]]; then - echo "ERR: Expected '$index_content', got '$(curl --fail -sS http://localhost:8087/index.html)'" - exit 1 -fi - -if [[ "$(curl --fail -sS http://localhost:8087/foo/foo)" != "$index_content" ]]; then - echo "ERR: Expected '$index_content', got '$(curl --fail -sS http://localhost:8087/index.html)'" - exit 1 -fi - -if [[ "$(curl --fail -sS http://localhost:8087/bacon)" != "$bacon_content" ]]; then - echo "ERR: Expected '$bacon_content', got '$(curl --fail -sS http://localhost:8087/bacon)'" - exit 1 -fi - -if [[ "$(curl --fail -sS http://localhost:8087/bacon.html)" != "$bacon_content" ]]; then - echo "ERR: Expected '$bacon_content', got '$(curl --fail -sS http://localhost:8087/bacon.html)'" - exit 1 -fi - -killall -9 $(basename $BUN_BIN) || echo "" -echo "✅ bun dev index html check passed." diff --git a/test/apps/bun-dev.sh b/test/apps/bun-dev.sh deleted file mode 100644 index ea15c1d21d..0000000000 --- a/test/apps/bun-dev.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -killall -9 $(basename $BUN_BIN) || echo "" - -dir=$(mktemp -d) - -index_content="index.html" -bacon_content="bacon.html" -js_content="console.log('hi')" - -mkdir -p $dir/public - -echo $index_content >"$dir/public/index.html" -echo $js_content >"$dir/index.js" -echo $bacon_content >"$dir/public/bacon.html" - -cd $dir - -$BUN_BIN dev --port 8087 & -sleep 0.005 - -if [ "$(curl --fail -sS http://localhost:8087/)" != "$index_content" ]; then - echo "ERR: Expected '$index_content', got '$(curl --fail -sS http://localhost:8087/)'" - exit 1 -fi - -if [ "$(curl --fail -sS http://localhost:8087/index)" != "$index_content" ]; then - echo "ERR: Expected '$index_content', got '$(curl --fail -sS http://localhost:8087/index)'" - exit 1 -fi - -if [ "$(curl --fail -sS http://localhost:8087/index.html)" != "$index_content" ]; then - echo "ERR: Expected '$index_content', got '$(curl --fail -sS http://localhost:8087/index.html)'" - exit 1 -fi - -if [ "$(curl --fail -sS http://localhost:8087/foo/foo)" != "$index_content" ]; then - echo "ERR: Expected '$index_content', got '$(curl --fail -sS http://localhost:8087/index.html)'" - exit 1 -fi - -if [ "$(curl --fail -sS http://localhost:8087/bacon)" != "$bacon_content" ]; then - echo "ERR: Expected '$index_content', got '$(curl --fail -sS http://localhost:8087/bacon)'" - exit 1 -fi - -if [ "$(curl --fail -sS http://localhost:8087/bacon.html)" != "$bacon_content" ]; then - echo "ERR: Expected '$index_content', got '$(curl --fail -sS http://localhost:8087/bacon.html)'" - exit 1 -fi - -killall -9 $(basename $BUN_BIN) || echo "" -echo "✅ bun dev index html check passed." diff --git a/test/apps/bun-init-check.sh b/test/apps/bun-init-check.sh deleted file mode 100644 index d0077cb60d..0000000000 --- a/test/apps/bun-init-check.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -# TODO: move this test to bun once we have a child_process equivalent. -(killall -9 $(basename $BUN_BIN) || echo "") >/dev/null 2>&1 - -rm -rf /tmp/bun-init-check -mkdir -p /tmp/bun-init-check - -cd /tmp/bun-init-check - -$BUN_BIN init -y - -if (($?)); then - echo "Bun init failed" - exit 1 -fi - -SHASUM_RESULT=$(cat index.ts .gitignore tsconfig.json package.json | shasum) - -# This test will fail when the minor version of Bun changes. -if [[ "${SHASUM_RESULT}" != "10eabf5101a3ef999bd67232a7af33542c525ec6 -" ]]; then - echo -e "Bun init shasum mismatch\n expected: b1548bb4e806f0506fd1b27ae8901d2e84926774\n actual: ${SHASUM_RESULT}" - exit 1 -fi - -exit 0 diff --git a/test/apps/bun-install-lockfile-status.sh b/test/apps/bun-install-lockfile-status.sh deleted file mode 100644 index fc39a6dd6e..0000000000 --- a/test/apps/bun-install-lockfile-status.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -killall -9 $(basename $BUN_BIN) || echo "" - -dir=$(mktemp -d) - -cd $dir - -$BUN_BIN add react - -echo "node_modules" >.gitignore - -git init && git add . && git commit -am "Initial commit" - -$BUN_BIN install - -ORIG_LOCKFILE="$($BUN_BIN pm hash-string)" - -[[ -z $(git status --untracked-files=no --porcelain) ]] || { - echo "ERR: Expected empty git status, got '$(git status --untracked-files=no --porcelain)'" - exit 1 -} - -$BUN_BIN add react - -NEW_LOCKFILE="$($BUN_BIN pm hash-string)" - -diff <(echo "$ORIG_LOCKFILE") <(echo "$NEW_LOCKFILE") || { - echo "ERR: Expected lockfile to be unchanged, got '$NEW_LOCKFILE'" - exit 1 -} - -ORIG_HASH=$($BUN_BIN bun.lockb --hash) - -$BUN_BIN remove react -$BUN_BIN add react - -NEW_HASH=$($BUN_BIN bun.lockb --hash) - -diff <(echo "$ORIG_HASH") <(echo "$NEW_HASH") || { - echo "ERR: Expected hash to be unchanged, got '$NEW_HASH'" - exit 1 -} - -echo '{ "dependencies": { "react": "17.0.2", "react-dom": "17.0.2" } }' >package.json - -$BUN_BIN install - -echo "var {version} = JSON.parse(require(\"fs\").readFileSync('./node_modules/react-dom/package.json', 'utf8')); if (version !== '17.0.2') {throw new Error('Unexpected react-dom version');}; " >index.js -$BUN_BIN run ./index.js - -echo "var {version} = JSON.parse(require(\"fs\").readFileSync('./node_modules/react/package.json', 'utf8')); if (version !== '17.0.2') {throw new Error('Unexpected react version');}; " >index.js -$BUN_BIN run ./index.js - -# This is just making sure that the JS was executed -realpath -e node_modules/react-dom >/dev/null || { - echo "ERR: Expected react-dom to be installed" - exit 1 -} -realpath -e node_modules/react >/dev/null || { - echo "ERR: Expected react to be installed" - exit 1 -} diff --git a/test/apps/bun-install-utf8.sh b/test/apps/bun-install-utf8.sh deleted file mode 100644 index ac6b684ed4..0000000000 --- a/test/apps/bun-install-utf8.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -killall -9 $(basename $BUN_BIN) || echo "" - -dir=$(mktemp -d) - -cd $dir - -# https://github.com/oven-sh/bun/issues/115 -echo '{ "author": "Arnaud Barré (https://github.com/ArnaudBarre)" }' >package.json - -$BUN_BIN add react diff --git a/test/apps/bun-install.sh b/test/apps/bun-install.sh deleted file mode 100644 index 18813b2d27..0000000000 --- a/test/apps/bun-install.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -dir=$(mktemp -d) - -cd $dir -${NPM_CLIENT:-$(which bun)} add react react-dom @types/react @babel/parser esbuild vite@3.0.0 - -echo "console.log(typeof require(\"react\").createElement);" >index.js -chmod +x index.js - -JS_RUNTIME=${JS_RUNTIME:-"$(which bun)"} - -if [ "$JS_RUNTIME" == "node" ]; then - result="$(node ./index.js)" -fi - -if [ "$JS_RUNTIME" != "node" ]; then - result="$($JS_RUNTIME run ./index.js)" -fi - -echo "console.log(typeof require(\"react-dom\").render);" >index.js -chmod +x index.js - -JS_RUNTIME=${JS_RUNTIME:-"$(which bun)"} - -# If this fails to run, it means we didn't link @babel/parser correctly -$(which grealpath || which realpath) -e ./node_modules/.bin/parser >/dev/null - -# If this fails to run, it means we didn't link esbuild correctly or esbuild's install script broke -# - https://github.com/evanw/esbuild/issues/2558 -./node_modules/.bin/esbuild --version >/dev/null - -VITE_ESBUILD="$(echo node_modules/vite/node_modules/esbuild-*)" -$VITE_ESBUILD/bin/esbuild --version >/dev/null - -if [ "$JS_RUNTIME" == "node" ]; then - result="$(node ./index.js)" -fi - -if [ "$JS_RUNTIME" != "node" ]; then - result="$($JS_RUNTIME run ./index.js)" -fi - -if [ "$result" != "function" ]; then - echo "ERR: Expected 'function', got '$result'" - exit 1 -fi - -${NPM_CLIENT:-$(which bun)} remove react-dom - -if [ -d "node_modules/react-dom" ]; then - echo "ERR: react-dom module still exists in $dir" - exit 1 -fi - -yarn_dot_lock=$(${NPM_CLIENT:-$(which bun)} bun.lockb) - -if echo "$yarn_dot_lock" | grep -q "react-dom"; then - echo "ERR: react-dom module still exists in lockfile" - exit 1 -fi - -${NPM_CLIENT:-$(which bun)} remove @types/react - -yarn_dot_lock=$(${NPM_CLIENT:-$(which bun)} bun.lockb) - -if echo "$yarn_dot_lock" | grep -q "@types/react"; then - echo "ERR: @types/react module still exists in lockfile" - exit 1 -fi - -if echo "$yarn_dot_lock" | grep -q "@types/react"; then - echo "ERR: @types/react module still exists in $dir" - exit 1 -fi - -${NPM_CLIENT:-$(which bun)} remove react - -if [ -d "node_modules/react" ]; then - echo "ERR: react module still exists in $dir" - exit 1 -fi - -if [ -d "bun.lockb" ]; then - echo "ERR: empty bun.lockb should be deleted" - exit 1 -fi diff --git a/test/apps/bun-run-check-nameless-package.json b/test/apps/bun-run-check-nameless-package.json deleted file mode 100644 index 8ace036137..0000000000 --- a/test/apps/bun-run-check-nameless-package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "scripts": { - "this-should-work": "echo \"✅ bun run test passed!\"", - "argv": "node -e 'console.log(process.argv)'" - } -} diff --git a/test/apps/bun-run-check-package.json b/test/apps/bun-run-check-package.json deleted file mode 100644 index b6eeda0462..0000000000 --- a/test/apps/bun-run-check-package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "check", - "scripts": { - "this-should-work": "echo \"✅ bun run test passed!\"", - "argv": "node -e 'console.log(process.argv)'" - } -} diff --git a/test/apps/bun-run-check.sh b/test/apps/bun-run-check.sh deleted file mode 100644 index 25432c4227..0000000000 --- a/test/apps/bun-run-check.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash - -# TODO: move this test to bun once we have a child_process equivalent. -(killall -9 $(basename $BUN_BIN) || echo "") >/dev/null 2>&1 - -# https://github.com/oven-sh/bun/issues/40 -# Define a function (details aren't important) -fn() { :; } -# The important bit: export the function -export -f fn - -rm -rf /tmp/bun-run-check -mkdir -p /tmp/bun-run-check - -cp ./bun-run-check-package.json /tmp/bun-run-check/package.json -cd /tmp/bun-run-check - -$BUN_BIN run bash -- -c "" - -if (($?)); then - echo "Bash exported functions are broken" - exit 1 -fi - -# We need to run these tests for two variations: -# bun run foo "bar" -# bun run foo -- "bar" -# the "--" should be ignored -# in earlier versions of bun, it was required to be present - -$BUN_BIN run bash -c "" -if (($?)); then - echo "Bash exported functions are broken" - exit 1 -fi - -# https://github.com/oven-sh/bun/issues/53 -rm -f /tmp/bun-run-out.expected.txt /tmp/bun-run-out.txt >/dev/null 2>&1 - -$BUN_BIN run --silent argv -- foo bar baz >/tmp/bun-run-out.txt -npm run --silent argv -- foo bar baz >/tmp/bun-run-out.expected.txt - -cmp -s /tmp/bun-run-out.expected.txt /tmp/bun-run-out.txt -if (($?)); then - echo "argv failed" - exit 1 -fi - -rm -f /tmp/bun-run-out.expected.txt /tmp/bun-run-out.txt >/dev/null 2>&1 - -$BUN_BIN run --silent argv foo bar baz >/tmp/bun-run-out.txt -npm run --silent argv -- foo bar baz >/tmp/bun-run-out.expected.txt - -cmp -s /tmp/bun-run-out.expected.txt /tmp/bun-run-out.txt -if (($?)); then - echo "argv failed" - exit 1 -fi - -$BUN_BIN run --silent this-should-work - -if (($?)); then - echo "this-should work failed" - exit 1 -fi - -exit 0 diff --git a/test/bun.js/.prettierignore b/test/bun.js/.prettierignore deleted file mode 100644 index 91b589eb2a..0000000000 --- a/test/bun.js/.prettierignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -third-party diff --git a/test/bun.js/bun.lockb b/test/bun.js/bun.lockb deleted file mode 100755 index 0c6a33d3d1..0000000000 Binary files a/test/bun.js/bun.lockb and /dev/null differ diff --git a/test/bun.js/bunEnv.ts b/test/bun.js/bunEnv.ts deleted file mode 100644 index 2fe33a4eaa..0000000000 --- a/test/bun.js/bunEnv.ts +++ /dev/null @@ -1,6 +0,0 @@ -export const bunEnv: any = { - ...process.env, - BUN_DEBUG_QUIET_LOGS: "1", - NO_COLOR: "1", - FORCE_COLOR: undefined, -}; diff --git a/test/bun.js/bunExe.ts b/test/bun.js/bunExe.ts deleted file mode 100644 index a66f702de3..0000000000 --- a/test/bun.js/bunExe.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function bunExe() { - return process.execPath; -} diff --git a/test/bun.js/bundled/always-bundled-module/always-bundled-module b/test/bun.js/bundled/always-bundled-module/always-bundled-module deleted file mode 120000 index f9a91ac4da..0000000000 --- a/test/bun.js/bundled/always-bundled-module/always-bundled-module +++ /dev/null @@ -1 +0,0 @@ -node_modules/always-bundled-module \ No newline at end of file diff --git a/test/bun.js/bundled/always-bundled-module/cjs.js b/test/bun.js/bundled/always-bundled-module/cjs.js deleted file mode 100644 index 087697589b..0000000000 --- a/test/bun.js/bundled/always-bundled-module/cjs.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - default: 0xdeadbeef, - default() { - return "ok"; - }, - default: true, - ok() { - return true; - }, -}; diff --git a/test/bun.js/bundled/always-bundled-module/esm.js b/test/bun.js/bundled/always-bundled-module/esm.js deleted file mode 100644 index 28e702881b..0000000000 --- a/test/bun.js/bundled/always-bundled-module/esm.js +++ /dev/null @@ -1,5 +0,0 @@ -const __esModule = true; - -export const foo = () => __esModule; - -export { __esModule, foo as default }; diff --git a/test/bun.js/bundled/always-bundled-module/package.json b/test/bun.js/bundled/always-bundled-module/package.json deleted file mode 100644 index 5029c16959..0000000000 --- a/test/bun.js/bundled/always-bundled-module/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "always-bundled-module", - "version": "1.0.0" -} diff --git a/test/bun.js/bundled/entrypoint.ts b/test/bun.js/bundled/entrypoint.ts deleted file mode 100644 index b9a17b538a..0000000000 --- a/test/bun.js/bundled/entrypoint.ts +++ /dev/null @@ -1,13 +0,0 @@ -import "i-am-bundled/cjs"; -import "i-am-bundled/esm"; -import "always-bundled-module/esm"; -import "always-bundled-module/cjs"; -import { foo } from "i-am-bundled/esm"; -import { foo as foo2 } from "always-bundled-module/esm"; -import cJS from "always-bundled-module/cjs"; - -foo(); -foo2(); -cJS(); - -export default cJS(); diff --git a/test/bun.js/bundled/package.json b/test/bun.js/bundled/package.json deleted file mode 100644 index cce72af9c3..0000000000 --- a/test/bun.js/bundled/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "to-bundle", - "scripts": { - "prebundle": "rm -rf node_modules; cp -r to_bundle_node_modules node_modules; ln -s always-bundled-module node_modules/always-bundled-module", - "bundle": "${BUN_BIN:-$(which bun)} bun ./entrypoint.ts" - }, - "bun": { - "alwaysBundle": [ - "always-bundled-module" - ] - } -} diff --git a/test/bun.js/bundled/to_bundle_node_modules/i-am-bundled/cjs.js b/test/bun.js/bundled/to_bundle_node_modules/i-am-bundled/cjs.js deleted file mode 100644 index 087697589b..0000000000 --- a/test/bun.js/bundled/to_bundle_node_modules/i-am-bundled/cjs.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - default: 0xdeadbeef, - default() { - return "ok"; - }, - default: true, - ok() { - return true; - }, -}; diff --git a/test/bun.js/bundled/to_bundle_node_modules/i-am-bundled/esm.js b/test/bun.js/bundled/to_bundle_node_modules/i-am-bundled/esm.js deleted file mode 100644 index 28e702881b..0000000000 --- a/test/bun.js/bundled/to_bundle_node_modules/i-am-bundled/esm.js +++ /dev/null @@ -1,5 +0,0 @@ -const __esModule = true; - -export const foo = () => __esModule; - -export { __esModule, foo as default }; diff --git a/test/bun.js/bundled/to_bundle_node_modules/i-am-bundled/package.json b/test/bun.js/bundled/to_bundle_node_modules/i-am-bundled/package.json deleted file mode 100644 index 661a80b2d1..0000000000 --- a/test/bun.js/bundled/to_bundle_node_modules/i-am-bundled/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "i-am-bundled", - "version": "1.0.0" -} diff --git a/test/bun.js/bundled/tsconfig.json b/test/bun.js/bundled/tsconfig.json deleted file mode 100644 index 3ccb11ae46..0000000000 --- a/test/bun.js/bundled/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "compilerOptions": { - "paths": {}, - "baseUrl": ".", - } -} \ No newline at end of file diff --git a/test/bun.js/file-importing-nonexistent-file.js b/test/bun.js/file-importing-nonexistent-file.js deleted file mode 100644 index 1136a7d8c2..0000000000 --- a/test/bun.js/file-importing-nonexistent-file.js +++ /dev/null @@ -1 +0,0 @@ -import "./does-not-exist.js"; diff --git a/test/bun.js/google-fixture.html b/test/bun.js/google-fixture.html deleted file mode 100644 index a5042789e4..0000000000 --- a/test/bun.js/google-fixture.html +++ /dev/null @@ -1,632 +0,0 @@ - - - - - - - - Google - - - - - - - -
-
- Search Images - Maps - Play - YouTube - News - Gmail - Drive - More » -
- -
-
-
-
-
-
-

-
-
- - - - - - -
  - -
- -
-
- - -
- Advanced search -
- - -
-
-

-
- -
-

- © 2022 - Privacy - Terms -

-
- - - - - diff --git a/test/bun.js/import.live.rexport.js b/test/bun.js/import.live.rexport.js deleted file mode 100644 index e4accd2ba4..0000000000 --- a/test/bun.js/import.live.rexport.js +++ /dev/null @@ -1,2 +0,0 @@ -export { foo, setFoo } from "./import.live.decl"; -import { foo as bar } from "./import.live.decl"; diff --git a/test/bun.js/module-require.snapshot.js b/test/bun.js/module-require.snapshot.js deleted file mode 100644 index d0270bb4c8..0000000000 --- a/test/bun.js/module-require.snapshot.js +++ /dev/null @@ -1 +0,0 @@ -console.log(module.require("react")); diff --git a/test/bun.js/package.json b/test/bun.js/package.json deleted file mode 100644 index 709dc6602c..0000000000 --- a/test/bun.js/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "bun-tests", - "dependencies": { - "esbuild": "0.15.13", - "uuid": "^9.0.0", - "tiny-typed-emitter": "^1.0.0", - "svelte": "^3.52.0" - }, - "prettier": "../../.prettierrc.cjs" -} diff --git a/test/bun.js/readdir.js b/test/bun.js/readdir.js deleted file mode 100644 index 18c111d0a0..0000000000 --- a/test/bun.js/readdir.js +++ /dev/null @@ -1,9 +0,0 @@ -const { readdirSync } = require("fs"); - -const count = parseInt(process.env.ITERATIONS || "1", 10) || 1; - -for (let i = 0; i < count; i++) { - readdirSync("."); -} - -console.log(readdirSync(".")); diff --git a/test/bun.js/snapshots.debug.js b/test/bun.js/snapshots.debug.js deleted file mode 100644 index cb774b3828..0000000000 --- a/test/bun.js/snapshots.debug.js +++ /dev/null @@ -1,7 +0,0 @@ -// test/bun.js/module-require.snapshot.js -import { __require as require } from "bun:wrap"; -console.log(import.meta.require("/Users/jarred/Code/bun/node_modules/react/index.js")); - -// test/bun.js/require-referenceerror.snapshot.js - -// test/bun.js/tiny-typed-emitter.snapshot.js diff --git a/test/bun.js/snapshots.js b/test/bun.js/snapshots.js deleted file mode 100644 index cb774b3828..0000000000 --- a/test/bun.js/snapshots.js +++ /dev/null @@ -1,7 +0,0 @@ -// test/bun.js/module-require.snapshot.js -import { __require as require } from "bun:wrap"; -console.log(import.meta.require("/Users/jarred/Code/bun/node_modules/react/index.js")); - -// test/bun.js/require-referenceerror.snapshot.js - -// test/bun.js/tiny-typed-emitter.snapshot.js diff --git a/test/bun.js/some-fs.js b/test/bun.js/some-fs.js deleted file mode 100644 index c162ed45a5..0000000000 --- a/test/bun.js/some-fs.js +++ /dev/null @@ -1,45 +0,0 @@ -const { mkdirSync, existsSync } = require("fs"); - -var performance = globalThis.performance; -if (!performance) { - try { - performance = require("perf_hooks").performance; - } catch (e) {} -} - -const count = parseInt(process.env.ITERATIONS || "1", 10) || 1; -var tempdir = `/tmp/some-fs-test/dir/${Date.now()}/hi`; - -for (let i = 0; i < count; i++) { - tempdir += `/${i.toString(36)}`; -} - -if (existsSync(tempdir)) { - throw new Error(`existsSync reports ${tempdir} exists, but it probably does not`); -} - -var origTempDir = tempdir; -var iterations = new Array(count * count).fill(""); -var total = 0; -for (let i = 0; i < count; i++) { - for (let j = 0; j < count; j++) { - iterations[total++] = `${origTempDir}/${j.toString(36)}-${i.toString(36)}`; - } -} -tempdir = origTempDir; -mkdirSync(origTempDir, { recursive: true }); -const recurse = { recursive: false }; -const start = performance.now(); -for (let i = 0; i < total; i++) { - mkdirSync(iterations[i], recurse); -} - -console.log("MKDIR " + total + " depth took:", performance.now() - start, "ms"); - -if (!existsSync(tempdir)) { - throw new Error("Expected directory to exist after mkdirSync, but it doesn't"); -} - -if (mkdirSync(tempdir, { recursive: true })) { - throw new Error("mkdirSync shouldn't return directory name on existing directories"); -} diff --git a/test/bun.js/test-programs/bigpipe-r.c b/test/bun.js/test-programs/bigpipe-r.c deleted file mode 100644 index 1acd94f7bc..0000000000 --- a/test/bun.js/test-programs/bigpipe-r.c +++ /dev/null @@ -1,26 +0,0 @@ -#include - -char one_mb_pipe_buf_1[1024 * 1024]; - - int main(int argc, char* argv[]) - { - for (int i = 0; i < sizeof(one_mb_pipe_buf_1); i++) { - one_mb_pipe_buf_1[i] = i % 256; - } - - while (1) { - - - size_t amt = 0; - size_t cnt = 0; - - cnt = 0; - while (cnt < sizeof(one_mb_pipe_buf_1)) { - amt = read(0, one_mb_pipe_buf_1 + cnt, sizeof(one_mb_pipe_buf_1) - cnt); - if (amt == 0) { - break; - } - cnt += amt; - } - } - } \ No newline at end of file diff --git a/test/bun.js/test-programs/bigpipe-w.c b/test/bun.js/test-programs/bigpipe-w.c deleted file mode 100644 index 1acd94f7bc..0000000000 --- a/test/bun.js/test-programs/bigpipe-w.c +++ /dev/null @@ -1,26 +0,0 @@ -#include - -char one_mb_pipe_buf_1[1024 * 1024]; - - int main(int argc, char* argv[]) - { - for (int i = 0; i < sizeof(one_mb_pipe_buf_1); i++) { - one_mb_pipe_buf_1[i] = i % 256; - } - - while (1) { - - - size_t amt = 0; - size_t cnt = 0; - - cnt = 0; - while (cnt < sizeof(one_mb_pipe_buf_1)) { - amt = read(0, one_mb_pipe_buf_1 + cnt, sizeof(one_mb_pipe_buf_1) - cnt); - if (amt == 0) { - break; - } - cnt += amt; - } - } - } \ No newline at end of file diff --git a/test/bun.js/test_scope_debug.ts b/test/bun.js/test_scope_debug.ts deleted file mode 100644 index fbc79acd84..0000000000 --- a/test/bun.js/test_scope_debug.ts +++ /dev/null @@ -1,172 +0,0 @@ -type AnyFunction = (...args: any[]) => any; -export function wrap({ - test: test_, - it: it_, - describe: describe_, - beforeEach: beforeEach_ = undefined, - beforeAll: beforeAll_ = undefined, - afterEach: afterEach_ = undefined, - afterAll: afterAll_ = undefined, -}: any) { - if (it_ === undefined) { - it_ = test_; - } - - var describe = (label, cb: AnyFunction) => { - return describe_( - label, - cb instanceof async function () {}.constructor - ? async () => { - console.log(`DESCRIBE [Enter] ${label}`); - try { - return await cb(); - } catch (e) { - throw e; - } finally { - console.log(`DESCRIBE [Exit] ${label}`); - } - } - : () => { - console.log(`DESCRIBE [Enter] ${label}`); - try { - return cb(); - } catch (e) { - throw e; - } finally { - console.log(`DESCRIBE [Exit] ${label}`); - } - }, - ); - }; - - var it = (label, cb: AnyFunction) => { - console.log("Before", label); - return it_( - label, - cb instanceof async function () {}.constructor - ? async () => { - console.log(`TEST [Enter] ${label}`); - try { - return await cb(); - } catch (e) { - throw e; - } finally { - console.log(`TEST [Exit] ${label}`); - } - } - : () => { - console.log(`TEST [Enter] ${label}`); - try { - return cb(); - } catch (e) { - throw e; - } finally { - console.log(`TEST [Exit] ${label}`); - } - }, - ); - }; - - var beforeEach = (cb: AnyFunction) => { - return beforeEach_( - cb instanceof async function () {}.constructor - ? async () => { - console.log(`BEFORE EACH [Enter]`); - try { - return await cb(); - } catch (e) { - throw e; - } finally { - console.log(`BEFORE EACH [Exit]`); - } - } - : () => { - console.log(`BEFORE EACH [Enter]`); - try { - return cb(); - } catch (e) { - throw e; - } finally { - console.log(`BEFORE EACH [Exit]`); - } - }, - ); - }; - var beforeAll = (cb: AnyFunction) => { - return beforeAll_( - cb instanceof async function () {}.constructor - ? async () => { - console.log(`BEFORE ALL [Enter]`); - try { - return await cb(); - } catch (e) { - throw e; - } finally { - console.log(`BEFORE ALL [Exit]`); - } - } - : () => { - console.log(`BEFORE ALL [Enter]`); - try { - return cb(); - } catch (e) { - throw e; - } finally { - console.log(`BEFORE ALL [Exit]`); - } - }, - ); - }; - var afterEach = (cb: AnyFunction) => { - return afterEach_( - cb instanceof async function () {}.constructor - ? async () => { - console.log(`AFTER EACH [Enter]`); - try { - return await cb(); - } catch (e) { - throw e; - } finally { - console.log(`AFTER EACH [Exit]`); - } - } - : () => { - console.log(`AFTER EACH [Enter]`); - try { - return cb(); - } catch (e) { - throw e; - } finally { - console.log(`AFTER EACH [Exit]`); - } - }, - ); - }; - var afterAll = (cb: AnyFunction) => { - return afterAll_( - cb instanceof async function () {}.constructor - ? async () => { - console.log(`AFTER ALL [Enter]`); - try { - return await cb(); - } catch (e) { - throw e; - } finally { - console.log(`AFTER ALL [Exit]`); - } - } - : () => { - console.log(`AFTER ALL [Enter]`); - try { - return cb(); - } catch (e) { - throw e; - } finally { - console.log(`AFTER ALL [Exit]`); - } - }, - ); - }; - - return { describe, it, beforeEach, beforeAll, afterEach, afterAll }; -} diff --git a/test/bun.js/tiny-typed-emitter.snapshot.js b/test/bun.js/tiny-typed-emitter.snapshot.js deleted file mode 100644 index 37299f9864..0000000000 --- a/test/bun.js/tiny-typed-emitter.snapshot.js +++ /dev/null @@ -1,7 +0,0 @@ -/** - * https://github.com/oven-sh/bun/issues/453 - */ -import { createRequire as topLevelCreateRequire } from "module"; -import { TypedEmitter as TypedEmitter7 } from "tiny-typed-emitter"; - -const require = topLevelCreateRequire(import.meta.url); diff --git a/test/bun.js/tsconfig.json b/test/bun.js/tsconfig.json deleted file mode 100644 index 0874dfd7ed..0000000000 --- a/test/bun.js/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "paths": { - "foo/bar": ["baz.js"], - "@faasjs/*": ["*.js"] - }, - "baseUrl": "." - }, - "exclude": ["solid-dom-fixtures", "bundled"] -} diff --git a/test/bun.lockb b/test/bun.lockb new file mode 100755 index 0000000000..f724750a95 Binary files /dev/null and b/test/bun.lockb differ diff --git a/test/bun.js/decorators.test.ts b/test/bundler/decorators.test.ts similarity index 100% rename from test/bun.js/decorators.test.ts rename to test/bundler/decorators.test.ts diff --git a/test/bun.js/inline.macro.js b/test/bundler/inline.macro.js similarity index 100% rename from test/bun.js/inline.macro.js rename to test/bundler/inline.macro.js diff --git a/test/bun.js/macro-check.js b/test/bundler/macro-check.js similarity index 100% rename from test/bun.js/macro-check.js rename to test/bundler/macro-check.js diff --git a/test/bun.js/transpiler.test.js b/test/bundler/transpiler.test.js similarity index 100% rename from test/bun.js/transpiler.test.js rename to test/bundler/transpiler.test.js diff --git a/test/bun.js/hot-runner-imported.js b/test/cli/hot/hot-runner-imported.js similarity index 100% rename from test/bun.js/hot-runner-imported.js rename to test/cli/hot/hot-runner-imported.js diff --git a/test/bun.js/hot-runner.js b/test/cli/hot/hot-runner.js similarity index 100% rename from test/bun.js/hot-runner.js rename to test/cli/hot/hot-runner.js diff --git a/test/bun.js/hot.test.ts b/test/cli/hot/hot.test.ts similarity index 98% rename from test/bun.js/hot.test.ts rename to test/cli/hot/hot.test.ts index 1745155074..88c7977f70 100644 --- a/test/bun.js/hot.test.ts +++ b/test/cli/hot/hot.test.ts @@ -1,7 +1,6 @@ import { spawn } from "bun"; import { expect, it } from "bun:test"; -import { bunEnv } from "bunEnv"; -import { bunExe } from "bunExe"; +import { bunExe, bunEnv } from "harness"; import { readFileSync, renameSync, rmSync, unlinkSync, writeFileSync } from "fs"; it("should hot reload when file is overwritten", async () => { diff --git a/test/bun.js/install/bad-workspace.test.ts b/test/cli/install/bad-workspace.test.ts similarity index 93% rename from test/bun.js/install/bad-workspace.test.ts rename to test/cli/install/bad-workspace.test.ts index bb3f03a86e..1feafc2b0d 100644 --- a/test/bun.js/install/bad-workspace.test.ts +++ b/test/cli/install/bad-workspace.test.ts @@ -1,7 +1,6 @@ import { spawnSync } from "bun"; import { test, describe, expect } from "bun:test"; -import { bunEnv } from "bunEnv"; -import { bunExe } from "bunExe"; +import { bunExe, bunEnv } from "harness"; import { mkdirSync, rmSync, writeFileSync } from "fs"; test("bad workspace path", () => { diff --git a/test/bun.js/install/bar-0.0.2.tgz b/test/cli/install/bar-0.0.2.tgz similarity index 100% rename from test/bun.js/install/bar-0.0.2.tgz rename to test/cli/install/bar-0.0.2.tgz diff --git a/test/bun.js/install/baz-0.0.3.tgz b/test/cli/install/baz-0.0.3.tgz similarity index 100% rename from test/bun.js/install/baz-0.0.3.tgz rename to test/cli/install/baz-0.0.3.tgz diff --git a/test/bun.js/install/baz-0.0.5.tgz b/test/cli/install/baz-0.0.5.tgz similarity index 100% rename from test/bun.js/install/baz-0.0.5.tgz rename to test/cli/install/baz-0.0.5.tgz diff --git a/test/bun.js/install/bun-add.test.ts b/test/cli/install/bun-add.test.ts similarity index 99% rename from test/bun.js/install/bun-add.test.ts rename to test/cli/install/bun-add.test.ts index 9ac54bbc55..d1222993b5 100644 --- a/test/bun.js/install/bun-add.test.ts +++ b/test/cli/install/bun-add.test.ts @@ -1,7 +1,6 @@ import { file, spawn } from "bun"; import { afterAll, afterEach, beforeAll, beforeEach, expect, it } from "bun:test"; -import { bunExe } from "bunExe"; -import { bunEnv as env } from "bunEnv"; +import { bunExe, bunEnv as env } from "harness"; import { access, mkdir, mkdtemp, readlink, realpath, rm, writeFile } from "fs/promises"; import { join, relative } from "path"; import { tmpdir } from "os"; diff --git a/test/bun.js/install/bun-install.test.ts b/test/cli/install/bun-install.test.ts similarity index 99% rename from test/bun.js/install/bun-install.test.ts rename to test/cli/install/bun-install.test.ts index 3ea14f27ca..ee515280e4 100644 --- a/test/bun.js/install/bun-install.test.ts +++ b/test/cli/install/bun-install.test.ts @@ -1,7 +1,6 @@ import { file, listen, spawn } from "bun"; import { afterAll, afterEach, beforeAll, beforeEach, expect, it } from "bun:test"; -import { bunExe } from "bunExe"; -import { bunEnv as env } from "bunEnv"; +import { bunExe, bunEnv as env } from "harness"; import { access, mkdir, readlink, writeFile } from "fs/promises"; import { join } from "path"; import { diff --git a/test/bun.js/install/bun-link.test.ts b/test/cli/install/bun-link.test.ts similarity index 99% rename from test/bun.js/install/bun-link.test.ts rename to test/cli/install/bun-link.test.ts index c1e1d18908..5b0abe1390 100644 --- a/test/bun.js/install/bun-link.test.ts +++ b/test/cli/install/bun-link.test.ts @@ -1,7 +1,6 @@ import { spawn } from "bun"; import { afterAll, afterEach, beforeAll, beforeEach, expect, it } from "bun:test"; -import { bunExe } from "bunExe"; -import { bunEnv as env } from "bunEnv"; +import { bunExe, bunEnv as env } from "harness"; import { access, mkdtemp, readlink, realpath, rm, writeFile } from "fs/promises"; import { basename, join } from "path"; import { tmpdir } from "os"; diff --git a/test/bun.js/install/bun-pm.test.ts b/test/cli/install/bun-pm.test.ts similarity index 98% rename from test/bun.js/install/bun-pm.test.ts rename to test/cli/install/bun-pm.test.ts index 3db2a4ad0b..23b73dfaeb 100644 --- a/test/bun.js/install/bun-pm.test.ts +++ b/test/cli/install/bun-pm.test.ts @@ -1,7 +1,6 @@ import { spawn } from "bun"; import { afterAll, afterEach, beforeAll, beforeEach, expect, it } from "bun:test"; -import { bunExe } from "bunExe"; -import { bunEnv as env } from "bunEnv"; +import { bunExe, bunEnv as env } from "harness"; import { mkdir, writeFile } from "fs/promises"; import { join } from "path"; import { diff --git a/test/bun.js/install/bunx.test.ts b/test/cli/install/bunx.test.ts similarity index 98% rename from test/bun.js/install/bunx.test.ts rename to test/cli/install/bunx.test.ts index 06266fe948..49d6e1c2d5 100644 --- a/test/bun.js/install/bunx.test.ts +++ b/test/cli/install/bunx.test.ts @@ -1,7 +1,6 @@ import { spawn } from "bun"; import { afterEach, beforeEach, expect, it } from "bun:test"; -import { bunExe } from "bunExe"; -import { bunEnv as env } from "bunEnv"; +import { bunExe, bunEnv as env } from "harness"; import { realpathSync } from "fs"; import { mkdtemp, realpath, rm, writeFile } from "fs/promises"; import { tmpdir } from "os"; diff --git a/test/bun.js/install/dummy.registry.ts b/test/cli/install/dummy.registry.ts similarity index 100% rename from test/bun.js/install/dummy.registry.ts rename to test/cli/install/dummy.registry.ts diff --git a/test/bun.js/install/moo-0.1.0.tgz b/test/cli/install/moo-0.1.0.tgz similarity index 100% rename from test/bun.js/install/moo-0.1.0.tgz rename to test/cli/install/moo-0.1.0.tgz diff --git a/test/bun.js/log-test.test.ts b/test/cli/run/log-test.test.ts similarity index 95% rename from test/bun.js/log-test.test.ts rename to test/cli/run/log-test.test.ts index 29f541e322..2e980cb7b0 100644 --- a/test/bun.js/log-test.test.ts +++ b/test/cli/run/log-test.test.ts @@ -2,8 +2,7 @@ import { it, expect } from "bun:test"; import { basename, dirname, join } from "path"; import * as fs from "fs"; import { readableStreamToText, spawnSync } from "bun"; -import { bunExe } from "bunExe"; -import { bunEnv } from "bunEnv"; +import { bunExe, bunEnv } from "harness"; it("should not log .env when quiet", async () => { writeDirectoryTree("/tmp/log-test-silent", { diff --git a/test/bun.js/preload-test.test.js b/test/cli/run/preload-test.test.js similarity index 98% rename from test/bun.js/preload-test.test.js rename to test/cli/run/preload-test.test.js index 76603b3a0a..e0e068f9a0 100644 --- a/test/bun.js/preload-test.test.js +++ b/test/cli/run/preload-test.test.js @@ -3,8 +3,7 @@ import { describe, expect, test } from "bun:test"; import { mkdirSync, realpathSync } from "fs"; import { tmpdir } from "os"; import { join } from "path"; -import { bunEnv } from "./bunEnv"; -import { bunExe } from "./bunExe"; +import { bunEnv, bunExe } from "harness"; const preloadModule = ` import {plugin} from 'bun'; diff --git a/test/fixtures/bun-link-pkg-fixture/bun-link-pkg-fixture.js b/test/fixtures/bun-link-pkg-fixture/bun-link-pkg-fixture.js deleted file mode 100755 index ce5ae872bf..0000000000 --- a/test/fixtures/bun-link-pkg-fixture/bun-link-pkg-fixture.js +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env node - -// package.json name is bun-link-pkg-fixture-1 to ensure we don't rely on dir name -const _ = require("lodash"); - -if (_.isBoolean(true)) { - console.log("Success"); - process.exit(0); -} - -console.error("Fail"); -process.exit(1); diff --git a/test/fixtures/bun-link-pkg-fixture/bun.lockb b/test/fixtures/bun-link-pkg-fixture/bun.lockb deleted file mode 100755 index ff3a1483f2..0000000000 Binary files a/test/fixtures/bun-link-pkg-fixture/bun.lockb and /dev/null differ diff --git a/test/fixtures/bun-link-pkg-fixture/package-lock.json b/test/fixtures/bun-link-pkg-fixture/package-lock.json deleted file mode 100644 index 6296eb120a..0000000000 --- a/test/fixtures/bun-link-pkg-fixture/package-lock.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "bun-link-pkg-fixture-1", - "version": "0.0.0", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "name": "bun-link-pkg-fixture-1", - "version": "0.0.0", - "dependencies": { - "lodash": "4.17.21" - }, - "bin": { - "bun-link-pkg-fixture": "bun-link-pkg-fixture.js" - } - }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - } - }, - "dependencies": { - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - } - } -} diff --git a/test/fixtures/bun-link-pkg-fixture/package.json b/test/fixtures/bun-link-pkg-fixture/package.json deleted file mode 100644 index 6688478424..0000000000 --- a/test/fixtures/bun-link-pkg-fixture/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "bun-link-pkg-fixture-1", - "version": "0.0.0", - "dependencies": { - "lodash": "4.17.21" - }, - "main": "bun-link-pkg-fixture.js", - "bin": { - "bun-link-pkg-fixture": "bun-link-pkg-fixture.js" - } -} diff --git a/test/fixtures/bun-link-to-pkg-fixture/.gitignore b/test/fixtures/bun-link-to-pkg-fixture/.gitignore deleted file mode 100644 index f81d56eaa3..0000000000 --- a/test/fixtures/bun-link-to-pkg-fixture/.gitignore +++ /dev/null @@ -1,169 +0,0 @@ -# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore - -# Logs - -logs -_.log -npm-debug.log_ -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) - -report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json - -# Runtime data - -pids -_.pid -_.seed -\*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover - -lib-cov - -# Coverage directory used by tools like istanbul - -coverage -\*.lcov - -# nyc test coverage - -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) - -.grunt - -# Bower dependency directory (https://bower.io/) - -bower_components - -# node-waf configuration - -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) - -build/Release - -# Dependency directories - -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) - -web_modules/ - -# TypeScript cache - -\*.tsbuildinfo - -# Optional npm cache directory - -.npm - -# Optional eslint cache - -.eslintcache - -# Optional stylelint cache - -.stylelintcache - -# Microbundle cache - -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history - -.node_repl_history - -# Output of 'npm pack' - -\*.tgz - -# Yarn Integrity file - -.yarn-integrity - -# dotenv environment variable files - -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) - -.cache -.parcel-cache - -# Next.js build output - -.next -out - -# Nuxt.js build / generate output - -.nuxt -dist - -# Gatsby files - -.cache/ - -# Comment in the public line in if your project uses Gatsby and not Next.js - -# https://nextjs.org/blog/next-9-1#public-directory-support - -# public - -# vuepress build output - -.vuepress/dist - -# vuepress v2.x temp and cache directory - -.temp -.cache - -# Docusaurus cache and generated files - -.docusaurus - -# Serverless directories - -.serverless/ - -# FuseBox cache - -.fusebox/ - -# DynamoDB Local files - -.dynamodb/ - -# TernJS port file - -.tern-port - -# Stores VSCode versions used for testing VSCode extensions - -.vscode-test - -# yarn v2 - -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.\* diff --git a/test/fixtures/bun-link-to-pkg-fixture/README.md b/test/fixtures/bun-link-to-pkg-fixture/README.md deleted file mode 100644 index ac47fd7972..0000000000 --- a/test/fixtures/bun-link-to-pkg-fixture/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# bun-link-to-pkg-fixture - -To install dependencies: - -```bash -bun install -``` - -To run: - -```bash -bun run index.ts -``` - -This project was created using `bun init` in bun v0.1.7. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/test/fixtures/bun-link-to-pkg-fixture/bun.lockb b/test/fixtures/bun-link-to-pkg-fixture/bun.lockb deleted file mode 100755 index 1f6e25aa6a..0000000000 Binary files a/test/fixtures/bun-link-to-pkg-fixture/bun.lockb and /dev/null differ diff --git a/test/fixtures/bun-link-to-pkg-fixture/index.js b/test/fixtures/bun-link-to-pkg-fixture/index.js deleted file mode 100644 index 2a5e4b80cc..0000000000 --- a/test/fixtures/bun-link-to-pkg-fixture/index.js +++ /dev/null @@ -1 +0,0 @@ -console.log("Hello via Bun!"); diff --git a/test/fixtures/bun-link-to-pkg-fixture/package.json b/test/fixtures/bun-link-to-pkg-fixture/package.json deleted file mode 100644 index 952d8bb306..0000000000 --- a/test/fixtures/bun-link-to-pkg-fixture/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "bun-link-to-pkg-fixture", - "module": "index.js", - "type": "module", - "devDependencies": { - "bun-types": "^0.1.0" - }, - "dependencies": { - "bun-link-pkg-fixture": "link:bun-link-pkg-fixture-1", - "bun-link-pkg-fixture-1": "link:bun-link-pkg-fixture-1" - } -} \ No newline at end of file diff --git a/test/fixtures/bun-link-to-pkg-fixture/tsconfig.json b/test/fixtures/bun-link-to-pkg-fixture/tsconfig.json deleted file mode 100644 index feee4b5845..0000000000 --- a/test/fixtures/bun-link-to-pkg-fixture/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "lib": ["ESNext"], - "module": "esnext", - "target": "esnext", - "moduleResolution": "node", - - // so that if your project isn't using TypeScript, it still has autocomplete - "allowJs": true, - - // "bun-types" is the important part - "types": ["bun-types"] - } -} diff --git a/test/bun.js/gc.ts b/test/harness.ts similarity index 70% rename from test/bun.js/gc.ts rename to test/harness.ts index b9d80116df..486381cf29 100644 --- a/test/bun.js/gc.ts +++ b/test/harness.ts @@ -1,3 +1,14 @@ +export const bunEnv: any = { + ...process.env, + BUN_DEBUG_QUIET_LOGS: "1", + NO_COLOR: "1", + FORCE_COLOR: undefined, +}; + +export function bunExe() { + return process.execPath; +} + export function gc(force: boolean = true) { Bun.gc(force); } @@ -13,7 +24,7 @@ export function gcTick(trace = false) { }); } -export function withoutAggressiveGC(block) { +export function withoutAggressiveGC(block: () => unknown) { if (!Bun.unsafe.gcAggressionLevel) return block(); const origGC = Bun.unsafe.gcAggressionLevel(); diff --git a/test/bun.js/console/console-iterator-run.js b/test/js/bun/console/console-iterator-run.js similarity index 100% rename from test/bun.js/console/console-iterator-run.js rename to test/js/bun/console/console-iterator-run.js diff --git a/test/bun.js/console/console-iterator.test.js b/test/js/bun/console/console-iterator.test.js similarity index 98% rename from test/bun.js/console/console-iterator.test.js rename to test/js/bun/console/console-iterator.test.js index 053e4382d9..89894fd726 100644 --- a/test/bun.js/console/console-iterator.test.js +++ b/test/js/bun/console/console-iterator.test.js @@ -1,6 +1,6 @@ import { spawnSync, spawn } from "bun"; import { describe, expect, it } from "bun:test"; -import { bunExe } from "bunExe"; +import { bunExe } from "harness"; describe("should work for static input", () => { const inputs = [ diff --git a/test/bun.js/resolve-dns.test.ts b/test/js/bun/dns/resolve-dns.test.ts similarity index 93% rename from test/bun.js/resolve-dns.test.ts rename to test/js/bun/dns/resolve-dns.test.ts index d83e23b56f..52534da13d 100644 --- a/test/bun.js/resolve-dns.test.ts +++ b/test/js/bun/dns/resolve-dns.test.ts @@ -1,6 +1,6 @@ import { dns } from "bun"; import { describe, expect, it, test } from "bun:test"; -import { withoutAggressiveGC } from "gc"; +import { withoutAggressiveGC } from "harness"; describe("dns.lookup", () => { const backends = [process.platform === "darwin" ? "system" : undefined, "libc", "c-ares"].filter(Boolean); @@ -28,7 +28,7 @@ describe("dns.lookup", () => { const [first, second] = await dns.lookup("google.com", { backend }); console.log(first, second); }); - it(backend + " local", async () => { + it.skip(backend + " local", async () => { const [first, second] = await dns.lookup("localhost", { backend }); console.log(first, second); }); diff --git a/test/bun.js/ffi-test.c b/test/js/bun/ffi/ffi-test.c similarity index 100% rename from test/bun.js/ffi-test.c rename to test/js/bun/ffi/ffi-test.c diff --git a/test/bun.js/ffi.test.fixture.callback.c b/test/js/bun/ffi/ffi.test.fixture.callback.c similarity index 99% rename from test/bun.js/ffi.test.fixture.callback.c rename to test/js/bun/ffi/ffi.test.fixture.callback.c index 3b9a465777..624f6cdd01 100644 --- a/test/bun.js/ffi.test.fixture.callback.c +++ b/test/js/bun/ffi/ffi.test.fixture.callback.c @@ -286,9 +286,6 @@ ZIG_REPR_TYPE JSFunctionCall(void* jsGlobalObject, void* callFrame); bool my_callback_function(void* arg0); bool my_callback_function(void* arg0) { -#ifdef INJECT_BEFORE -INJECT_BEFORE; -#endif ZIG_REPR_TYPE arguments[1]; arguments[0] = PTR_TO_JSVALUE(arg0).asZigRepr; return (bool)JSVALUE_TO_BOOL(_FFI_Callback_call((void*)0x0000000000000000ULL, 1, arguments)); diff --git a/test/bun.js/ffi.test.fixture.receiver.c b/test/js/bun/ffi/ffi.test.fixture.receiver.c similarity index 100% rename from test/bun.js/ffi.test.fixture.receiver.c rename to test/js/bun/ffi/ffi.test.fixture.receiver.c diff --git a/test/bun.js/ffi.test.js b/test/js/bun/ffi/ffi.test.js similarity index 98% rename from test/bun.js/ffi.test.js rename to test/js/bun/ffi/ffi.test.js index 1027377829..8b31280c92 100644 --- a/test/bun.js/ffi.test.js +++ b/test/js/bun/ffi/ffi.test.js @@ -1,5 +1,5 @@ import { afterAll, describe, expect, it } from "bun:test"; -// +import { existsSync } from "fs"; import { CFunction, CString, @@ -20,6 +20,7 @@ const dlopen = (...args) => { throw err; } }; +const ok = existsSync("/tmp/bun-ffi-test.dylib"); it("ffi print", async () => { await Bun.write( @@ -607,7 +608,11 @@ it("read", () => { } }); -describe("run ffi", () => { - ffiRunner(false); - ffiRunner(true); -}); +if (ok) { + describe("run ffi", () => { + ffiRunner(false); + ffiRunner(true); + }); +} else { + it.skip("run ffi", () => {}); +} diff --git a/test/bun.js/globals.test.js b/test/js/bun/globals.test.js similarity index 100% rename from test/bun.js/globals.test.js rename to test/js/bun/globals.test.js diff --git a/test/bun.js/bun-server.test.ts b/test/js/bun/http/bun-server.test.ts similarity index 100% rename from test/bun.js/bun-server.test.ts rename to test/js/bun/http/bun-server.test.ts diff --git a/test/bun.js/fetch.js.txt b/test/js/bun/http/fetch.js.txt similarity index 100% rename from test/bun.js/fetch.js.txt rename to test/js/bun/http/fetch.js.txt diff --git a/test/bun.js/fixture.html.gz b/test/js/bun/http/fixture.html.gz similarity index 100% rename from test/bun.js/fixture.html.gz rename to test/js/bun/http/fixture.html.gz diff --git a/test/bun.js/proxy.test.js b/test/js/bun/http/proxy.test.js similarity index 98% rename from test/bun.js/proxy.test.js rename to test/js/bun/http/proxy.test.js index c903efab31..abe05133d5 100644 --- a/test/bun.js/proxy.test.js +++ b/test/js/bun/http/proxy.test.js @@ -1,5 +1,5 @@ import { afterAll, beforeAll, describe, expect, it } from "bun:test"; -import { gc } from "./gc"; +import { gc } from "harness"; let proxy, server; diff --git a/test/leaks/http-static-leak.ts b/test/js/bun/http/serve.leak.ts similarity index 100% rename from test/leaks/http-static-leak.ts rename to test/js/bun/http/serve.leak.ts diff --git a/test/bun.js/serve.test.ts b/test/js/bun/http/serve.test.ts similarity index 100% rename from test/bun.js/serve.test.ts rename to test/js/bun/http/serve.test.ts diff --git a/test/bun.js/bun-streams-test-fifo.sh b/test/js/bun/io/bun-streams-test-fifo.sh similarity index 100% rename from test/bun.js/bun-streams-test-fifo.sh rename to test/js/bun/io/bun-streams-test-fifo.sh diff --git a/test/bun.js/bun-write.test.js b/test/js/bun/io/bun-write.test.js similarity index 99% rename from test/bun.js/bun-write.test.js rename to test/js/bun/io/bun-write.test.js index c324d36a04..c3b9b187bb 100644 --- a/test/bun.js/bun-write.test.js +++ b/test/js/bun/io/bun-write.test.js @@ -1,7 +1,7 @@ import fs from "fs"; import { it, expect, describe } from "bun:test"; import path from "path"; -import { gcTick, withoutAggressiveGC } from "./gc"; +import { gcTick, withoutAggressiveGC } from "harness"; it("Bun.write blob", async () => { await Bun.write(Bun.file("/tmp/response-file.test.txt"), Bun.file(path.join(import.meta.dir, "fetch.js.txt"))); diff --git a/test/bun.js/emptyFile b/test/js/bun/io/emptyFile similarity index 100% rename from test/bun.js/emptyFile rename to test/js/bun/io/emptyFile diff --git a/test/js/bun/io/fetch.js.txt b/test/js/bun/io/fetch.js.txt new file mode 100644 index 0000000000..5a9b52fcf1 --- /dev/null +++ b/test/js/bun/io/fetch.js.txt @@ -0,0 +1,46 @@ + + + + Example Domain + + + + + + + + +
+

Example Domain

+

This domain is for use in illustrative examples in documents. You may use this + domain in literature without prior coordination or asking for permission.

+

More information...

+
+ + diff --git a/test/bun.js/bun-jsc.test.js b/test/js/bun/jsc/bun-jsc.test.js similarity index 100% rename from test/bun.js/bun-jsc.test.js rename to test/js/bun/jsc/bun-jsc.test.js diff --git a/test/bun.js/shadow.test.js b/test/js/bun/jsc/shadow.test.js similarity index 100% rename from test/bun.js/shadow.test.js rename to test/js/bun/jsc/shadow.test.js diff --git a/test/bun.js/socket/echo.js b/test/js/bun/net/echo.js similarity index 100% rename from test/bun.js/socket/echo.js rename to test/js/bun/net/echo.js diff --git a/test/bun.js/socket/socket.test.ts b/test/js/bun/net/socket.test.ts similarity index 98% rename from test/bun.js/socket/socket.test.ts rename to test/js/bun/net/socket.test.ts index 4c58243ef3..881175b242 100644 --- a/test/bun.js/socket/socket.test.ts +++ b/test/js/bun/net/socket.test.ts @@ -1,5 +1,5 @@ import { expect, it } from "bun:test"; -import { bunExe } from "../bunExe"; +import { bunExe } from "harness"; import { connect, spawn } from "bun"; it("should keep process alive only when active", async () => { diff --git a/test/bun.js/tcp-server.test.ts b/test/js/bun/net/tcp-server.test.ts similarity index 98% rename from test/bun.js/tcp-server.test.ts rename to test/js/bun/net/tcp-server.test.ts index 6f3f869ece..ba6927fe33 100644 --- a/test/bun.js/tcp-server.test.ts +++ b/test/js/bun/net/tcp-server.test.ts @@ -1,4 +1,4 @@ -import { listen, connect, TCPSocketListener, TCPSocketOptions, SocketHandler } from "bun"; +import { listen, connect, TCPSocketListener, SocketHandler } from "bun"; import { describe, expect, it } from "bun:test"; import * as JSC from "bun:jsc"; diff --git a/test/bun.js/hello.svelte b/test/js/bun/plugin/hello.svelte similarity index 100% rename from test/bun.js/hello.svelte rename to test/js/bun/plugin/hello.svelte diff --git a/test/bun.js/hello2.svelte b/test/js/bun/plugin/hello2.svelte similarity index 100% rename from test/bun.js/hello2.svelte rename to test/js/bun/plugin/hello2.svelte diff --git a/test/bun.js/plugins.d.ts b/test/js/bun/plugin/plugins.d.ts similarity index 100% rename from test/bun.js/plugins.d.ts rename to test/js/bun/plugin/plugins.d.ts diff --git a/test/bun.js/plugins.test.ts b/test/js/bun/plugin/plugins.test.ts similarity index 99% rename from test/bun.js/plugins.test.ts rename to test/js/bun/plugin/plugins.test.ts index e533cef064..2bac4b4d47 100644 --- a/test/bun.js/plugins.test.ts +++ b/test/js/bun/plugin/plugins.test.ts @@ -131,7 +131,7 @@ plugin({ }); // This is to test that it works when imported from a separate file -import "bun-loader-svelte"; +import "../../third_party/svelte"; describe("require", () => { it("SSRs `

Hello world!

` with Svelte", () => { diff --git a/test/bun.js/baz.js b/test/js/bun/resolve/baz.js similarity index 100% rename from test/bun.js/baz.js rename to test/js/bun/resolve/baz.js diff --git a/test/js/bun/resolve/file-importing-nonexistent-file.js b/test/js/bun/resolve/file-importing-nonexistent-file.js new file mode 100644 index 0000000000..f805e78bcd --- /dev/null +++ b/test/js/bun/resolve/file-importing-nonexistent-file.js @@ -0,0 +1 @@ +import "./does-not-exist.js.js.js.js"; diff --git a/test/bun.js/esm/first.mjs b/test/js/bun/resolve/first.mjs similarity index 100% rename from test/bun.js/esm/first.mjs rename to test/js/bun/resolve/first.mjs diff --git a/test/bun.js/import-meta.test.js b/test/js/bun/resolve/import-meta.test.js similarity index 92% rename from test/bun.js/import-meta.test.js rename to test/js/bun/resolve/import-meta.test.js index 3f89c09f0e..f87c8f89f5 100644 --- a/test/bun.js/import-meta.test.js +++ b/test/js/bun/resolve/import-meta.test.js @@ -1,7 +1,7 @@ import { it, expect } from "bun:test"; import { mkdirSync, rmSync, writeFileSync } from "node:fs"; import * as Module from "node:module"; -import sync from "./require-json.json"; +import sync from "./require-json.json.js"; const { path, dir } = import.meta; @@ -27,7 +27,7 @@ it("require with a query string works on dynamically created content", () => { try { const require = Module.createRequire("/tmp/bun-test-import-meta-dynamic-dir/foo.js"); try { - require("./bar.js?query=123"); + require("./bar.js?query=123.js"); } catch (e) { expect(e.name).toBe("ResolveError"); } @@ -36,7 +36,7 @@ it("require with a query string works on dynamically created content", () => { writeFileSync("/tmp/bun-test-import-meta-dynamic-dir/bar.js", "export default 'hello';", "utf8"); - expect(require("./bar.js?query=123").default).toBe("hello"); + expect(require("./bar.js?query=123.js").default).toBe("hello"); } catch (e) { throw e; } finally { @@ -50,7 +50,7 @@ it("require with a query string works on dynamically created content", () => { it("import.meta.require (json)", () => { expect(import.meta.require("./require-json.json").hello).toBe(sync.hello); const require = Module.createRequire(import.meta.path); - expect(require("./require-json.json").hello).toBe(sync.hello); + expect(require("./require-json.json.js").hello).toBe(sync.hello); }); it("const f = require;require(json)", () => { @@ -148,11 +148,11 @@ it("import.meta.require (javascript, live bindings)", () => { }); it("import.meta.dir", () => { - expect(dir.endsWith("/bun/test/bun.js")).toBe(true); + expect(dir.endsWith("/bun/test/js/bun/resolve")).toBe(true); }); it("import.meta.path", () => { - expect(path.endsWith("/bun/test/bun.js/import-meta.test.js")).toBe(true); + expect(path.endsWith("/bun/test/js/bun/resolve/import-meta.test.js")).toBe(true); }); it('require("bun") works', () => { diff --git a/test/bun.js/import-require-tla.js b/test/js/bun/resolve/import-require-tla.js similarity index 100% rename from test/bun.js/import-require-tla.js rename to test/js/bun/resolve/import-require-tla.js diff --git a/test/bun.js/import.live.decl.js b/test/js/bun/resolve/import.live.decl.js similarity index 100% rename from test/bun.js/import.live.decl.js rename to test/js/bun/resolve/import.live.decl.js diff --git a/test/bun.js/import.live.rexport-require.js b/test/js/bun/resolve/import.live.rexport-require.js similarity index 100% rename from test/bun.js/import.live.rexport-require.js rename to test/js/bun/resolve/import.live.rexport-require.js diff --git a/test/js/bun/resolve/import.live.rexport.js b/test/js/bun/resolve/import.live.rexport.js new file mode 100644 index 0000000000..6709c34660 --- /dev/null +++ b/test/js/bun/resolve/import.live.rexport.js @@ -0,0 +1,2 @@ +export { foo, setFoo } from "./import.live.decl.js"; +import { foo as bar } from "./import.live.decl.js"; diff --git a/test/bun.js/test-png-import.test.js b/test/js/bun/resolve/png/test-png-import.test.js similarity index 100% rename from test/bun.js/test-png-import.test.js rename to test/js/bun/resolve/png/test-png-import.test.js diff --git a/test/bun.js/test-png.png b/test/js/bun/resolve/png/test-png.png similarity index 100% rename from test/bun.js/test-png.png rename to test/js/bun/resolve/png/test-png.png diff --git a/test/bun.js/require-js-top-level-await.js b/test/js/bun/resolve/require-js-top-level-await.js similarity index 100% rename from test/bun.js/require-js-top-level-await.js rename to test/js/bun/resolve/require-js-top-level-await.js diff --git a/test/bun.js/require-js.js b/test/js/bun/resolve/require-js.js similarity index 100% rename from test/bun.js/require-js.js rename to test/js/bun/resolve/require-js.js diff --git a/test/bun.js/require-js2.js b/test/js/bun/resolve/require-js2.js similarity index 100% rename from test/bun.js/require-js2.js rename to test/js/bun/resolve/require-js2.js diff --git a/test/bun.js/require-json.json b/test/js/bun/resolve/require-json.json similarity index 100% rename from test/bun.js/require-json.json rename to test/js/bun/resolve/require-json.json diff --git a/test/bun.js/require-referenceerror.snapshot.js b/test/js/bun/resolve/require-referenceerror.snapshot.js similarity index 100% rename from test/bun.js/require-referenceerror.snapshot.js rename to test/js/bun/resolve/require-referenceerror.snapshot.js diff --git a/test/bun.js/resolve-error.test.ts b/test/js/bun/resolve/resolve-error.test.ts similarity index 100% rename from test/bun.js/resolve-error.test.ts rename to test/js/bun/resolve/resolve-error.test.ts diff --git a/test/bun.js/resolve-typescript-file.tsx b/test/js/bun/resolve/resolve-typescript-file.tsx similarity index 100% rename from test/bun.js/resolve-typescript-file.tsx rename to test/js/bun/resolve/resolve-typescript-file.tsx diff --git a/test/bun.js/resolve.test.js b/test/js/bun/resolve/resolve.test.js similarity index 100% rename from test/bun.js/resolve.test.js rename to test/js/bun/resolve/resolve.test.js diff --git a/test/bun.js/esm/second-child.mjs b/test/js/bun/resolve/second-child.mjs similarity index 100% rename from test/bun.js/esm/second-child.mjs rename to test/js/bun/resolve/second-child.mjs diff --git a/test/bun.js/esm/second.mjs b/test/js/bun/resolve/second.mjs similarity index 100% rename from test/bun.js/esm/second.mjs rename to test/js/bun/resolve/second.mjs diff --git a/test/bun.js/esm/startEnd.mjs b/test/js/bun/resolve/startEnd.mjs similarity index 100% rename from test/bun.js/esm/startEnd.mjs rename to test/js/bun/resolve/startEnd.mjs diff --git a/test/bun.js/esm/third.mjs b/test/js/bun/resolve/third.mjs similarity index 100% rename from test/bun.js/esm/third.mjs rename to test/js/bun/resolve/third.mjs diff --git a/test/bun.js/toml-fixture.toml b/test/js/bun/resolve/toml/toml-fixture.toml similarity index 100% rename from test/bun.js/toml-fixture.toml rename to test/js/bun/resolve/toml/toml-fixture.toml diff --git a/test/bun.js/toml.test.js b/test/js/bun/resolve/toml/toml.test.js similarity index 97% rename from test/bun.js/toml.test.js rename to test/js/bun/resolve/toml/toml.test.js index a1aa09a4c6..17d1674761 100644 --- a/test/bun.js/toml.test.js +++ b/test/js/bun/resolve/toml/toml.test.js @@ -1,5 +1,5 @@ import { describe, it, expect } from "bun:test"; -import { gc } from "./gc"; +import { gc } from "harness"; it("syntax", async () => { gc(); diff --git a/test/bun.js/bash-echo.sh b/test/js/bun/spawn/bash-echo.sh similarity index 100% rename from test/bun.js/bash-echo.sh rename to test/js/bun/spawn/bash-echo.sh diff --git a/test/bun.js/bun-spawn-test.js b/test/js/bun/spawn/bun-spawn-test.js similarity index 100% rename from test/bun.js/bun-spawn-test.js rename to test/js/bun/spawn/bun-spawn-test.js diff --git a/test/bun.js/exit-code-0.js b/test/js/bun/spawn/exit-code-0.js similarity index 100% rename from test/bun.js/exit-code-0.js rename to test/js/bun/spawn/exit-code-0.js diff --git a/test/bun.js/exit-code-1.js b/test/js/bun/spawn/exit-code-1.js similarity index 100% rename from test/bun.js/exit-code-1.js rename to test/js/bun/spawn/exit-code-1.js diff --git a/test/bun.js/exit-code-await-throw-1.js b/test/js/bun/spawn/exit-code-await-throw-1.js similarity index 100% rename from test/bun.js/exit-code-await-throw-1.js rename to test/js/bun/spawn/exit-code-await-throw-1.js diff --git a/test/bun.js/exit-code-unhandled-throw.js b/test/js/bun/spawn/exit-code-unhandled-throw.js similarity index 100% rename from test/bun.js/exit-code-unhandled-throw.js rename to test/js/bun/spawn/exit-code-unhandled-throw.js diff --git a/test/bun.js/exit-code.test.ts b/test/js/bun/spawn/exit-code.test.ts similarity index 95% rename from test/bun.js/exit-code.test.ts rename to test/js/bun/spawn/exit-code.test.ts index 5f1aab9043..cda76a395f 100644 --- a/test/bun.js/exit-code.test.ts +++ b/test/js/bun/spawn/exit-code.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it, test } from "bun:test"; -import { bunExe } from "bunExe"; +import { bunExe } from "harness"; import { spawnSync } from "bun"; it("process.exit(1) works", () => { diff --git a/test/bun.js/exit.js b/test/js/bun/spawn/exit.js similarity index 100% rename from test/bun.js/exit.js rename to test/js/bun/spawn/exit.js diff --git a/test/bun.js/spawn-streaming-stdin.test.ts b/test/js/bun/spawn/spawn-streaming-stdin.test.ts similarity index 93% rename from test/bun.js/spawn-streaming-stdin.test.ts rename to test/js/bun/spawn/spawn-streaming-stdin.test.ts index 02067b7193..e2d346ec84 100644 --- a/test/bun.js/spawn-streaming-stdin.test.ts +++ b/test/js/bun/spawn/spawn-streaming-stdin.test.ts @@ -1,9 +1,7 @@ import { it, test, expect } from "bun:test"; import { spawn } from "bun"; -import { bunExe } from "./bunExe"; -import { gcTick } from "gc"; +import { bunExe, bunEnv, gcTick } from "harness"; import { closeSync, openSync } from "fs"; -import { bunEnv } from "./bunEnv"; const N = 100; test("spawn can write to stdin multiple chunks", async () => { diff --git a/test/bun.js/spawn-streaming-stdout-repro.js b/test/js/bun/spawn/spawn-streaming-stdout-repro.js similarity index 100% rename from test/bun.js/spawn-streaming-stdout-repro.js rename to test/js/bun/spawn/spawn-streaming-stdout-repro.js diff --git a/test/bun.js/spawn-streaming-stdout.test.ts b/test/js/bun/spawn/spawn-streaming-stdout.test.ts similarity index 92% rename from test/bun.js/spawn-streaming-stdout.test.ts rename to test/js/bun/spawn/spawn-streaming-stdout.test.ts index bda1031add..75e36ca2c3 100644 --- a/test/bun.js/spawn-streaming-stdout.test.ts +++ b/test/js/bun/spawn/spawn-streaming-stdout.test.ts @@ -1,9 +1,7 @@ import { it, test, expect } from "bun:test"; import { spawn } from "bun"; -import { bunExe } from "./bunExe"; -import { gcTick } from "gc"; +import { bunExe, bunEnv, gcTick } from "harness"; import { closeSync, openSync } from "fs"; -import { bunEnv } from "./bunEnv"; test("spawn can read from stdout multiple chunks", async () => { gcTick(true); diff --git a/test/bun.js/spawn.test.ts b/test/js/bun/spawn/spawn.test.ts similarity index 99% rename from test/bun.js/spawn.test.ts rename to test/js/bun/spawn/spawn.test.ts index def0330ee2..876985e665 100644 --- a/test/bun.js/spawn.test.ts +++ b/test/js/bun/spawn/spawn.test.ts @@ -1,8 +1,7 @@ import { ArrayBufferSink, readableStreamToText, spawn, spawnSync, write } from "bun"; import { describe, expect, it } from "bun:test"; -import { gcTick as _gcTick } from "./gc"; +import { gcTick as _gcTick, bunEnv } from "harness"; import { rmdirSync, unlinkSync, rmSync, writeFileSync } from "node:fs"; -import { bunEnv } from "./bunEnv"; for (let [gcTick, label] of [ [_gcTick, "gcTick"], diff --git a/test/bun.js/stdin-repro.js b/test/js/bun/spawn/stdin-repro.js similarity index 100% rename from test/bun.js/stdin-repro.js rename to test/js/bun/spawn/stdin-repro.js diff --git a/test/bun.js/stdio-test-instance-a-lot.js b/test/js/bun/spawn/stdio-test-instance-a-lot.js similarity index 100% rename from test/bun.js/stdio-test-instance-a-lot.js rename to test/js/bun/spawn/stdio-test-instance-a-lot.js diff --git a/test/bun.js/stdio-test-instance.js b/test/js/bun/spawn/stdio-test-instance.js similarity index 100% rename from test/bun.js/stdio-test-instance.js rename to test/js/bun/spawn/stdio-test-instance.js diff --git a/test/bun.js/northwind.testdb b/test/js/bun/sqlite/northwind.testdb similarity index 100% rename from test/bun.js/northwind.testdb rename to test/js/bun/sqlite/northwind.testdb diff --git a/test/bun.js/sql-raw.test.js b/test/js/bun/sqlite/sql-raw.test.js similarity index 100% rename from test/bun.js/sql-raw.test.js rename to test/js/bun/sqlite/sql-raw.test.js diff --git a/test/bun.js/sqlite-cross-process.js b/test/js/bun/sqlite/sqlite-cross-process.js similarity index 100% rename from test/bun.js/sqlite-cross-process.js rename to test/js/bun/sqlite/sqlite-cross-process.js diff --git a/test/bun.js/sqlite.test.js b/test/js/bun/sqlite/sqlite.test.js similarity index 99% rename from test/bun.js/sqlite.test.js rename to test/js/bun/sqlite/sqlite.test.js index 408fa5a26b..a23c2f0378 100644 --- a/test/bun.js/sqlite.test.js +++ b/test/js/bun/sqlite/sqlite.test.js @@ -2,7 +2,7 @@ import { expect, it, describe } from "bun:test"; import { Database, constants } from "bun:sqlite"; import { existsSync, fstat, realpathSync, rmSync, writeFileSync } from "fs"; import { spawnSync } from "bun"; -import { bunExe } from "bunExe"; +import { bunExe } from "harness"; import { tmpdir } from "os"; var encode = text => new TextEncoder().encode(text); diff --git a/test/bun.js/bigint.test.js b/test/js/bun/test/bigint.test.js similarity index 100% rename from test/bun.js/bigint.test.js rename to test/js/bun/test/bigint.test.js diff --git a/test/bun.js/bun-test.test.ts b/test/js/bun/test/bun-test.test.ts similarity index 100% rename from test/bun.js/bun-test.test.ts rename to test/js/bun/test/bun-test.test.ts diff --git a/test/bun.js/jest-doesnt-auto-import.js b/test/js/bun/test/jest-doesnt-auto-import.js similarity index 100% rename from test/bun.js/jest-doesnt-auto-import.js rename to test/js/bun/test/jest-doesnt-auto-import.js diff --git a/test/bun.js/bun-test/jest-hooks.test.ts b/test/js/bun/test/jest-hooks.test.ts similarity index 100% rename from test/bun.js/bun-test/jest-hooks.test.ts rename to test/js/bun/test/jest-hooks.test.ts diff --git a/test/bun.js/bun-test/nested-describes.test.ts b/test/js/bun/test/nested-describes.test.ts similarity index 100% rename from test/bun.js/bun-test/nested-describes.test.ts rename to test/js/bun/test/nested-describes.test.ts diff --git a/test/bun.js/test-auto-import-jest-globals.test.js b/test/js/bun/test/test-auto-import-jest-globals.test.js similarity index 100% rename from test/bun.js/test-auto-import-jest-globals.test.js rename to test/js/bun/test/test-auto-import-jest-globals.test.js diff --git a/test/bun.js/test-test.test.ts b/test/js/bun/test/test-test.test.ts similarity index 99% rename from test/bun.js/test-test.test.ts rename to test/js/bun/test/test-test.test.ts index c83ee07a53..b834d2152b 100644 --- a/test/bun.js/test-test.test.ts +++ b/test/js/bun/test/test-test.test.ts @@ -1,7 +1,6 @@ import { spawn, spawnSync } from "bun"; import { describe, expect, it, test } from "bun:test"; -import { bunEnv } from "bunEnv"; -import { bunExe } from "bunExe"; +import { bunExe, bunEnv } from "harness"; import { mkdirSync, realpathSync, rmSync, writeFileSync } from "fs"; import { mkdtemp, rm, writeFile } from "fs/promises"; import { tmpdir } from "os"; diff --git a/test/bun.js/arraybuffersink.test.ts b/test/js/bun/util/arraybuffersink.test.ts similarity index 98% rename from test/bun.js/arraybuffersink.test.ts rename to test/js/bun/util/arraybuffersink.test.ts index f0df03d900..373ac11165 100644 --- a/test/bun.js/arraybuffersink.test.ts +++ b/test/js/bun/util/arraybuffersink.test.ts @@ -1,6 +1,6 @@ import { ArrayBufferSink } from "bun"; import { describe, expect, it } from "bun:test"; -import { withoutAggressiveGC } from "gc"; +import { withoutAggressiveGC } from "harness"; describe("ArrayBufferSink", () => { const fixtures = [ diff --git a/test/bun.js/concat.test.js b/test/js/bun/util/concat.test.js similarity index 97% rename from test/bun.js/concat.test.js rename to test/js/bun/util/concat.test.js index 36421cab62..0cea303fe9 100644 --- a/test/bun.js/concat.test.js +++ b/test/js/bun/util/concat.test.js @@ -1,5 +1,4 @@ import { describe, it, expect } from "bun:test"; -import { gcTick } from "./gc"; import { concatArrayBuffers } from "bun"; describe("concat", () => { diff --git a/test/bun.js/empty.js b/test/js/bun/util/empty.js similarity index 100% rename from test/bun.js/empty.js rename to test/js/bun/util/empty.js diff --git a/test/bun.js/escapeHTML.test.js b/test/js/bun/util/escapeHTML.test.js similarity index 99% rename from test/bun.js/escapeHTML.test.js rename to test/js/bun/util/escapeHTML.test.js index f96849a843..bdddf4a45d 100644 --- a/test/bun.js/escapeHTML.test.js +++ b/test/js/bun/util/escapeHTML.test.js @@ -1,5 +1,4 @@ import { describe, it, expect } from "bun:test"; -import { gcTick } from "./gc"; import { escapeHTML } from "bun"; describe("escapeHTML", () => { diff --git a/test/bun.js/fileUrl.test.js b/test/js/bun/util/fileUrl.test.js similarity index 100% rename from test/bun.js/fileUrl.test.js rename to test/js/bun/util/fileUrl.test.js diff --git a/test/bun.js/filesink.test.ts b/test/js/bun/util/filesink.test.ts similarity index 100% rename from test/bun.js/filesink.test.ts rename to test/js/bun/util/filesink.test.ts diff --git a/test/bun.js/filesystem_router.test.ts b/test/js/bun/util/filesystem_router.test.ts similarity index 100% rename from test/bun.js/filesystem_router.test.ts rename to test/js/bun/util/filesystem_router.test.ts diff --git a/test/bun.js/hash.test.js b/test/js/bun/util/hash.test.js similarity index 97% rename from test/bun.js/hash.test.js rename to test/js/bun/util/hash.test.js index 0c1baaf14a..87a5a9ce32 100644 --- a/test/bun.js/hash.test.js +++ b/test/js/bun/util/hash.test.js @@ -1,7 +1,7 @@ import fs from "fs"; import { it, expect } from "bun:test"; import path from "path"; -import { gcTick } from "gc"; +import { gcTick } from "harness"; it(`Bun.hash()`, () => { gcTick(); diff --git a/test/bun.js/index-of-line.test.ts b/test/js/bun/util/index-of-line.test.ts similarity index 100% rename from test/bun.js/index-of-line.test.ts rename to test/js/bun/util/index-of-line.test.ts diff --git a/test/bun.js/inspect.test.js b/test/js/bun/util/inspect.test.js similarity index 99% rename from test/bun.js/inspect.test.js rename to test/js/bun/util/inspect.test.js index 024a976a3d..ec2fb0b45c 100644 --- a/test/bun.js/inspect.test.js +++ b/test/js/bun/util/inspect.test.js @@ -278,7 +278,7 @@ const fixture = [ return new (import.meta.require("events").EventEmitter)(); }, async () => await import("node:assert"), - async () => await import("./empty.js"), + async () => await import("../../empty.js.js"), () => import.meta.require("./empty.js"), () => new Proxy({ yolo: 1 }, {}), () => diff --git a/test/bun.js/mmap.test.js b/test/js/bun/util/mmap.test.js similarity index 97% rename from test/bun.js/mmap.test.js rename to test/js/bun/util/mmap.test.js index 2b15a4000f..4972359da5 100644 --- a/test/bun.js/mmap.test.js +++ b/test/js/bun/util/mmap.test.js @@ -1,5 +1,5 @@ import { describe, it, expect } from "bun:test"; -import { gcTick } from "./gc"; +import { gcTick } from "harness"; describe("Bun.mmap", async () => { await gcTick(); diff --git a/test/bun.js/peek.test.ts b/test/js/bun/util/peek.test.ts similarity index 100% rename from test/bun.js/peek.test.ts rename to test/js/bun/util/peek.test.ts diff --git a/test/bun.js/reportError.test.js b/test/js/bun/util/reportError.test.js similarity index 100% rename from test/bun.js/reportError.test.js rename to test/js/bun/util/reportError.test.js diff --git a/test/bun.js/sleep.js b/test/js/bun/util/sleep.js similarity index 100% rename from test/bun.js/sleep.js rename to test/js/bun/util/sleep.js diff --git a/test/bun.js/sleepSync.test.ts b/test/js/bun/util/sleepSync.test.ts similarity index 100% rename from test/bun.js/sleepSync.test.ts rename to test/js/bun/util/sleepSync.test.ts diff --git a/test/bun.js/unsafe.test.js b/test/js/bun/util/unsafe.test.js similarity index 97% rename from test/bun.js/unsafe.test.js rename to test/js/bun/util/unsafe.test.js index 8ce7598db8..38830fa36d 100644 --- a/test/bun.js/unsafe.test.js +++ b/test/js/bun/util/unsafe.test.js @@ -1,5 +1,5 @@ import { test, expect, it, describe } from "bun:test"; -import { gc } from "./gc"; +import { gc } from "harness"; it("arrayBufferToString u8", async () => { var encoder = new TextEncoder(); diff --git a/test/bun.js/which.test.ts b/test/js/bun/util/which.test.ts similarity index 100% rename from test/bun.js/which.test.ts rename to test/js/bun/util/which.test.ts diff --git a/test/bun.js/hello-wasi.wasm b/test/js/bun/wasm/hello-wasi.wasm similarity index 100% rename from test/bun.js/hello-wasi.wasm rename to test/js/bun/wasm/hello-wasi.wasm diff --git a/test/bun.js/wasi.test.js b/test/js/bun/wasm/wasi.test.js similarity index 84% rename from test/bun.js/wasi.test.js rename to test/js/bun/wasm/wasi.test.js index f6d8e76f5f..ac1d986d46 100644 --- a/test/bun.js/wasi.test.js +++ b/test/js/bun/wasm/wasi.test.js @@ -1,7 +1,6 @@ import { spawnSync } from "bun"; import { expect, it } from "bun:test"; -import { bunEnv } from "bunEnv"; -import { bunExe } from "bunExe"; +import { bunExe, bunEnv } from "harness"; it("Should support printing 'hello world'", () => { const { stdout, exitCode } = spawnSync({ diff --git a/test/bun.js/wasm-return-1-test.zig b/test/js/bun/wasm/wasm-return-1-test.zig similarity index 100% rename from test/bun.js/wasm-return-1-test.zig rename to test/js/bun/wasm/wasm-return-1-test.zig diff --git a/test/bun.js/wasm.js b/test/js/bun/wasm/wasm.js similarity index 100% rename from test/bun.js/wasm.js rename to test/js/bun/wasm/wasm.js diff --git a/test/bun.js/websocket-server.test.ts b/test/js/bun/websocket/websocket-server.test.ts similarity index 97% rename from test/bun.js/websocket-server.test.ts rename to test/js/bun/websocket/websocket-server.test.ts index 3205ff9490..b3b2e57b50 100644 --- a/test/bun.js/websocket-server.test.ts +++ b/test/js/bun/websocket/websocket-server.test.ts @@ -1,20 +1,11 @@ import { describe, expect, it } from "bun:test"; -import { gcTick } from "./gc"; +import { gcTick } from "harness"; import { serve } from "bun"; -var port = 4301; -function getPort() { - if (port > 4444) { - port = 4321; - } - - return port++; -} - describe("websocket server", () => { it("can do publish()", async done => { var server = serve({ - port: getPort(), + port: 0, websocket: { open(ws) { ws.subscribe("all"); @@ -51,7 +42,7 @@ describe("websocket server", () => { it("can do publish() with publishToSelf: false", async done => { var server = serve({ - port: getPort(), + port: 0, websocket: { open(ws) { ws.subscribe("all"); @@ -92,7 +83,7 @@ describe("websocket server", () => { it("in close() should work", async () => { var count = 0; var server = serve({ - port: getPort(), + port: 0, websocket: { open(ws) { ws.subscribe("all"); @@ -152,7 +143,7 @@ describe("websocket server", () => { var resolve; console.trace("here"); var server = serve({ - port: getPort(), + port: 0, websocket: { open(ws) {}, message(ws, msg) {}, @@ -196,7 +187,7 @@ describe("websocket server", () => { it("headers error doesn't crash", async () => { await new Promise((resolve, reject) => { const server = serve({ - port: getPort(), + port: 0, websocket: { open(ws) { ws.close(); @@ -236,7 +227,7 @@ describe("websocket server", () => { }); it("can do hello world", async () => { const server = serve({ - port: getPort(), + port: 0, websocket: { open(ws) { server.stop(); @@ -290,7 +281,7 @@ describe("websocket server", () => { it("fetch() allows a Response object to be returned for an upgraded ServerWebSocket", () => { const server = serve({ - port: getPort(), + port: 0, websocket: { open(ws) { server.stop(); @@ -349,7 +340,7 @@ describe("websocket server", () => { it("fetch() allows a Promise object to be returned for an upgraded ServerWebSocket", () => { const server = serve({ - port: getPort(), + port: 0, websocket: { async open(ws) { server.stop(); @@ -409,7 +400,7 @@ describe("websocket server", () => { it("binaryType works", async () => { var done = false; const server = serve({ - port: getPort(), + port: 0, websocket: { open(ws) { server.stop(); @@ -471,7 +462,7 @@ describe("websocket server", () => { it("does not upgrade for non-websocket connections", async () => { await new Promise(async (resolve, reject) => { var server = serve({ - port: getPort(), + port: 0, websocket: { open(ws) { ws.send("hello world"); @@ -497,7 +488,7 @@ describe("websocket server", () => { it("does not upgrade for non-websocket servers", async () => { await new Promise(async (resolve, reject) => { const server = serve({ - port: getPort(), + port: 0, fetch(req, server) { server.stop(); expect(() => { @@ -515,7 +506,7 @@ describe("websocket server", () => { it("async can do hello world", async () => { const server = serve({ - port: getPort(), + port: 0, websocket: { async open(ws) { server.stop(true); @@ -555,7 +546,7 @@ describe("websocket server", () => { await new Promise((resolve, reject) => { var websocket; var server = serve({ - port: getPort(), + port: 0, websocket: { async open(ws) { // we don't care about the data @@ -585,7 +576,7 @@ describe("websocket server", () => { await new Promise((resolve, reject) => { var websocket; var server = serve({ - port: getPort(), + port: 0, websocket: { async open(ws) { // we don't care about the data @@ -613,7 +604,7 @@ describe("websocket server", () => { await new Promise((resolve, reject) => { var websocket; var server = serve({ - port: getPort(), + port: 0, websocket: { async open(ws) { // we don't care about the data @@ -641,7 +632,7 @@ describe("websocket server", () => { await new Promise((resolve, reject) => { var websocket; var server = serve({ - port: getPort(), + port: 0, websocket: { async open(ws) { // we don't care about the data @@ -667,7 +658,7 @@ describe("websocket server", () => { it("can do hello world corked", async () => { const server = serve({ - port: getPort(), + port: 0, websocket: { open(ws) { server.stop(); @@ -709,7 +700,7 @@ describe("websocket server", () => { it("can do some back and forth", async () => { var dataCount = 0; const server = serve({ - port: getPort(), + port: 0, websocket: { open(ws) { server.stop(); @@ -785,7 +776,7 @@ describe("websocket server", () => { var clientCounter = 0; const server = serve({ - port: getPort(), + port: 0, websocket: { open(ws) { server.stop(); @@ -846,7 +837,7 @@ describe("websocket server", () => { var serverCounter = 0; var clientCount = 0; const server = serve({ - port: getPort(), + port: 0, websocket: { open(ws) { server.stop(); diff --git a/test/bun.js/undici.test.ts b/test/js/first_party/undici/undici.test.ts similarity index 100% rename from test/bun.js/undici.test.ts rename to test/js/first_party/undici/undici.test.ts diff --git a/test/bun.js/assert-test.test.ts b/test/js/node/assert/assert-test.test.ts similarity index 100% rename from test/bun.js/assert-test.test.ts rename to test/js/node/assert/assert-test.test.ts diff --git a/test/bun.js/buffer.test.js b/test/js/node/buffer.test.js similarity index 99% rename from test/bun.js/buffer.test.js rename to test/js/node/buffer.test.js index b8fade4d23..568bf8d445 100644 --- a/test/bun.js/buffer.test.js +++ b/test/js/node/buffer.test.js @@ -1,5 +1,5 @@ import { describe, it, expect, beforeEach, afterEach, test } from "bun:test"; -import { gc } from "./gc"; +import { gc } from "harness"; const BufferModule = await import("buffer"); diff --git a/test/bun.js/child-process-stdio.test.js b/test/js/node/child_process/child-process-stdio.test.js similarity index 97% rename from test/bun.js/child-process-stdio.test.js rename to test/js/node/child_process/child-process-stdio.test.js index 43bcc771ac..d0c6d9bc75 100644 --- a/test/bun.js/child-process-stdio.test.js +++ b/test/js/node/child_process/child-process-stdio.test.js @@ -1,7 +1,6 @@ import { describe, it, expect, beforeAll } from "bun:test"; import { spawn, execSync } from "node:child_process"; -import { bunExe } from "bunExe"; -import { bunEnv } from "bunEnv"; +import { bunExe, bunEnv } from "harness"; const CHILD_PROCESS_FILE = import.meta.dir + "/spawned-child.js"; const OUT_FILE = import.meta.dir + "/stdio-test-out.txt"; diff --git a/test/bun.js/child_process-node.test.js b/test/js/node/child_process/child_process-node.test.js similarity index 99% rename from test/bun.js/child_process-node.test.js rename to test/js/node/child_process/child_process-node.test.js index f2c18c67ce..deb3bfb868 100644 --- a/test/bun.js/child_process-node.test.js +++ b/test/js/node/child_process/child_process-node.test.js @@ -1,8 +1,7 @@ import { beforeAll, describe, expect, it } from "bun:test"; import { ChildProcess, spawn, exec } from "node:child_process"; -import { throws, assert, createCallCheckCtx, createDoneDotAll } from "node-test-helpers"; +import { throws, assert, createCallCheckCtx, createDoneDotAll } from "node-harness"; import { tmpdir } from "node:os"; -import { gcTick } from "gc"; const strictEqual = (a, b) => expect(a).toStrictEqual(b); const debug = process.env.DEBUG ? console.log : () => {}; diff --git a/test/bun.js/child_process.test.ts b/test/js/node/child_process/child_process.test.ts similarity index 99% rename from test/bun.js/child_process.test.ts rename to test/js/node/child_process/child_process.test.ts index 7f2c6b383f..167cbd8b06 100644 --- a/test/bun.js/child_process.test.ts +++ b/test/js/node/child_process/child_process.test.ts @@ -1,5 +1,5 @@ import { describe, it as it_, expect as expect_ } from "bun:test"; -import { gcTick } from "gc"; +import { gcTick } from "harness"; import { ChildProcess, spawn, execFile, exec, fork, spawnSync, execFileSync, execSync } from "node:child_process"; import { tmpdir } from "node:os"; import { promisify } from "node:util"; diff --git a/test/bun.js/readFileSync.txt b/test/js/node/child_process/readFileSync.txt similarity index 100% rename from test/bun.js/readFileSync.txt rename to test/js/node/child_process/readFileSync.txt diff --git a/test/bun.js/spawned-child.js b/test/js/node/child_process/spawned-child.js similarity index 100% rename from test/bun.js/spawned-child.js rename to test/js/node/child_process/spawned-child.js diff --git a/test/bun.js/crypto-scrypt.test.js b/test/js/node/crypto/crypto-scrypt.test.js similarity index 100% rename from test/bun.js/crypto-scrypt.test.js rename to test/js/node/crypto/crypto-scrypt.test.js diff --git a/test/bun.js/crypto.test.js b/test/js/node/crypto/crypto.test.js similarity index 100% rename from test/bun.js/crypto.test.js rename to test/js/node/crypto/crypto.test.js diff --git a/test/bun.js/node-crypto.test.js b/test/js/node/crypto/node-crypto.test.js similarity index 100% rename from test/bun.js/node-crypto.test.js rename to test/js/node/crypto/node-crypto.test.js diff --git a/test/bun.js/dirname.test.js b/test/js/node/dirname.test.js similarity index 100% rename from test/bun.js/dirname.test.js rename to test/js/node/dirname.test.js diff --git a/test/bun.js/disabled-module.test.js b/test/js/node/disabled-module.test.js similarity index 100% rename from test/bun.js/disabled-module.test.js rename to test/js/node/disabled-module.test.js diff --git a/test/bun.js/dns.node.mjs b/test/js/node/dns/dns.node.mjs similarity index 100% rename from test/bun.js/dns.node.mjs rename to test/js/node/dns/dns.node.mjs diff --git a/test/bun.js/node-dns.test.js b/test/js/node/dns/node-dns.test.js similarity index 100% rename from test/bun.js/node-dns.test.js rename to test/js/node/dns/node-dns.test.js diff --git a/test/bun.js/event-emitter.test.ts b/test/js/node/events/event-emitter.test.ts similarity index 100% rename from test/bun.js/event-emitter.test.ts rename to test/js/node/events/event-emitter.test.ts diff --git a/test/bun.js/node-builtins.test.js b/test/js/node/events/node-builtins.test.js similarity index 100% rename from test/bun.js/node-builtins.test.js rename to test/js/node/events/node-builtins.test.js diff --git a/test/fixtures/export-lazy-fs-streams/export-*-from.ts b/test/js/node/fs/export-*-from.ts similarity index 100% rename from test/fixtures/export-lazy-fs-streams/export-*-from.ts rename to test/js/node/fs/export-*-from.ts diff --git a/test/fixtures/export-lazy-fs-streams/export-from.ts b/test/js/node/fs/export-from.ts similarity index 100% rename from test/fixtures/export-lazy-fs-streams/export-from.ts rename to test/js/node/fs/export-from.ts diff --git a/test/bun.js/fs-stream.js b/test/js/node/fs/fs-stream.js similarity index 100% rename from test/bun.js/fs-stream.js rename to test/js/node/fs/fs-stream.js diff --git a/test/bun.js/fs-stream.link.js b/test/js/node/fs/fs-stream.link.js similarity index 100% rename from test/bun.js/fs-stream.link.js rename to test/js/node/fs/fs-stream.link.js diff --git a/test/bun.js/fs.test.ts b/test/js/node/fs/fs.test.ts similarity index 99% rename from test/bun.js/fs.test.ts rename to test/js/node/fs/fs.test.ts index 4c847d25a4..48abef6cb1 100644 --- a/test/bun.js/fs.test.ts +++ b/test/js/node/fs/fs.test.ts @@ -1,5 +1,5 @@ import { beforeEach, describe, expect, it } from "bun:test"; -import { gc, gcTick } from "./gc"; +import { gc, gcTick } from "harness"; import fs, { closeSync, existsSync, @@ -32,11 +32,8 @@ import _promises from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { ReadStream as ReadStream_, WriteStream as WriteStream_ } from "../fixtures/export-lazy-fs-streams/export-from"; -import { - ReadStream as ReadStreamStar_, - WriteStream as WriteStreamStar_, -} from "../fixtures/export-lazy-fs-streams/export-*-from"; +import { ReadStream as ReadStream_, WriteStream as WriteStream_ } from "./export-from.js"; +import { ReadStream as ReadStreamStar_, WriteStream as WriteStreamStar_ } from "./export-*-from.js"; const Buffer = globalThis.Buffer || Uint8Array; diff --git a/test/js/node/fs/readFileSync.txt b/test/js/node/fs/readFileSync.txt new file mode 100644 index 0000000000..ddc94b988e --- /dev/null +++ b/test/js/node/fs/readFileSync.txt @@ -0,0 +1 @@ +File read successfully \ No newline at end of file diff --git a/test/js/node/fs/test.txt b/test/js/node/fs/test.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/bun.js/writeFileSync.txt b/test/js/node/fs/writeFileSync.txt similarity index 100% rename from test/bun.js/writeFileSync.txt rename to test/js/node/fs/writeFileSync.txt diff --git a/test/bun.js/node-test-helpers.test.js b/test/js/node/harness.test.js similarity index 100% rename from test/bun.js/node-test-helpers.test.js rename to test/js/node/harness.test.js diff --git a/test/bun.js/node-test-helpers.ts b/test/js/node/harness.ts similarity index 99% rename from test/bun.js/node-test-helpers.ts rename to test/js/node/harness.ts index 0eaa7d07b4..227009a642 100644 --- a/test/bun.js/node-test-helpers.ts +++ b/test/js/node/harness.ts @@ -1,6 +1,5 @@ import { expect as expect_ } from "bun:test"; -// @ts-ignore -import { gcTick } from "gc"; +import { gcTick } from "harness"; import assertNode from "node:assert"; type DoneCb = (err?: Error) => any; diff --git a/test/bun.js/node-http.test.ts b/test/js/node/http/node-http.fixme.ts similarity index 94% rename from test/bun.js/node-http.test.ts rename to test/js/node/http/node-http.fixme.ts index 619d8cb352..d47002a6ff 100644 --- a/test/bun.js/node-http.test.ts +++ b/test/js/node/http/node-http.fixme.ts @@ -1,6 +1,19 @@ import { describe, expect, it, beforeAll, afterAll } from "bun:test"; import { createServer, request, get, Agent, globalAgent, Server } from "node:http"; -import { createDoneDotAll } from "node-test-helpers"; +import { createDoneDotAll } from "node-harness"; + +function listen(server: any): Promise { + return new Promise((resolve, reject) => { + server.listen({ port: 0 }, (err, hostname, port) => { + if (err) { + reject(err); + } else { + resolve(new URL(`http://${hostname}:${port}`)); + } + }); + setTimeout(() => reject("Timed out"), 5000); + }); +} describe("node:http", () => { describe("createServer", async () => { @@ -10,9 +23,8 @@ describe("node:http", () => { res.writeHead(200, { "Content-Type": "text/plain" }); res.end("Hello World"); }); - server.listen(8123); - - const res = await fetch("http://localhost:8123/hello?world"); + const url = await listen(server); + const res = await fetch(new URL("/hello?world", url)); expect(await res.text()).toBe("Hello World"); server.close(); }); @@ -32,9 +44,8 @@ describe("node:http", () => { res.end(); }); }); - server.listen(8124); - - const res = await fetch("http://localhost:8124", { + const url = await listen(server); + const res = await fetch(url, { method: "POST", body: bodyBlob, }); @@ -59,9 +70,8 @@ describe("node:http", () => { res.end(); }); }); - server.listen(8125); - - const res = await fetch("http://localhost:8125", { + const url = await listen(server); + const res = await fetch(url, { method: "POST", body: bodyBlob, }); @@ -73,7 +83,7 @@ describe("node:http", () => { it("listen should return server", async () => { const server = createServer(); - const listenResponse = server.listen(8129); + const listenResponse = server.listen(0); expect(listenResponse instanceof Server).toBe(true); expect(listenResponse).toBe(server); listenResponse.close(); @@ -464,24 +474,25 @@ describe("node:http", () => { done(); }); - server.listen({ signal, port: 8130 }); + server.listen({ signal, port: 0 }); }); }); describe("get", () => { let server; - beforeAll(() => { + let url; + beforeAll(async () => { server = createServer((req, res) => { res.writeHead(200, { "Content-Type": "text/plain" }); res.end("Hello World"); }); - server.listen(8127); + url = await listen(server); }); afterAll(() => { server.close(); }); it("should make a standard GET request, like request", done => { - get("http://127.0.0.1:8127", res => { + get(url, res => { let data = ""; res.setEncoding("utf8"); res.on("data", chunk => { @@ -506,12 +517,12 @@ describe("node:http", () => { res.writeHead(200, { "Content-Type": "text/plain" }); res.end("Hello World"); }); - server.listen(8128, () => { + server.listen({ port: 0 }, (_, host, port) => { // Setup request after server is listening dummyReq = request( { - host: "localhost", - port: 8128, + host, + port, agent: dummyAgent, }, res => {}, @@ -570,7 +581,7 @@ describe("node:http", () => { server.close(); }); it("should attempt to make a standard GET request and abort", done => { - get(`http://127.0.0.1:${server_port}`, { signal: AbortSignal.timeout(5) }, res => { + get(`http://${server_host}:${server_port}`, { signal: AbortSignal.timeout(5) }, res => { let data = ""; res.setEncoding("utf8"); res.on("data", chunk => { diff --git a/test/bun.js/node-module-module.test.js b/test/js/node/module/node-module-module.test.js similarity index 100% rename from test/bun.js/node-module-module.test.js rename to test/js/node/module/node-module-module.test.js diff --git a/test/bun.js/socket/node-net.test.ts b/test/js/node/net/node-net.test.ts similarity index 100% rename from test/bun.js/socket/node-net.test.ts rename to test/js/node/net/node-net.test.ts diff --git a/test/bun.js/os.test.js b/test/js/node/os/os.test.js similarity index 100% rename from test/bun.js/os.test.js rename to test/js/node/os/os.test.js diff --git a/test/bun.js/path.test.js b/test/js/node/path/path.test.js similarity index 100% rename from test/bun.js/path.test.js rename to test/js/node/path/path.test.js diff --git a/test/bun.js/print-process-args.js b/test/js/node/process/print-process-args.js similarity index 100% rename from test/bun.js/print-process-args.js rename to test/js/node/process/print-process-args.js diff --git a/test/bun.js/process-args.test.js b/test/js/node/process/process-args.test.js similarity index 97% rename from test/bun.js/process-args.test.js rename to test/js/node/process/process-args.test.js index a2c79616f5..4da3a5381f 100644 --- a/test/bun.js/process-args.test.js +++ b/test/js/node/process/process-args.test.js @@ -1,6 +1,6 @@ import { spawn } from "bun"; import { test, expect } from "bun:test"; -import { bunExe } from "./bunExe"; +import { bunExe } from "harness"; test("args exclude run", async () => { const arg0 = process.argv[0]; diff --git a/test/bun.js/process-nexttick.js b/test/js/node/process/process-nexttick.js similarity index 100% rename from test/bun.js/process-nexttick.js rename to test/js/node/process/process-nexttick.js diff --git a/test/bun.js/process-nexttick.test.js b/test/js/node/process/process-nexttick.test.js similarity index 100% rename from test/bun.js/process-nexttick.test.js rename to test/js/node/process/process-nexttick.test.js diff --git a/test/bun.js/process-stdin-echo.js b/test/js/node/process/process-stdin-echo.js similarity index 100% rename from test/bun.js/process-stdin-echo.js rename to test/js/node/process/process-stdin-echo.js diff --git a/test/bun.js/process-stdio.test.ts b/test/js/node/process/process-stdio.test.ts similarity index 99% rename from test/bun.js/process-stdio.test.ts rename to test/js/node/process/process-stdio.test.ts index 6054eeeebb..463ab5fda3 100644 --- a/test/bun.js/process-stdio.test.ts +++ b/test/js/node/process/process-stdio.test.ts @@ -1,6 +1,6 @@ import { spawn, spawnSync } from "bun"; import { describe, expect, it, test } from "bun:test"; -import { bunExe } from "bunExe"; +import { bunExe } from "harness"; import { isatty } from "tty"; test("process.stdin", () => { diff --git a/test/bun.js/process.test.js b/test/js/node/process/process.test.js similarity index 96% rename from test/bun.js/process.test.js rename to test/js/node/process/process.test.js index 8cc3e6b87e..59f54c53f9 100644 --- a/test/bun.js/process.test.js +++ b/test/js/node/process/process.test.js @@ -1,6 +1,6 @@ import { resolveSync, which } from "bun"; import { describe, expect, it } from "bun:test"; -import { readFileSync, realpathSync } from "fs"; +import { existsSync, readFileSync, realpathSync } from "fs"; import { basename } from "path"; it("process", () => { @@ -120,7 +120,8 @@ it("process.umask()", () => { expect(process.umask(orig)).toBe(777); }); -it("process.versions", () => { +const versions = existsSync(import.meta.dir + "/../../src/generated_versions_list.zig"); +(versions ? it : it.skip)("process.versions", () => { // Generate a list of all the versions in the versions object // example: // pub const boringssl = "b275c5ce1c88bc06f5a967026d3c0ce1df2be815"; diff --git a/test/bun.js/readline.node.test.ts b/test/js/node/readline/readline.node.test.ts similarity index 99% rename from test/bun.js/readline.node.test.ts rename to test/js/node/readline/readline.node.test.ts index 4a6c4be8c4..7dfa51ac8d 100644 --- a/test/bun.js/readline.node.test.ts +++ b/test/js/node/readline/readline.node.test.ts @@ -2,7 +2,7 @@ import { beforeEach, describe, it } from "bun:test"; import readline from "node:readline"; import { Writable, PassThrough } from "node:stream"; import { EventEmitter } from "node:events"; -import { createDoneDotAll, createCallCheckCtx, assert } from "./node-test-helpers"; +import { createDoneDotAll, createCallCheckCtx, assert } from "node-harness"; var { CSI, diff --git a/test/bun.js/readline_promises.node.test.ts b/test/js/node/readline/readline_promises.node.test.ts similarity index 94% rename from test/bun.js/readline_promises.node.test.ts rename to test/js/node/readline/readline_promises.node.test.ts index 93093aecd0..c75d254ca0 100644 --- a/test/bun.js/readline_promises.node.test.ts +++ b/test/js/node/readline/readline_promises.node.test.ts @@ -1,7 +1,7 @@ import { describe, it } from "bun:test"; import readlinePromises from "node:readline/promises"; import { EventEmitter } from "node:events"; -import { createDoneDotAll, createCallCheckCtx, assert } from "./node-test-helpers"; +import { createDoneDotAll, createCallCheckCtx, assert } from "node-harness"; // ---------------------------------------------------------------------------- // Helpers diff --git a/test/bun.js/bufferlist.test.ts b/test/js/node/stream/bufferlist.test.ts similarity index 100% rename from test/bun.js/bufferlist.test.ts rename to test/js/node/stream/bufferlist.test.ts diff --git a/test/bun.js/node-stream-uint8array.test.ts b/test/js/node/stream/node-stream-uint8array.test.ts similarity index 100% rename from test/bun.js/node-stream-uint8array.test.ts rename to test/js/node/stream/node-stream-uint8array.test.ts diff --git a/test/bun.js/node-stream.test.js b/test/js/node/stream/node-stream.test.js similarity index 100% rename from test/bun.js/node-stream.test.js rename to test/js/node/stream/node-stream.test.js diff --git a/test/bun.js/string-decoder.test.js b/test/js/node/string_decoder/string-decoder.test.js similarity index 99% rename from test/bun.js/string-decoder.test.js rename to test/js/node/string_decoder/string-decoder.test.js index 4bc9d7e8bb..f373266782 100644 --- a/test/bun.js/string-decoder.test.js +++ b/test/js/node/string_decoder/string-decoder.test.js @@ -1,5 +1,5 @@ import { describe, expect, it } from "bun:test"; -import { withoutAggressiveGC } from "gc"; +import { withoutAggressiveGC } from "harness"; const RealStringDecoder = require("string_decoder").StringDecoder; diff --git a/test/bun.js/node-timers.test.ts b/test/js/node/timers/node-timers.test.ts similarity index 100% rename from test/bun.js/node-timers.test.ts rename to test/js/node/timers/node-timers.test.ts diff --git a/test/bun.js/test-util-types.test.js b/test/js/node/util/test-util-types.test.js similarity index 100% rename from test/bun.js/test-util-types.test.js rename to test/js/node/util/test-util-types.test.js diff --git a/test/bun.js/util/util-promisify.test.js b/test/js/node/util/util-promisify.test.js similarity index 100% rename from test/bun.js/util/util-promisify.test.js rename to test/js/node/util/util-promisify.test.js diff --git a/test/bun.js/util/util.test.js b/test/js/node/util/util.test.js similarity index 100% rename from test/bun.js/util/util.test.js rename to test/js/node/util/util.test.js diff --git a/test/bun.js/capture-stack-trace.test.js b/test/js/node/v8/capture-stack-trace.test.js similarity index 100% rename from test/bun.js/capture-stack-trace.test.js rename to test/js/node/v8/capture-stack-trace.test.js diff --git a/test/js/node/zlib/fixture.html.gz b/test/js/node/zlib/fixture.html.gz new file mode 100644 index 0000000000..0bb85d4cbd Binary files /dev/null and b/test/js/node/zlib/fixture.html.gz differ diff --git a/test/bun.js/zlib.test.js b/test/js/node/zlib/zlib.test.js similarity index 100% rename from test/bun.js/zlib.test.js rename to test/js/node/zlib/zlib.test.js diff --git a/test/bun.js/third-party/body-parser-test/bun.lockb b/test/js/third_party/body-parser/bun.lockb similarity index 100% rename from test/bun.js/third-party/body-parser-test/bun.lockb rename to test/js/third_party/body-parser/bun.lockb diff --git a/test/bun.js/third-party/body-parser-test/express-body-parser-test.test.ts b/test/js/third_party/body-parser/express-body-parser-test.test.ts similarity index 100% rename from test/bun.js/third-party/body-parser-test/express-body-parser-test.test.ts rename to test/js/third_party/body-parser/express-body-parser-test.test.ts diff --git a/test/bun.js/third-party/body-parser-test/package.json b/test/js/third_party/body-parser/package.json similarity index 100% rename from test/bun.js/third-party/body-parser-test/package.json rename to test/js/third_party/body-parser/package.json diff --git a/test/js/third_party/esbuild/bun.lockb b/test/js/third_party/esbuild/bun.lockb new file mode 100755 index 0000000000..f46c6aa5da Binary files /dev/null and b/test/js/third_party/esbuild/bun.lockb differ diff --git a/test/bun.js/esbuild-child_process.test.ts b/test/js/third_party/esbuild/esbuild-child_process.test.ts similarity index 92% rename from test/bun.js/esbuild-child_process.test.ts rename to test/js/third_party/esbuild/esbuild-child_process.test.ts index 9c0daa5232..adda89f9bd 100644 --- a/test/bun.js/esbuild-child_process.test.ts +++ b/test/js/third_party/esbuild/esbuild-child_process.test.ts @@ -1,6 +1,6 @@ import { spawnSync } from "bun"; import { describe, it, expect, test } from "bun:test"; -import { bunExe } from "bunExe"; +import { bunExe } from "harness"; test("esbuild", () => { const { exitCode, stderr, stdout } = spawnSync([bunExe(), import.meta.dir + "/esbuild-test.js"], { diff --git a/test/bun.js/esbuild-test.js b/test/js/third_party/esbuild/esbuild-test.js similarity index 100% rename from test/bun.js/esbuild-test.js rename to test/js/third_party/esbuild/esbuild-test.js diff --git a/test/js/third_party/esbuild/package.json b/test/js/third_party/esbuild/package.json new file mode 100644 index 0000000000..ad6bc55f6e --- /dev/null +++ b/test/js/third_party/esbuild/package.json @@ -0,0 +1,6 @@ +{ + "type": "module", + "dependencies": { + "esbuild": "^0.17.11" + } +} \ No newline at end of file diff --git a/test/bun.js/third-party/napi_create_external/bun.lockb b/test/js/third_party/napi_create_external/bun.lockb similarity index 100% rename from test/bun.js/third-party/napi_create_external/bun.lockb rename to test/js/third_party/napi_create_external/bun.lockb diff --git a/test/bun.js/third-party/napi_create_external/napi-create-external.test.ts b/test/js/third_party/napi_create_external/napi-create-external.test.ts similarity index 99% rename from test/bun.js/third-party/napi_create_external/napi-create-external.test.ts rename to test/js/third_party/napi_create_external/napi-create-external.test.ts index ca7e50b991..c3fe5ad65b 100644 --- a/test/bun.js/third-party/napi_create_external/napi-create-external.test.ts +++ b/test/js/third_party/napi_create_external/napi-create-external.test.ts @@ -1,5 +1,5 @@ import { test, it, describe, expect } from "bun:test"; -import { withoutAggressiveGC } from "gc"; +import { withoutAggressiveGC } from "harness"; import * as _ from "lodash"; function rebase(str, inBase, outBase) { diff --git a/test/bun.js/third-party/napi_create_external/package.json b/test/js/third_party/napi_create_external/package.json similarity index 93% rename from test/bun.js/third-party/napi_create_external/package.json rename to test/js/third_party/napi_create_external/package.json index 82b0ef58d6..659b279b21 100644 --- a/test/bun.js/third-party/napi_create_external/package.json +++ b/test/js/third_party/napi_create_external/package.json @@ -1,5 +1,6 @@ { "name": "napi-create-external-test", + "type": "module", "version": "1.0.0", "description": "Test for napi_create_external", "dependencies": { diff --git a/test/bun.js/react-dom-server.bun.cjs b/test/js/third_party/react-dom/react-dom-server.bun.cjs similarity index 100% rename from test/bun.js/react-dom-server.bun.cjs rename to test/js/third_party/react-dom/react-dom-server.bun.cjs diff --git a/test/bun.js/react-dom.test.tsx b/test/js/third_party/react-dom/react-dom.test.tsx similarity index 99% rename from test/bun.js/react-dom.test.tsx rename to test/js/third_party/react-dom/react-dom.test.tsx index b484982e06..2f1309fb8a 100644 --- a/test/bun.js/react-dom.test.tsx +++ b/test/js/third_party/react-dom/react-dom.test.tsx @@ -9,7 +9,7 @@ import { import { heapStats } from "bun:jsc"; import { describe, expect, it } from "bun:test"; import { renderToReadableStream as renderToReadableStreamBrowser } from "react-dom/server.browser"; -import { gc } from "./gc"; +import { gc } from "harness"; import { renderToReadableStream as renderToReadableStreamBun } from "./react-dom-server.bun.cjs"; import React from "react"; diff --git a/test/bun.js/bun-loader-svelte/bun-loader-svelte.ts b/test/js/third_party/svelte/bun-loader-svelte.ts similarity index 100% rename from test/bun.js/bun-loader-svelte/bun-loader-svelte.ts rename to test/js/third_party/svelte/bun-loader-svelte.ts diff --git a/test/js/third_party/svelte/hello.svelte b/test/js/third_party/svelte/hello.svelte new file mode 100644 index 0000000000..05dac42940 --- /dev/null +++ b/test/js/third_party/svelte/hello.svelte @@ -0,0 +1,5 @@ + + +

Hello {name}!

diff --git a/test/bun.js/bun-loader-svelte/package.json b/test/js/third_party/svelte/package.json similarity index 100% rename from test/bun.js/bun-loader-svelte/package.json rename to test/js/third_party/svelte/package.json diff --git a/test/js/third_party/svelte/svelte.test.ts b/test/js/third_party/svelte/svelte.test.ts new file mode 100644 index 0000000000..44e36cce27 --- /dev/null +++ b/test/js/third_party/svelte/svelte.test.ts @@ -0,0 +1,21 @@ +import { describe, expect, it } from "bun:test"; +import "./bun-loader-svelte"; + +describe("require", () => { + it("SSRs `

Hello world!

` with Svelte", () => { + const { default: App } = require("./hello.svelte"); + const { html } = App.render(); + + expect(html).toBe("

Hello world!

"); + }); +}); + +describe("dynamic import", () => { + it("SSRs `

Hello world!

` with Svelte", async () => { + const { default: App }: any = await import("./hello.svelte"); + + const { html } = App.render(); + + expect(html).toBe("

Hello world!

"); + }); +}); diff --git a/test/bun.js/abort-signal-timeout.test.js b/test/js/web/abort/abort-signal-timeout.test.js similarity index 100% rename from test/bun.js/abort-signal-timeout.test.js rename to test/js/web/abort/abort-signal-timeout.test.js diff --git a/test/bun.js/console/console-log.expected.txt b/test/js/web/console/console-log.expected.txt similarity index 100% rename from test/bun.js/console/console-log.expected.txt rename to test/js/web/console/console-log.expected.txt diff --git a/test/bun.js/console/console-log.js b/test/js/web/console/console-log.js similarity index 100% rename from test/bun.js/console/console-log.js rename to test/js/web/console/console-log.js diff --git a/test/bun.js/console/console-log.test.ts b/test/js/web/console/console-log.test.ts similarity index 94% rename from test/bun.js/console/console-log.test.ts rename to test/js/web/console/console-log.test.ts index 7fd9c79e57..98c8370def 100644 --- a/test/bun.js/console/console-log.test.ts +++ b/test/js/web/console/console-log.test.ts @@ -1,6 +1,6 @@ import { file, spawn } from "bun"; import { expect, it } from "bun:test"; -import { bunExe } from "bunExe"; +import { bunExe } from "harness"; it("should log to console correctly", async () => { const { stdout, stderr, exited } = spawn({ diff --git a/test/bun.js/web-crypto.test.ts b/test/js/web/crypto/web-crypto.test.ts similarity index 100% rename from test/bun.js/web-crypto.test.ts rename to test/js/web/crypto/web-crypto.test.ts diff --git a/test/bun.js/text-decoder.test.js b/test/js/web/encoding/text-decoder.test.js similarity index 99% rename from test/bun.js/text-decoder.test.js rename to test/js/web/encoding/text-decoder.test.js index da04974641..abd4c2a72f 100644 --- a/test/bun.js/text-decoder.test.js +++ b/test/js/web/encoding/text-decoder.test.js @@ -1,5 +1,5 @@ import { expect, it, describe } from "bun:test"; -import { gc as gcTrace, withoutAggressiveGC } from "./gc"; +import { gc as gcTrace, withoutAggressiveGC } from "harness"; const getByteLength = str => { // returns the byte length of an utf8 string diff --git a/test/bun.js/text-encoder.test.js b/test/js/web/encoding/text-encoder.test.js similarity index 99% rename from test/bun.js/text-encoder.test.js rename to test/js/web/encoding/text-encoder.test.js index a18c22618f..3d271026da 100644 --- a/test/bun.js/text-encoder.test.js +++ b/test/js/web/encoding/text-encoder.test.js @@ -1,5 +1,5 @@ import { expect, it, describe } from "bun:test"; -import { gc as gcTrace, withoutAggressiveGC } from "./gc"; +import { gc as gcTrace, withoutAggressiveGC } from "harness"; const getByteLength = str => { // returns the byte length of an utf8 string diff --git a/test/bun.js/utf8-encoding-fixture.bin b/test/js/web/encoding/utf8-encoding-fixture.bin similarity index 100% rename from test/bun.js/utf8-encoding-fixture.bin rename to test/js/web/encoding/utf8-encoding-fixture.bin diff --git a/test/bun.js/body-mixin-errors.test.ts b/test/js/web/fetch/body-mixin-errors.test.ts similarity index 100% rename from test/bun.js/body-mixin-errors.test.ts rename to test/js/web/fetch/body-mixin-errors.test.ts diff --git a/test/bun.js/body-stream.test.ts b/test/js/web/fetch/body-stream.test.ts similarity index 100% rename from test/bun.js/body-stream.test.ts rename to test/js/web/fetch/body-stream.test.ts diff --git a/test/bun.js/fetch-gzip.test.ts b/test/js/web/fetch/fetch-gzip.test.ts similarity index 99% rename from test/bun.js/fetch-gzip.test.ts rename to test/js/web/fetch/fetch-gzip.test.ts index eee8413758..01eedc54ac 100644 --- a/test/bun.js/fetch-gzip.test.ts +++ b/test/js/web/fetch/fetch-gzip.test.ts @@ -1,7 +1,7 @@ import { concatArrayBuffers } from "bun"; import { it, describe, expect } from "bun:test"; import fs from "fs"; -import { gc, gcTick } from "./gc"; +import { gc, gcTick } from "harness"; it("fetch() with a buffered gzip response works (one chunk)", async () => { var server = Bun.serve({ diff --git a/test/js/web/fetch/fetch.js.txt b/test/js/web/fetch/fetch.js.txt new file mode 100644 index 0000000000..5a9b52fcf1 --- /dev/null +++ b/test/js/web/fetch/fetch.js.txt @@ -0,0 +1,46 @@ + + + + Example Domain + + + + + + + + +
+

Example Domain

+

This domain is for use in illustrative examples in documents. You may use this + domain in literature without prior coordination or asking for permission.

+

More information...

+
+ + diff --git a/test/bun.js/fetch.test.ts b/test/js/web/fetch/fetch.test.ts similarity index 99% rename from test/bun.js/fetch.test.ts rename to test/js/web/fetch/fetch.test.ts index f5f264dd75..1185dbd55f 100644 --- a/test/bun.js/fetch.test.ts +++ b/test/js/web/fetch/fetch.test.ts @@ -4,7 +4,7 @@ import { chmodSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSy import { mkfifo } from "mkfifo"; import { tmpdir } from "os"; import { join } from "path"; -import { gc, withoutAggressiveGC } from "./gc"; +import { gc, withoutAggressiveGC } from "harness"; const tmp_dir = mkdtempSync(join(realpathSync(tmpdir()), "fetch.test")); diff --git a/test/bun.js/fetch_headers.test.js b/test/js/web/fetch/fetch_headers.test.js similarity index 100% rename from test/bun.js/fetch_headers.test.js rename to test/js/web/fetch/fetch_headers.test.js diff --git a/test/bun.js/fixture.html b/test/js/web/fetch/fixture.html similarity index 100% rename from test/bun.js/fixture.html rename to test/js/web/fetch/fixture.html diff --git a/test/js/web/fetch/fixture.html.gz b/test/js/web/fetch/fixture.html.gz new file mode 100644 index 0000000000..0bb85d4cbd Binary files /dev/null and b/test/js/web/fetch/fixture.html.gz differ diff --git a/test/bun.js/FormData.test.ts b/test/js/web/html/FormData.test.ts similarity index 99% rename from test/bun.js/FormData.test.ts rename to test/js/web/html/FormData.test.ts index 25c0d5d549..9d0db43611 100644 --- a/test/bun.js/FormData.test.ts +++ b/test/js/web/html/FormData.test.ts @@ -1,7 +1,7 @@ import { afterAll, beforeAll, describe, expect, it, test } from "bun:test"; import fs, { chmodSync, unlinkSync } from "fs"; import { mkfifo } from "mkfifo"; -import { gc, withoutAggressiveGC } from "./gc"; +import { gc, withoutAggressiveGC } from "../../gc"; describe("FormData", () => { it("should be able to append a string", () => { diff --git a/test/bun.js/form-data-fixture.txt b/test/js/web/html/form-data-fixture.txt similarity index 100% rename from test/bun.js/form-data-fixture.txt rename to test/js/web/html/form-data-fixture.txt diff --git a/test/js/web/streams/bun-streams-test-fifo.sh b/test/js/web/streams/bun-streams-test-fifo.sh new file mode 100644 index 0000000000..57650ba1d7 --- /dev/null +++ b/test/js/web/streams/bun-streams-test-fifo.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +echoerr() { echo "$@" 1>&2; } + +echoerr "bun-streams-test-fifo.sh: starting" +echo -e "$FIFO_TEST" >>${@: -1} +echoerr "bun-streams-test-fifo.sh: ending" +exit 0 diff --git a/test/js/web/streams/fetch.js.txt b/test/js/web/streams/fetch.js.txt new file mode 100644 index 0000000000..5a9b52fcf1 --- /dev/null +++ b/test/js/web/streams/fetch.js.txt @@ -0,0 +1,46 @@ + + + + Example Domain + + + + + + + + +
+

Example Domain

+

This domain is for use in illustrative examples in documents. You may use this + domain in literature without prior coordination or asking for permission.

+

More information...

+
+ + diff --git a/test/bun.js/streams.test.js b/test/js/web/streams/streams.test.js similarity index 99% rename from test/bun.js/streams.test.js rename to test/js/web/streams/streams.test.js index 7ae49db40d..c4af85e4f5 100644 --- a/test/bun.js/streams.test.js +++ b/test/js/web/streams/streams.test.js @@ -4,7 +4,7 @@ import { mkfifo } from "mkfifo"; import { realpathSync, unlinkSync, writeFileSync } from "node:fs"; import { join } from "node:path"; import { tmpdir } from "os"; -import { gc } from "./gc"; +import { gc } from "harness"; beforeEach(() => gc()); afterEach(() => gc()); diff --git a/test/bun.js/microtask.test.js b/test/js/web/timers/microtask.test.js similarity index 100% rename from test/bun.js/microtask.test.js rename to test/js/web/timers/microtask.test.js diff --git a/test/bun.js/performance.test.js b/test/js/web/timers/performance.test.js similarity index 100% rename from test/bun.js/performance.test.js rename to test/js/web/timers/performance.test.js diff --git a/test/bun.js/setImmediate.test.js b/test/js/web/timers/setImmediate.test.js similarity index 100% rename from test/bun.js/setImmediate.test.js rename to test/js/web/timers/setImmediate.test.js diff --git a/test/bun.js/setInterval.test.js b/test/js/web/timers/setInterval.test.js similarity index 100% rename from test/bun.js/setInterval.test.js rename to test/js/web/timers/setInterval.test.js diff --git a/test/bun.js/setTimeout.test.js b/test/js/web/timers/setTimeout.test.js similarity index 100% rename from test/bun.js/setTimeout.test.js rename to test/js/web/timers/setTimeout.test.js diff --git a/test/bun.js/url.test.ts b/test/js/web/url/url.test.ts similarity index 100% rename from test/bun.js/url.test.ts rename to test/js/web/url/url.test.ts diff --git a/test/bun.js/atob.test.js b/test/js/web/util/atob.test.js similarity index 100% rename from test/bun.js/atob.test.js rename to test/js/web/util/atob.test.js diff --git a/test/bun.js/web-globals.test.js b/test/js/web/web-globals.test.js similarity index 99% rename from test/bun.js/web-globals.test.js rename to test/js/web/web-globals.test.js index aa5756c520..b7a243190b 100644 --- a/test/bun.js/web-globals.test.js +++ b/test/js/web/web-globals.test.js @@ -1,6 +1,6 @@ import { unsafe } from "bun"; import { expect, it, test } from "bun:test"; -import { withoutAggressiveGC } from "gc"; +import { withoutAggressiveGC } from "harness"; test("exists", () => { expect(typeof URL !== "undefined").toBe(true); diff --git a/test/bun.js/websocket-subprocess.ts b/test/js/web/websocket/websocket-subprocess.ts similarity index 100% rename from test/bun.js/websocket-subprocess.ts rename to test/js/web/websocket/websocket-subprocess.ts diff --git a/test/bun.js/websocket.test.js b/test/js/web/websocket/websocket.test.js similarity index 98% rename from test/bun.js/websocket.test.js rename to test/js/web/websocket/websocket.test.js index 61c9ec054d..f0f29c1c39 100644 --- a/test/bun.js/websocket.test.js +++ b/test/js/web/websocket/websocket.test.js @@ -1,9 +1,6 @@ import { describe, it, expect } from "bun:test"; import { unsafe, spawn, readableStreamToText } from "bun"; -import { bunExe } from "bunExe"; - -import { gc } from "./gc"; -import { bunEnv } from "bunEnv"; +import { bunExe, bunEnv, gc } from "harness"; const TEST_WEBSOCKET_HOST = process.env.TEST_WEBSOCKET_HOST || "wss://ws.postman-echo.com/raw"; diff --git a/test/bun.js/html-rewriter.test.js b/test/js/workerd/html-rewriter.test.js similarity index 99% rename from test/bun.js/html-rewriter.test.js rename to test/js/workerd/html-rewriter.test.js index e33710f28e..b5db3fde2e 100644 --- a/test/bun.js/html-rewriter.test.js +++ b/test/js/workerd/html-rewriter.test.js @@ -1,5 +1,5 @@ import { describe, it, expect } from "bun:test"; -import { gcTick } from "./gc"; +import { gcTick } from "../gc"; var setTimeoutAsync = (fn, delay) => { return new Promise((resolve, reject) => { diff --git a/test/macro/assert.tsx b/test/macro/assert.tsx deleted file mode 100644 index 8a6e4d8224..0000000000 --- a/test/macro/assert.tsx +++ /dev/null @@ -1,4 +0,0 @@ -// This logs the result at build time -export function unreachable(call) { - throw new Error(call.arguments[0].toString() || "unreachable"); -} diff --git a/test/macro/fetchSync.tsx b/test/macro/fetchSync.tsx deleted file mode 100644 index 51d1ca4f53..0000000000 --- a/test/macro/fetchSync.tsx +++ /dev/null @@ -1,9 +0,0 @@ -// @ts-nocheck -export async function fetchSync(ctx) { - const str = ctx.arguments[0].toString(); - - const response = await fetch(str); - const text = await response.text(); - - return ; -} diff --git a/test/macro/hello-fetch-macro.tsx b/test/macro/hello-fetch-macro.tsx deleted file mode 100644 index fa0de4a9d7..0000000000 --- a/test/macro/hello-fetch-macro.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { fetchSync } from "macro:./fetchSync.tsx"; - -const synchronousFetch = fetchSync(`https://example.com`); - -console.log(synchronousFetch); diff --git a/test/macro/loadMocks.tsx b/test/macro/loadMocks.tsx deleted file mode 100644 index 08e90dece6..0000000000 --- a/test/macro/loadMocks.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { unreachable } from "macro:./assert"; - -if (process.env.NODE_ENV !== "test") unreachable("This module should only be imported in tests"); - -export const mockData = { - Copilot: { - id: "Copilot", - name: "Copilot", - description: "Copilot", - icon: "https://s3.amazonaws.com/copilot-public/images/icons/Copilot.png", - color: "#00AEEF", - type: "service", - tags: ["copilot"], - categories: ["copilot"], - links: [ - { - id: "Copilot", - name: "Copilot", - url: "https://copilot.io", - description: "Copilot", - icon: "https://s3.amazonaws.com/copilot-public/images/icons/Copilot.png", - color: "#00AEEF", - type: "service", - tags: ["copilot"], - categories: ["copilot"], - }, - ], - }, -}; diff --git a/test/macro/macro.d.ts b/test/macro/macro.d.ts deleted file mode 100644 index ba02c03ede..0000000000 --- a/test/macro/macro.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module "macro:*"; diff --git a/test/bun.js/mkfifo.ts b/test/mkfifo.ts similarity index 100% rename from test/bun.js/mkfifo.ts rename to test/mkfifo.ts diff --git a/test/package.json b/test/package.json new file mode 100644 index 0000000000..dfeabcd42a --- /dev/null +++ b/test/package.json @@ -0,0 +1,19 @@ +{ + "private": true, + "name": "test", + "type": "module", + "devDependencies": { + "bun-types": "canary" + }, + "dependencies": { + "bktree-fast": "^0.0.7", + "body-parser": "^1.20.2", + "esbuild": "^0.17.11", + "express": "^4.18.2", + "iconv-lite": "^0.6.3", + "lodash": "^4.17.21", + "react-dom": "^18.2.0", + "svelte": "^3.55.1", + "undici": "^5.20.0" + } +} \ No newline at end of file diff --git a/test/bun.js/repro_631.test.js b/test/regression/issue/00631.test.ts similarity index 78% rename from test/bun.js/repro_631.test.js rename to test/regression/issue/00631.test.ts index 11eba44742..691c3227cf 100644 --- a/test/bun.js/repro_631.test.js +++ b/test/regression/issue/00631.test.ts @@ -1,10 +1,11 @@ import { expect, it } from "bun:test"; -import { bunExe } from "./bunExe.ts"; -import { bunEnv } from "./bunEnv.ts"; -import { mkdirSync, rmSync, writeFileSync, readFileSync } from "fs"; +import { bunExe, bunEnv } from "../../harness.js"; +import { mkdirSync, rmSync, writeFileSync, readFileSync, mkdtempSync } from "fs"; +import { tmpdir } from "os"; +import { join } from "path"; it("JSON strings escaped properly", async () => { - const testDir = import.meta.dir + "/repro_631/"; + const testDir = mkdtempSync(join(tmpdir(), "issue631-")); // Clean up from prior runs if necessary rmSync(testDir, { recursive: true, force: true }); @@ -23,6 +24,7 @@ it("JSON strings escaped properly", async () => { }); expect(exitCode).toBe(0); + console.log(testDir); const packageContents = readFileSync(testDir + "package.json", { encoding: "utf8" }); expect(packageContents).toBe(String.raw`{ "testRegex": "\\a\n\\b\\", diff --git a/test/bun.js/repro_2005.test.js b/test/regression/issue/02005.test.ts similarity index 86% rename from test/bun.js/repro_2005.test.js rename to test/regression/issue/02005.test.ts index dc0cd9a975..230be5301b 100644 --- a/test/bun.js/repro_2005.test.js +++ b/test/regression/issue/02005.test.ts @@ -1,6 +1,6 @@ import { it, expect } from "bun:test"; -it("regex literal with non-Latin1 should work", () => { +it("regex literal with non-latin1 should work", () => { const text = "这是一段要替换的文字"; //Correct results: 这是一段的文字 diff --git a/test/tsconfig.json b/test/tsconfig.json new file mode 100644 index 0000000000..e879cd5f54 --- /dev/null +++ b/test/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "noEmit": true, + "lib": ["ESNext"], + "module": "ESNext", + "target": "ESNext", + "moduleResolution": "nodenext", + "strict": true, + "downlevelIteration": true, + "skipLibCheck": true, + "jsx": "preserve", + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "allowJs": true, + "types": ["bun-types"], + "baseUrl": ".", + "paths": { + "harness": ["harness.ts"], + "mkfifo": ["mkfifo.ts"], + "node-harness": ["js/node/harness.ts"] + } + } +} diff --git a/tsconfig.json b/tsconfig.json index 518dca2c16..461fdb4724 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,8 +16,6 @@ "bench", "examples/react-fast-refresh-test", "examples/macros", - "test/bun.js/solid-dom-fixtures", - "test/bun.js/bundled", "src/deps", "bun-webkit", // JavaScriptCore builtins use a non-standard "@" symbol to indicate a private identifier which no other tool supports