diff --git a/.gitattributes b/.gitattributes index 127f8791354..47e70ff94e6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,4 +6,4 @@ *.resi linguist-language=ReScript .yarn/releases/* binary linguist-vendored -tests/dependencies/** linguist-vendored +packages/rescript-react/** linguist-vendored diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8cdb0ecb51d..24c57f3ce0d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,7 +51,7 @@ git clone --depth 1 https://github.com/rescript-lang/rescript.git This will only consume less than 50MB. -[.gitattributes](.gitattributes) checks out every text file with LF line endings, which the committed snapshots and formatters expect on every platform. It also marks the Yarn release and the copied test dependencies in `tests/dependencies` as vendored, which leaves them out of GitHub's language statistics. +[.gitattributes](.gitattributes) checks out every text file with LF line endings, which the committed snapshots and formatters expect on every platform. It also marks the Yarn release and the vendored copy of rescript-react in `packages/rescript-react` (used by the playground and the tests) as vendored, which leaves them out of GitHub's language statistics. ## Installation diff --git a/biome.json b/biome.json index f02fa308a3f..cdb3be08587 100644 --- a/biome.json +++ b/biome.json @@ -56,10 +56,10 @@ "!**/tests/analysis_tests/**/src", "!**/tests/build_tests/**/src", "!**/tests/project_tests/**/src", - "!**/tests/belt_tests/**/src", - "!**/tests/commonjs_tests/src", - "!**/tests/dependencies/**/src", - "!**/tests/docstring_tests", + "!**/tests/runtime_tests/belt/**/src", + "!**/tests/runtime_tests/commonjs/src", + "!**/packages/rescript-react/src", + "!**/tests/runtime_tests/docstrings", "!**/tests/gentype_tests", "**/tests/gentype_tests/typescript-react-example/**", "!**/tests/compiler_tests/**/src", diff --git a/changes/rescript-react-package.internal.md b/changes/rescript-react-package.internal.md new file mode 100644 index 00000000000..cdf2f12c469 --- /dev/null +++ b/changes/rescript-react-package.internal.md @@ -0,0 +1 @@ +- Move the vendored rescript-react, which the playground and many tests build against, to `packages/rescript-react`, and require `"private": true` for every workspace that is not published. diff --git a/changes/runtime-test-suites.internal.md b/changes/runtime-test-suites.internal.md new file mode 100644 index 00000000000..d2e8a28d6ea --- /dev/null +++ b/changes/runtime-test-suites.internal.md @@ -0,0 +1 @@ +- Group the Belt, CommonJS and docstring suites under `tests/runtime_tests` and move the CLI platform test to `tests/package_tests`. diff --git a/lib_dev/paths.js b/lib_dev/paths.js index 2b01c575869..408b364975b 100644 --- a/lib_dev/paths.js +++ b/lib_dev/paths.js @@ -38,14 +38,22 @@ export const projectTestDir = path.resolve(testDir, "project_tests"); export const errorTestDir = path.resolve(testDir, "error_tests"); /** - * path: `/tests/docstring_tests/` + * path: `/tests/runtime_tests/docstrings/` */ -export const docstringTestDir = path.resolve(testDir, "docstring_tests"); +export const docstringTestDir = path.resolve( + testDir, + "runtime_tests", + "docstrings", +); /** - * path: `/tests/commonjs_tests/` + * path: `/tests/runtime_tests/commonjs/` */ -export const commonjsTestDir = path.resolve(testDir, "commonjs_tests"); +export const commonjsTestDir = path.resolve( + testDir, + "runtime_tests", + "commonjs", +); /** * path: `/compiler/version/rescript_version.ml` diff --git a/package.json b/package.json index 1badf6eb1c8..d938542899d 100644 --- a/package.json +++ b/package.json @@ -106,14 +106,14 @@ "packages/dev-playground", "packages/playground", "packages/@rescript/*", - "tests/dependencies/**", + "packages/rescript-react", "tests/analysis_tests/**", - "tests/docstring_tests", - "tests/belt_tests", + "tests/runtime_tests/docstrings", + "tests/runtime_tests/belt", "tests/gentype_tests/**", "tests/compiler_tests", "tests/tools_tests", - "tests/commonjs_tests", + "tests/runtime_tests/commonjs", "scripts/res" ], "packageManager": "yarn@4.18.1", diff --git a/packages/rescript-react/.gitignore b/packages/rescript-react/.gitignore new file mode 100644 index 00000000000..340f5449c62 --- /dev/null +++ b/packages/rescript-react/.gitignore @@ -0,0 +1,3 @@ +*.js +*.mjs +lib/ diff --git a/tests/dependencies/rescript-react/package.json b/packages/rescript-react/package.json similarity index 100% rename from tests/dependencies/rescript-react/package.json rename to packages/rescript-react/package.json diff --git a/tests/dependencies/rescript-react/rescript.json b/packages/rescript-react/rescript.json similarity index 100% rename from tests/dependencies/rescript-react/rescript.json rename to packages/rescript-react/rescript.json diff --git a/tests/dependencies/rescript-react/src/React.res b/packages/rescript-react/src/React.res similarity index 100% rename from tests/dependencies/rescript-react/src/React.res rename to packages/rescript-react/src/React.res diff --git a/tests/dependencies/rescript-react/src/ReactDOM.res b/packages/rescript-react/src/ReactDOM.res similarity index 100% rename from tests/dependencies/rescript-react/src/ReactDOM.res rename to packages/rescript-react/src/ReactDOM.res diff --git a/tests/dependencies/rescript-react/src/ReactDOMStyle.res b/packages/rescript-react/src/ReactDOMStyle.res similarity index 100% rename from tests/dependencies/rescript-react/src/ReactDOMStyle.res rename to packages/rescript-react/src/ReactDOMStyle.res diff --git a/tests/dependencies/rescript-react/src/ReactEvent.res b/packages/rescript-react/src/ReactEvent.res similarity index 100% rename from tests/dependencies/rescript-react/src/ReactEvent.res rename to packages/rescript-react/src/ReactEvent.res diff --git a/tests/dependencies/rescript-react/src/ReactEvent.resi b/packages/rescript-react/src/ReactEvent.resi similarity index 100% rename from tests/dependencies/rescript-react/src/ReactEvent.resi rename to packages/rescript-react/src/ReactEvent.resi diff --git a/tests/dependencies/rescript-react/src/RescriptReactErrorBoundary.res b/packages/rescript-react/src/RescriptReactErrorBoundary.res similarity index 100% rename from tests/dependencies/rescript-react/src/RescriptReactErrorBoundary.res rename to packages/rescript-react/src/RescriptReactErrorBoundary.res diff --git a/tests/dependencies/rescript-react/src/RescriptReactErrorBoundary.resi b/packages/rescript-react/src/RescriptReactErrorBoundary.resi similarity index 100% rename from tests/dependencies/rescript-react/src/RescriptReactErrorBoundary.resi rename to packages/rescript-react/src/RescriptReactErrorBoundary.resi diff --git a/tests/dependencies/rescript-react/src/RescriptReactRouter.res b/packages/rescript-react/src/RescriptReactRouter.res similarity index 100% rename from tests/dependencies/rescript-react/src/RescriptReactRouter.res rename to packages/rescript-react/src/RescriptReactRouter.res diff --git a/tests/dependencies/rescript-react/src/RescriptReactRouter.resi b/packages/rescript-react/src/RescriptReactRouter.resi similarity index 100% rename from tests/dependencies/rescript-react/src/RescriptReactRouter.resi rename to packages/rescript-react/src/RescriptReactRouter.resi diff --git a/scripts/compilerBenchmarks.js b/scripts/compilerBenchmarks.js index 2883694297d..36cede0364f 100644 --- a/scripts/compilerBenchmarks.js +++ b/scripts/compilerBenchmarks.js @@ -582,15 +582,8 @@ function copySources(from, to) { }); } -/** - * The project the build benchmarks build, relative to a checkout. A base from - * before the rename to tests/compiler_tests still has it at tests/tests; the - * next pull request in the stack drops that fallback. - */ -const benchmarkProjects = [ - path.join("tests", "compiler_tests"), - path.join("tests", "tests"), -]; +/** The project the build benchmarks build, relative to a checkout. */ +const benchmarkProject = path.join("tests", "compiler_tests"); /** * The module of the project that about 200 others use, and that has no @@ -622,11 +615,7 @@ const sharedModule = path.join("src", "test_utils.res"); */ function measureProjectBuild(checkout, projectCheckout, results) { const rescript = path.join(checkout, relativeBinDir, "rescript.exe"); - const projectDir = - benchmarkProjects - .map(project => path.join(projectCheckout, project)) - .find(dir => fs.existsSync(dir)) ?? - path.join(projectCheckout, benchmarkProjects[0]); + const projectDir = path.join(projectCheckout, benchmarkProject); const workDir = path.join(os.tmpdir(), "compiler-bench-project"); fs.rmSync(workDir, { recursive: true, force: true }); try { @@ -642,12 +631,15 @@ function measureProjectBuild(checkout, projectCheckout, results) { `${JSON.stringify(config, null, 2)}\n`, ); const scope = path.join(workDir, "node_modules", "@rescript"); - const react = path.join( - projectCheckout, - "tests", - "dependencies", - "rescript-react", - ); + // A base from before tests/dependencies/rescript-react moved to + // packages/rescript-react still has the project there; the next pull + // request in the stack drops that fallback. + const react = + [ + path.join(projectCheckout, "packages", "rescript-react"), + path.join(projectCheckout, "tests", "dependencies", "rescript-react"), + ].find(dir => fs.existsSync(dir)) ?? + path.join(projectCheckout, "packages", "rescript-react"); copySources(path.join(react, "src"), path.join(scope, "react", "src")); fs.copyFileSync( path.join(react, "rescript.json"), diff --git a/scripts/test.js b/scripts/test.js index 46273403434..b674ac23b01 100644 --- a/scripts/test.js +++ b/scripts/test.js @@ -73,7 +73,7 @@ if (ounitTest) { if (mochaTest) { const beltPackageDir = path.join(projectDir, "packages/@rescript/belt"); - const beltTestDir = path.join(projectDir, "tests/belt_tests"); + const beltTestDir = path.join(projectDir, "tests/runtime_tests/belt"); // No need to clean beforehand, the build system detects changes to the compiler binary // and rebuilds automatically in that case. @@ -101,8 +101,8 @@ if (mochaTest) { "-t", "10000", "tests/compiler_tests/src/**/*_test.mjs", - "tests/belt_tests/src/**/*_test.mjs", - "tests/cli_tests/*_test.mjs", + "tests/runtime_tests/belt/src/**/*_test.mjs", + "tests/package_tests/*_test.mjs", // jsx_preserve_test.mjs contains JSX, which Node cannot load; the // file exists to pin the preserved-JSX output. "--ignore", @@ -147,7 +147,7 @@ if (mochaTest) { stdio: "inherit", }); - await node("tests/commonjs_tests/src/belt_import.js", [], { + await node("tests/runtime_tests/commonjs/src/belt_import.js", [], { cwd: projectDir, stdio: "inherit", }); diff --git a/tests/dependencies/rescript-react/.gitignore b/tests/dependencies/rescript-react/.gitignore deleted file mode 100644 index 1b19cda82ce..00000000000 --- a/tests/dependencies/rescript-react/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.js -*.mjs \ No newline at end of file diff --git a/tests/cli_tests/platform_test.mjs b/tests/package_tests/platform_test.mjs similarity index 100% rename from tests/cli_tests/platform_test.mjs rename to tests/package_tests/platform_test.mjs diff --git a/tests/belt_tests/package.json b/tests/runtime_tests/belt/package.json similarity index 100% rename from tests/belt_tests/package.json rename to tests/runtime_tests/belt/package.json diff --git a/tests/belt_tests/rescript.json b/tests/runtime_tests/belt/rescript.json similarity index 100% rename from tests/belt_tests/rescript.json rename to tests/runtime_tests/belt/rescript.json diff --git a/tests/belt_tests/src/array_data_util.mjs b/tests/runtime_tests/belt/src/array_data_util.mjs similarity index 100% rename from tests/belt_tests/src/array_data_util.mjs rename to tests/runtime_tests/belt/src/array_data_util.mjs diff --git a/tests/belt_tests/src/array_data_util.res b/tests/runtime_tests/belt/src/array_data_util.res similarity index 100% rename from tests/belt_tests/src/array_data_util.res rename to tests/runtime_tests/belt/src/array_data_util.res diff --git a/tests/belt_tests/src/belt_deferred_signature_copy_test.mjs b/tests/runtime_tests/belt/src/belt_deferred_signature_copy_test.mjs similarity index 100% rename from tests/belt_tests/src/belt_deferred_signature_copy_test.mjs rename to tests/runtime_tests/belt/src/belt_deferred_signature_copy_test.mjs diff --git a/tests/belt_tests/src/belt_deferred_signature_copy_test.res b/tests/runtime_tests/belt/src/belt_deferred_signature_copy_test.res similarity index 100% rename from tests/belt_tests/src/belt_deferred_signature_copy_test.res rename to tests/runtime_tests/belt/src/belt_deferred_signature_copy_test.res diff --git a/tests/belt_tests/src/belt_float_test.mjs b/tests/runtime_tests/belt/src/belt_float_test.mjs similarity index 100% rename from tests/belt_tests/src/belt_float_test.mjs rename to tests/runtime_tests/belt/src/belt_float_test.mjs diff --git a/tests/belt_tests/src/belt_float_test.res b/tests/runtime_tests/belt/src/belt_float_test.res similarity index 100% rename from tests/belt_tests/src/belt_float_test.res rename to tests/runtime_tests/belt/src/belt_float_test.res diff --git a/tests/belt_tests/src/belt_hashmap_test.mjs b/tests/runtime_tests/belt/src/belt_hashmap_test.mjs similarity index 100% rename from tests/belt_tests/src/belt_hashmap_test.mjs rename to tests/runtime_tests/belt/src/belt_hashmap_test.mjs diff --git a/tests/belt_tests/src/belt_hashmap_test.res b/tests/runtime_tests/belt/src/belt_hashmap_test.res similarity index 100% rename from tests/belt_tests/src/belt_hashmap_test.res rename to tests/runtime_tests/belt/src/belt_hashmap_test.res diff --git a/tests/belt_tests/src/belt_hashset_int_test.mjs b/tests/runtime_tests/belt/src/belt_hashset_int_test.mjs similarity index 100% rename from tests/belt_tests/src/belt_hashset_int_test.mjs rename to tests/runtime_tests/belt/src/belt_hashset_int_test.mjs diff --git a/tests/belt_tests/src/belt_hashset_int_test.res b/tests/runtime_tests/belt/src/belt_hashset_int_test.res similarity index 100% rename from tests/belt_tests/src/belt_hashset_int_test.res rename to tests/runtime_tests/belt/src/belt_hashset_int_test.res diff --git a/tests/belt_tests/src/belt_int_test.mjs b/tests/runtime_tests/belt/src/belt_int_test.mjs similarity index 100% rename from tests/belt_tests/src/belt_int_test.mjs rename to tests/runtime_tests/belt/src/belt_int_test.mjs diff --git a/tests/belt_tests/src/belt_int_test.res b/tests/runtime_tests/belt/src/belt_int_test.res similarity index 100% rename from tests/belt_tests/src/belt_int_test.res rename to tests/runtime_tests/belt/src/belt_int_test.res diff --git a/tests/belt_tests/src/belt_list_test.mjs b/tests/runtime_tests/belt/src/belt_list_test.mjs similarity index 100% rename from tests/belt_tests/src/belt_list_test.mjs rename to tests/runtime_tests/belt/src/belt_list_test.mjs diff --git a/tests/belt_tests/src/belt_list_test.res b/tests/runtime_tests/belt/src/belt_list_test.res similarity index 100% rename from tests/belt_tests/src/belt_list_test.res rename to tests/runtime_tests/belt/src/belt_list_test.res diff --git a/tests/belt_tests/src/belt_mapint_test.mjs b/tests/runtime_tests/belt/src/belt_mapint_test.mjs similarity index 100% rename from tests/belt_tests/src/belt_mapint_test.mjs rename to tests/runtime_tests/belt/src/belt_mapint_test.mjs diff --git a/tests/belt_tests/src/belt_mapint_test.res b/tests/runtime_tests/belt/src/belt_mapint_test.res similarity index 100% rename from tests/belt_tests/src/belt_mapint_test.res rename to tests/runtime_tests/belt/src/belt_mapint_test.res diff --git a/tests/belt_tests/src/belt_reduce_removal_test.mjs b/tests/runtime_tests/belt/src/belt_reduce_removal_test.mjs similarity index 100% rename from tests/belt_tests/src/belt_reduce_removal_test.mjs rename to tests/runtime_tests/belt/src/belt_reduce_removal_test.mjs diff --git a/tests/belt_tests/src/belt_reduce_removal_test.res b/tests/runtime_tests/belt/src/belt_reduce_removal_test.res similarity index 100% rename from tests/belt_tests/src/belt_reduce_removal_test.res rename to tests/runtime_tests/belt/src/belt_reduce_removal_test.res diff --git a/tests/belt_tests/src/belt_result_alias_test.mjs b/tests/runtime_tests/belt/src/belt_result_alias_test.mjs similarity index 100% rename from tests/belt_tests/src/belt_result_alias_test.mjs rename to tests/runtime_tests/belt/src/belt_result_alias_test.mjs diff --git a/tests/belt_tests/src/belt_result_alias_test.res b/tests/runtime_tests/belt/src/belt_result_alias_test.res similarity index 100% rename from tests/belt_tests/src/belt_result_alias_test.res rename to tests/runtime_tests/belt/src/belt_result_alias_test.res diff --git a/tests/belt_tests/src/belt_sortarray_test.mjs b/tests/runtime_tests/belt/src/belt_sortarray_test.mjs similarity index 100% rename from tests/belt_tests/src/belt_sortarray_test.mjs rename to tests/runtime_tests/belt/src/belt_sortarray_test.mjs diff --git a/tests/belt_tests/src/belt_sortarray_test.res b/tests/runtime_tests/belt/src/belt_sortarray_test.res similarity index 100% rename from tests/belt_tests/src/belt_sortarray_test.res rename to tests/runtime_tests/belt/src/belt_sortarray_test.res diff --git a/tests/belt_tests/src/bs_array_test.mjs b/tests/runtime_tests/belt/src/bs_array_test.mjs similarity index 100% rename from tests/belt_tests/src/bs_array_test.mjs rename to tests/runtime_tests/belt/src/bs_array_test.mjs diff --git a/tests/belt_tests/src/bs_array_test.res b/tests/runtime_tests/belt/src/bs_array_test.res similarity index 100% rename from tests/belt_tests/src/bs_array_test.res rename to tests/runtime_tests/belt/src/bs_array_test.res diff --git a/tests/belt_tests/src/bs_map_set_dict_test.mjs b/tests/runtime_tests/belt/src/bs_map_set_dict_test.mjs similarity index 100% rename from tests/belt_tests/src/bs_map_set_dict_test.mjs rename to tests/runtime_tests/belt/src/bs_map_set_dict_test.mjs diff --git a/tests/belt_tests/src/bs_map_set_dict_test.res b/tests/runtime_tests/belt/src/bs_map_set_dict_test.res similarity index 100% rename from tests/belt_tests/src/bs_map_set_dict_test.res rename to tests/runtime_tests/belt/src/bs_map_set_dict_test.res diff --git a/tests/belt_tests/src/bs_map_test.mjs b/tests/runtime_tests/belt/src/bs_map_test.mjs similarity index 100% rename from tests/belt_tests/src/bs_map_test.mjs rename to tests/runtime_tests/belt/src/bs_map_test.mjs diff --git a/tests/belt_tests/src/bs_map_test.res b/tests/runtime_tests/belt/src/bs_map_test.res similarity index 100% rename from tests/belt_tests/src/bs_map_test.res rename to tests/runtime_tests/belt/src/bs_map_test.res diff --git a/tests/belt_tests/src/bs_mutable_set_test.mjs b/tests/runtime_tests/belt/src/bs_mutable_set_test.mjs similarity index 100% rename from tests/belt_tests/src/bs_mutable_set_test.mjs rename to tests/runtime_tests/belt/src/bs_mutable_set_test.mjs diff --git a/tests/belt_tests/src/bs_mutable_set_test.res b/tests/runtime_tests/belt/src/bs_mutable_set_test.res similarity index 100% rename from tests/belt_tests/src/bs_mutable_set_test.res rename to tests/runtime_tests/belt/src/bs_mutable_set_test.res diff --git a/tests/belt_tests/src/bs_poly_map_test.mjs b/tests/runtime_tests/belt/src/bs_poly_map_test.mjs similarity index 100% rename from tests/belt_tests/src/bs_poly_map_test.mjs rename to tests/runtime_tests/belt/src/bs_poly_map_test.mjs diff --git a/tests/belt_tests/src/bs_poly_map_test.res b/tests/runtime_tests/belt/src/bs_poly_map_test.res similarity index 100% rename from tests/belt_tests/src/bs_poly_map_test.res rename to tests/runtime_tests/belt/src/bs_poly_map_test.res diff --git a/tests/belt_tests/src/bs_poly_mutable_map_test.mjs b/tests/runtime_tests/belt/src/bs_poly_mutable_map_test.mjs similarity index 100% rename from tests/belt_tests/src/bs_poly_mutable_map_test.mjs rename to tests/runtime_tests/belt/src/bs_poly_mutable_map_test.mjs diff --git a/tests/belt_tests/src/bs_poly_mutable_map_test.res b/tests/runtime_tests/belt/src/bs_poly_mutable_map_test.res similarity index 100% rename from tests/belt_tests/src/bs_poly_mutable_map_test.res rename to tests/runtime_tests/belt/src/bs_poly_mutable_map_test.res diff --git a/tests/belt_tests/src/bs_poly_mutable_set_test.mjs b/tests/runtime_tests/belt/src/bs_poly_mutable_set_test.mjs similarity index 100% rename from tests/belt_tests/src/bs_poly_mutable_set_test.mjs rename to tests/runtime_tests/belt/src/bs_poly_mutable_set_test.mjs diff --git a/tests/belt_tests/src/bs_poly_mutable_set_test.res b/tests/runtime_tests/belt/src/bs_poly_mutable_set_test.res similarity index 100% rename from tests/belt_tests/src/bs_poly_mutable_set_test.res rename to tests/runtime_tests/belt/src/bs_poly_mutable_set_test.res diff --git a/tests/belt_tests/src/bs_poly_set_test.mjs b/tests/runtime_tests/belt/src/bs_poly_set_test.mjs similarity index 100% rename from tests/belt_tests/src/bs_poly_set_test.mjs rename to tests/runtime_tests/belt/src/bs_poly_set_test.mjs diff --git a/tests/belt_tests/src/bs_poly_set_test.res b/tests/runtime_tests/belt/src/bs_poly_set_test.res similarity index 100% rename from tests/belt_tests/src/bs_poly_set_test.res rename to tests/runtime_tests/belt/src/bs_poly_set_test.res diff --git a/tests/belt_tests/src/bs_queue_test.mjs b/tests/runtime_tests/belt/src/bs_queue_test.mjs similarity index 100% rename from tests/belt_tests/src/bs_queue_test.mjs rename to tests/runtime_tests/belt/src/bs_queue_test.mjs diff --git a/tests/belt_tests/src/bs_queue_test.res b/tests/runtime_tests/belt/src/bs_queue_test.res similarity index 100% rename from tests/belt_tests/src/bs_queue_test.res rename to tests/runtime_tests/belt/src/bs_queue_test.res diff --git a/tests/belt_tests/src/bs_set_int_test.mjs b/tests/runtime_tests/belt/src/bs_set_int_test.mjs similarity index 100% rename from tests/belt_tests/src/bs_set_int_test.mjs rename to tests/runtime_tests/belt/src/bs_set_int_test.mjs diff --git a/tests/belt_tests/src/bs_set_int_test.res b/tests/runtime_tests/belt/src/bs_set_int_test.res similarity index 100% rename from tests/belt_tests/src/bs_set_int_test.res rename to tests/runtime_tests/belt/src/bs_set_int_test.res diff --git a/tests/belt_tests/src/bs_stack_test.mjs b/tests/runtime_tests/belt/src/bs_stack_test.mjs similarity index 100% rename from tests/belt_tests/src/bs_stack_test.mjs rename to tests/runtime_tests/belt/src/bs_stack_test.mjs diff --git a/tests/belt_tests/src/bs_stack_test.res b/tests/runtime_tests/belt/src/bs_stack_test.res similarity index 100% rename from tests/belt_tests/src/bs_stack_test.res rename to tests/runtime_tests/belt/src/bs_stack_test.res diff --git a/tests/belt_tests/src/demo_int_map.mjs b/tests/runtime_tests/belt/src/demo_int_map.mjs similarity index 100% rename from tests/belt_tests/src/demo_int_map.mjs rename to tests/runtime_tests/belt/src/demo_int_map.mjs diff --git a/tests/belt_tests/src/demo_int_map.res b/tests/runtime_tests/belt/src/demo_int_map.res similarity index 100% rename from tests/belt_tests/src/demo_int_map.res rename to tests/runtime_tests/belt/src/demo_int_map.res diff --git a/tests/belt_tests/src/demo_int_map.resi b/tests/runtime_tests/belt/src/demo_int_map.resi similarity index 100% rename from tests/belt_tests/src/demo_int_map.resi rename to tests/runtime_tests/belt/src/demo_int_map.resi diff --git a/tests/belt_tests/src/gpr_4265_test.mjs b/tests/runtime_tests/belt/src/gpr_4265_test.mjs similarity index 100% rename from tests/belt_tests/src/gpr_4265_test.mjs rename to tests/runtime_tests/belt/src/gpr_4265_test.mjs diff --git a/tests/belt_tests/src/gpr_4265_test.res b/tests/runtime_tests/belt/src/gpr_4265_test.res similarity index 100% rename from tests/belt_tests/src/gpr_4265_test.res rename to tests/runtime_tests/belt/src/gpr_4265_test.res diff --git a/tests/belt_tests/src/hash_test.mjs b/tests/runtime_tests/belt/src/hash_test.mjs similarity index 100% rename from tests/belt_tests/src/hash_test.mjs rename to tests/runtime_tests/belt/src/hash_test.mjs diff --git a/tests/belt_tests/src/hash_test.res b/tests/runtime_tests/belt/src/hash_test.res similarity index 100% rename from tests/belt_tests/src/hash_test.res rename to tests/runtime_tests/belt/src/hash_test.res diff --git a/tests/belt_tests/src/hash_utils.mjs b/tests/runtime_tests/belt/src/hash_utils.mjs similarity index 100% rename from tests/belt_tests/src/hash_utils.mjs rename to tests/runtime_tests/belt/src/hash_utils.mjs diff --git a/tests/belt_tests/src/hash_utils.res b/tests/runtime_tests/belt/src/hash_utils.res similarity index 100% rename from tests/belt_tests/src/hash_utils.res rename to tests/runtime_tests/belt/src/hash_utils.res diff --git a/tests/belt_tests/src/hash_utils.resi b/tests/runtime_tests/belt/src/hash_utils.resi similarity index 100% rename from tests/belt_tests/src/hash_utils.resi rename to tests/runtime_tests/belt/src/hash_utils.resi diff --git a/tests/belt_tests/src/inner_unused.mjs b/tests/runtime_tests/belt/src/inner_unused.mjs similarity index 100% rename from tests/belt_tests/src/inner_unused.mjs rename to tests/runtime_tests/belt/src/inner_unused.mjs diff --git a/tests/belt_tests/src/inner_unused.res b/tests/runtime_tests/belt/src/inner_unused.res similarity index 100% rename from tests/belt_tests/src/inner_unused.res rename to tests/runtime_tests/belt/src/inner_unused.res diff --git a/tests/belt_tests/src/int_map.mjs b/tests/runtime_tests/belt/src/int_map.mjs similarity index 100% rename from tests/belt_tests/src/int_map.mjs rename to tests/runtime_tests/belt/src/int_map.mjs diff --git a/tests/belt_tests/src/int_map.res b/tests/runtime_tests/belt/src/int_map.res similarity index 100% rename from tests/belt_tests/src/int_map.res rename to tests/runtime_tests/belt/src/int_map.res diff --git a/tests/belt_tests/src/list_test.mjs b/tests/runtime_tests/belt/src/list_test.mjs similarity index 100% rename from tests/belt_tests/src/list_test.mjs rename to tests/runtime_tests/belt/src/list_test.mjs diff --git a/tests/belt_tests/src/list_test.res b/tests/runtime_tests/belt/src/list_test.res similarity index 100% rename from tests/belt_tests/src/list_test.res rename to tests/runtime_tests/belt/src/list_test.res diff --git a/tests/belt_tests/src/map_find_test.mjs b/tests/runtime_tests/belt/src/map_find_test.mjs similarity index 100% rename from tests/belt_tests/src/map_find_test.mjs rename to tests/runtime_tests/belt/src/map_find_test.mjs diff --git a/tests/belt_tests/src/map_find_test.res b/tests/runtime_tests/belt/src/map_find_test.res similarity index 100% rename from tests/belt_tests/src/map_find_test.res rename to tests/runtime_tests/belt/src/map_find_test.res diff --git a/tests/belt_tests/src/mocha.mjs b/tests/runtime_tests/belt/src/mocha.mjs similarity index 100% rename from tests/belt_tests/src/mocha.mjs rename to tests/runtime_tests/belt/src/mocha.mjs diff --git a/tests/belt_tests/src/mocha.res b/tests/runtime_tests/belt/src/mocha.res similarity index 100% rename from tests/belt_tests/src/mocha.res rename to tests/runtime_tests/belt/src/mocha.res diff --git a/tests/belt_tests/src/node_assert.mjs b/tests/runtime_tests/belt/src/node_assert.mjs similarity index 100% rename from tests/belt_tests/src/node_assert.mjs rename to tests/runtime_tests/belt/src/node_assert.mjs diff --git a/tests/belt_tests/src/node_assert.res b/tests/runtime_tests/belt/src/node_assert.res similarity index 100% rename from tests/belt_tests/src/node_assert.res rename to tests/runtime_tests/belt/src/node_assert.res diff --git a/tests/belt_tests/src/rec_module_opt.mjs b/tests/runtime_tests/belt/src/rec_module_opt.mjs similarity index 100% rename from tests/belt_tests/src/rec_module_opt.mjs rename to tests/runtime_tests/belt/src/rec_module_opt.mjs diff --git a/tests/belt_tests/src/rec_module_opt.res b/tests/runtime_tests/belt/src/rec_module_opt.res similarity index 100% rename from tests/belt_tests/src/rec_module_opt.res rename to tests/runtime_tests/belt/src/rec_module_opt.res diff --git a/tests/belt_tests/src/test_array.mjs b/tests/runtime_tests/belt/src/test_array.mjs similarity index 100% rename from tests/belt_tests/src/test_array.mjs rename to tests/runtime_tests/belt/src/test_array.mjs diff --git a/tests/belt_tests/src/test_array.res b/tests/runtime_tests/belt/src/test_array.res similarity index 100% rename from tests/belt_tests/src/test_array.res rename to tests/runtime_tests/belt/src/test_array.res diff --git a/tests/belt_tests/src/test_for_map2.mjs b/tests/runtime_tests/belt/src/test_for_map2.mjs similarity index 100% rename from tests/belt_tests/src/test_for_map2.mjs rename to tests/runtime_tests/belt/src/test_for_map2.mjs diff --git a/tests/belt_tests/src/test_for_map2.res b/tests/runtime_tests/belt/src/test_for_map2.res similarity index 100% rename from tests/belt_tests/src/test_for_map2.res rename to tests/runtime_tests/belt/src/test_for_map2.res diff --git a/tests/belt_tests/src/test_int_map_find.mjs b/tests/runtime_tests/belt/src/test_int_map_find.mjs similarity index 100% rename from tests/belt_tests/src/test_int_map_find.mjs rename to tests/runtime_tests/belt/src/test_int_map_find.mjs diff --git a/tests/belt_tests/src/test_int_map_find.res b/tests/runtime_tests/belt/src/test_int_map_find.res similarity index 100% rename from tests/belt_tests/src/test_int_map_find.res rename to tests/runtime_tests/belt/src/test_int_map_find.res diff --git a/tests/belt_tests/src/test_string_map.mjs b/tests/runtime_tests/belt/src/test_string_map.mjs similarity index 100% rename from tests/belt_tests/src/test_string_map.mjs rename to tests/runtime_tests/belt/src/test_string_map.mjs diff --git a/tests/belt_tests/src/test_string_map.res b/tests/runtime_tests/belt/src/test_string_map.res similarity index 100% rename from tests/belt_tests/src/test_string_map.res rename to tests/runtime_tests/belt/src/test_string_map.res diff --git a/tests/belt_tests/src/test_utils.mjs b/tests/runtime_tests/belt/src/test_utils.mjs similarity index 100% rename from tests/belt_tests/src/test_utils.mjs rename to tests/runtime_tests/belt/src/test_utils.mjs diff --git a/tests/belt_tests/src/test_utils.res b/tests/runtime_tests/belt/src/test_utils.res similarity index 100% rename from tests/belt_tests/src/test_utils.res rename to tests/runtime_tests/belt/src/test_utils.res diff --git a/tests/belt_tests/src/ticker.mjs b/tests/runtime_tests/belt/src/ticker.mjs similarity index 100% rename from tests/belt_tests/src/ticker.mjs rename to tests/runtime_tests/belt/src/ticker.mjs diff --git a/tests/belt_tests/src/ticker.res b/tests/runtime_tests/belt/src/ticker.res similarity index 100% rename from tests/belt_tests/src/ticker.res rename to tests/runtime_tests/belt/src/ticker.res diff --git a/tests/commonjs_tests/package.json b/tests/runtime_tests/commonjs/package.json similarity index 100% rename from tests/commonjs_tests/package.json rename to tests/runtime_tests/commonjs/package.json diff --git a/tests/commonjs_tests/rescript.json b/tests/runtime_tests/commonjs/rescript.json similarity index 100% rename from tests/commonjs_tests/rescript.json rename to tests/runtime_tests/commonjs/rescript.json diff --git a/tests/commonjs_tests/src/belt_import.js b/tests/runtime_tests/commonjs/src/belt_import.js similarity index 100% rename from tests/commonjs_tests/src/belt_import.js rename to tests/runtime_tests/commonjs/src/belt_import.js diff --git a/tests/commonjs_tests/src/belt_import.res b/tests/runtime_tests/commonjs/src/belt_import.res similarity index 100% rename from tests/commonjs_tests/src/belt_import.res rename to tests/runtime_tests/commonjs/src/belt_import.res diff --git a/tests/commonjs_tests/src/scope_default_import.js b/tests/runtime_tests/commonjs/src/scope_default_import.js similarity index 100% rename from tests/commonjs_tests/src/scope_default_import.js rename to tests/runtime_tests/commonjs/src/scope_default_import.js diff --git a/tests/commonjs_tests/src/scope_default_import.res b/tests/runtime_tests/commonjs/src/scope_default_import.res similarity index 100% rename from tests/commonjs_tests/src/scope_default_import.res rename to tests/runtime_tests/commonjs/src/scope_default_import.res diff --git a/tests/docstring_tests/.gitignore b/tests/runtime_tests/docstrings/.gitignore similarity index 100% rename from tests/docstring_tests/.gitignore rename to tests/runtime_tests/docstrings/.gitignore diff --git a/tests/docstring_tests/ArrayUtils.res b/tests/runtime_tests/docstrings/ArrayUtils.res similarity index 100% rename from tests/docstring_tests/ArrayUtils.res rename to tests/runtime_tests/docstrings/ArrayUtils.res diff --git a/tests/docstring_tests/ArrayUtils.res.js b/tests/runtime_tests/docstrings/ArrayUtils.res.js similarity index 100% rename from tests/docstring_tests/ArrayUtils.res.js rename to tests/runtime_tests/docstrings/ArrayUtils.res.js diff --git a/tests/docstring_tests/DocTest.res b/tests/runtime_tests/docstrings/DocTest.res similarity index 99% rename from tests/docstring_tests/DocTest.res rename to tests/runtime_tests/docstrings/DocTest.res index b2484606959..1509f24df52 100644 --- a/tests/docstring_tests/DocTest.res +++ b/tests/runtime_tests/docstrings/DocTest.res @@ -1,6 +1,6 @@ open Node -@module("../../cli/common/bins.js") +@module("../../../cli/common/bins.js") external rescript_tools_exe: string = "rescript_tools_exe" // Only major version diff --git a/tests/docstring_tests/DocTest.res.js b/tests/runtime_tests/docstrings/DocTest.res.js similarity index 98% rename from tests/docstring_tests/DocTest.res.js rename to tests/runtime_tests/docstrings/DocTest.res.js index da9384982dd..46d65f046bd 100644 --- a/tests/docstring_tests/DocTest.res.js +++ b/tests/runtime_tests/docstrings/DocTest.res.js @@ -13,7 +13,7 @@ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.mjs"; import * as Primitive_string from "@rescript/runtime/lib/es6/Primitive_string.mjs"; import * as Promises from "node:fs/promises"; import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.mjs"; -import * as BinsJs from "../../cli/common/bins.js"; +import * as BinsJs from "../../../cli/common/bins.js"; let rescript_tools_exe = BinsJs.rescript_tools_exe; diff --git a/tests/docstring_tests/DocTest.resi b/tests/runtime_tests/docstrings/DocTest.resi similarity index 100% rename from tests/docstring_tests/DocTest.resi rename to tests/runtime_tests/docstrings/DocTest.resi diff --git a/tests/docstring_tests/Mocha.res b/tests/runtime_tests/docstrings/Mocha.res similarity index 100% rename from tests/docstring_tests/Mocha.res rename to tests/runtime_tests/docstrings/Mocha.res diff --git a/tests/docstring_tests/Mocha.res.js b/tests/runtime_tests/docstrings/Mocha.res.js similarity index 100% rename from tests/docstring_tests/Mocha.res.js rename to tests/runtime_tests/docstrings/Mocha.res.js diff --git a/tests/docstring_tests/Node.res b/tests/runtime_tests/docstrings/Node.res similarity index 100% rename from tests/docstring_tests/Node.res rename to tests/runtime_tests/docstrings/Node.res diff --git a/tests/docstring_tests/Node.res.js b/tests/runtime_tests/docstrings/Node.res.js similarity index 100% rename from tests/docstring_tests/Node.res.js rename to tests/runtime_tests/docstrings/Node.res.js diff --git a/tests/docstring_tests/SpawnAsync.res b/tests/runtime_tests/docstrings/SpawnAsync.res similarity index 100% rename from tests/docstring_tests/SpawnAsync.res rename to tests/runtime_tests/docstrings/SpawnAsync.res diff --git a/tests/docstring_tests/SpawnAsync.res.js b/tests/runtime_tests/docstrings/SpawnAsync.res.js similarity index 100% rename from tests/docstring_tests/SpawnAsync.res.js rename to tests/runtime_tests/docstrings/SpawnAsync.res.js diff --git a/tests/docstring_tests/package.json b/tests/runtime_tests/docstrings/package.json similarity index 100% rename from tests/docstring_tests/package.json rename to tests/runtime_tests/docstrings/package.json diff --git a/tests/docstring_tests/rescript.json b/tests/runtime_tests/docstrings/rescript.json similarity index 100% rename from tests/docstring_tests/rescript.json rename to tests/runtime_tests/docstrings/rescript.json diff --git a/yarn.config.cjs b/yarn.config.cjs index eb9d504f12c..05f402bcded 100644 --- a/yarn.config.cjs +++ b/yarn.config.cjs @@ -7,6 +7,33 @@ const fs = require("node:fs/promises"); const { defineConfig } = require("@yarnpkg/types"); +/** + * The workspaces that are published to npm: the rescript package at the root + * and the packages in packages/@rescript. Other workspaces with an @rescript + * scope, like the vendored rescript-react in packages/rescript-react, are not. + * + * @param {Yarn.Constraints.Workspace} workspace + */ +function isPublished(workspace) { + return ( + workspace.cwd === "." || workspace.cwd.startsWith("packages/@rescript/") + ); +} + +/** + * Every other workspace must be private: the publish workflow publishes all + * workspaces that are not (`yarn workspaces foreach --no-private`). + * + * @param {Yarn.Constraints.Context} ctx + */ +function enforcePrivateWorkspaces({ Yarn }) { + for (const workspace of Yarn.workspaces()) { + if (!isPublished(workspace)) { + workspace.set("private", true); + } + } +} + /** * @param {Yarn.Constraints.Context} ctx */ @@ -14,11 +41,7 @@ async function enforceCompilerMeta({ Yarn }) { const EXPECTED_VERSION = "13.0.0-alpha.8"; for (const workspace of Yarn.workspaces()) { - const { ident } = workspace.pkg; - if ( - ident === "rescript" || - (workspace.cwd.startsWith("packages") && ident.startsWith("@rescript/")) - ) { + if (isPublished(workspace)) { workspace.set("version", EXPECTED_VERSION); workspace.set("homepage", "https://rescript-lang.org"); workspace.set("bugs", "https://github.com/rescript-lang/rescript/issues"); @@ -74,5 +97,6 @@ async function enforceCompilerMeta({ Yarn }) { module.exports = defineConfig({ async constraints(ctx) { await enforceCompilerMeta(ctx); + enforcePrivateWorkspaces(ctx); }, }); diff --git a/yarn.lock b/yarn.lock index 3818102019b..8478c97b249 100644 --- a/yarn.lock +++ b/yarn.lock @@ -218,9 +218,9 @@ __metadata: languageName: unknown linkType: soft -"@rescript/react@workspace:^, @rescript/react@workspace:tests/dependencies/rescript-react": +"@rescript/react@workspace:^, @rescript/react@workspace:packages/rescript-react": version: 0.0.0-use.local - resolution: "@rescript/react@workspace:tests/dependencies/rescript-react" + resolution: "@rescript/react@workspace:packages/rescript-react" dependencies: rescript: "workspace:^" languageName: unknown @@ -585,9 +585,9 @@ __metadata: languageName: unknown linkType: soft -"@tests/belt@workspace:tests/belt_tests": +"@tests/belt@workspace:tests/runtime_tests/belt": version: 0.0.0-use.local - resolution: "@tests/belt@workspace:tests/belt_tests" + resolution: "@tests/belt@workspace:tests/runtime_tests/belt" dependencies: "@rescript/belt": "workspace:^" mocha: "npm:12.0.3" @@ -595,9 +595,9 @@ __metadata: languageName: unknown linkType: soft -"@tests/docstring-tests@workspace:^, @tests/docstring-tests@workspace:tests/docstring_tests": +"@tests/docstring-tests@workspace:^, @tests/docstring-tests@workspace:tests/runtime_tests/docstrings": version: 0.0.0-use.local - resolution: "@tests/docstring-tests@workspace:tests/docstring_tests" + resolution: "@tests/docstring-tests@workspace:tests/runtime_tests/docstrings" dependencies: "@rescript/belt": "workspace:^" "@rescript/react": "workspace:^" @@ -1365,9 +1365,9 @@ __metadata: languageName: node linkType: hard -"rescript-commonjs-tests@workspace:tests/commonjs_tests": +"rescript-commonjs-tests@workspace:tests/runtime_tests/commonjs": version: 0.0.0-use.local - resolution: "rescript-commonjs-tests@workspace:tests/commonjs_tests" + resolution: "rescript-commonjs-tests@workspace:tests/runtime_tests/commonjs" dependencies: "@rescript/belt": "workspace:^" rescript: "workspace:^"