Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
*.resi linguist-language=ReScript

.yarn/releases/* binary linguist-vendored
tests/dependencies/** linguist-vendored
packages/rescript-react/** linguist-vendored
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions changes/rescript-react-package.internal.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions changes/runtime-test-suites.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Group the Belt, CommonJS and docstring suites under `tests/runtime_tests` and move the CLI platform test to `tests/package_tests`.
16 changes: 12 additions & 4 deletions lib_dev/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,22 @@ export const projectTestDir = path.resolve(testDir, "project_tests");
export const errorTestDir = path.resolve(testDir, "error_tests");

/**
* path: `<projectDir>/tests/docstring_tests/`
* path: `<projectDir>/tests/runtime_tests/docstrings/`
*/
export const docstringTestDir = path.resolve(testDir, "docstring_tests");
export const docstringTestDir = path.resolve(
testDir,
"runtime_tests",
"docstrings",
);

/**
* path: `<projectDir>/tests/commonjs_tests/`
* path: `<projectDir>/tests/runtime_tests/commonjs/`
*/
export const commonjsTestDir = path.resolve(testDir, "commonjs_tests");
export const commonjsTestDir = path.resolve(
testDir,
"runtime_tests",
"commonjs",
);

/**
* path: `<projectDir>/compiler/version/rescript_version.ml`
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions packages/rescript-react/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.js
*.mjs
lib/
32 changes: 12 additions & 20 deletions scripts/compilerBenchmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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"),
Expand Down
8 changes: 4 additions & 4 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
});
Expand Down
2 changes: 0 additions & 2 deletions tests/dependencies/rescript-react/.gitignore

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
34 changes: 29 additions & 5 deletions yarn.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,41 @@
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
*/
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");
Expand Down Expand Up @@ -74,5 +97,6 @@ async function enforceCompilerMeta({ Yarn }) {
module.exports = defineConfig({
async constraints(ctx) {
await enforceCompilerMeta(ctx);
enforcePrivateWorkspaces(ctx);
},
});
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -585,19 +585,19 @@ __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"
rescript: "workspace:^"
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:^"
Expand Down Expand Up @@ -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:^"
Expand Down
Loading