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
27 changes: 18 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ jobs:
git config --system core.autocrlf false
git config --system core.eol lf
git config --system core.longpaths true
git config --system core.symlinks true

- name: Checkout
uses: actions/checkout@v7
Expand Down Expand Up @@ -205,20 +206,28 @@ jobs:
- name: Check for diffs in tests folder
run: git diff --ignore-cr-at-eol --exit-code tests

# On Windows, after running setup-ocaml (if it wasn't cached yet or the cache couldn't be restored),
# Cygwin bash is used instead of Git Bash for Windows, breaking the test scripts below.
# So we need to adjust the path to bring back Git Bash for Windows.
- name: "Windows: Use Git Bash"
if: ${{ runner.os == 'Windows' }}
run: echo "C:\Program Files\Git\bin" >> $GITHUB_PATH
shell: bash

# Git Bash does not include make.
- name: "Windows: Install make"
if: ${{ runner.os == 'Windows' }}
run: command -v make || choco install make --no-progress
shell: bash

# Linux runs these tests in the coverage workflow.
- name: Run analysis / tools tests
if: runner.os != 'Windows' && runner.os != 'Linux'
if: runner.os != 'Linux'
run: opam exec -- make -C tests/analysis_tests test && make -C tests/tools_tests test
shell: bash

- name: Run gentype tests
if: runner.os != 'Windows'
run: make -C tests/gentype_tests/typescript-react-example clean test

# On Windows, after running setup-ocaml (if it wasn't cached yet or the cache couldn't be restored),
# Cygwin bash is used instead of Git Bash for Windows, breaking the rewatch tests.
# So we need to adjust the path to bring back Git Bash for Windows.
- name: Rewatch tests need Git Bash for Windows
if: ${{ runner.os == 'Windows' }}
run: echo "C:\Program Files\Git\bin" >> $GITHUB_PATH
shell: bash

- name: Run OCaml rewatch parity tests
Expand Down
5 changes: 4 additions & 1 deletion analysis/src/cli.ml
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,11 @@ let test ~state ~path =
let lines = text |> String.split_on_char '\n' in
let process_line i line =
let create_current_file () =
(* Binary mode keeps the copy's LF line endings on Windows, so dumped
source text matches the original file. *)
let current_file, cout =
Filename.open_temp_file "def" ("txt." ^ Filename.extension path)
Filename.open_temp_file ~mode:[Open_binary] "def"
("txt." ^ Filename.extension path)
in
let remove_line_comment l =
let len = String.length l in
Expand Down
1 change: 1 addition & 0 deletions changes/windows-ci-tests.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Run the full compiler unit tests, runtime docstring tests, analysis, tools and gentype tests, and the `unicode` and `duplicated_symlinked_packages` build tests on Windows CI.
7 changes: 5 additions & 2 deletions lib_dev/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export const compilerBinDir = path.resolve(
);

/**
* path: `<projectDir>/_build/install/default/bin/ounit_tests`
* path: `<projectDir>/_build/install/default/bin/ounit_tests[.exe]`
*/
export const ounitTestBin = path.join(compilerBinDir, "ounit_tests");
export const ounitTestBin = path.join(
compilerBinDir,
process.platform === "win32" ? "ounit_tests.exe" : "ounit_tests",
);
36 changes: 4 additions & 32 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,35 +64,9 @@ if (formatTest) {
}

if (ounitTest) {
if (process.platform === "win32") {
// GenType's drive-root regression needs the native Windows Filename module.
const binary = path.join(
projectDir,
"_build/default/tests/ounit_tests/ounit_tests_main.exe",
);
const { stdout } = await execBin(binary, ["-list-test"], {
shell: false,
throwOnFail: true,
});
const tests = stdout
.split(/\r?\n/)
.filter(test => test.includes(":gentype:"));
if (tests.length === 0) {
throw new Error("No GenType unit tests found");
}
await execBin(
binary,
tests.flatMap(test => ["-only-test", test]),
{
stdio: "inherit",
shell: false,
},
);
} else {
await execBin(ounitTestBin, [], {
stdio: "inherit",
});
}
await execBin(ounitTestBin, [], {
stdio: "inherit",
});
}

if (mochaTest) {
Expand Down Expand Up @@ -197,9 +171,7 @@ if (buildTest) {
}

if (runtimeDocstrings) {
if (process.platform === "win32") {
console.log(`Skipping docstrings tests on ${process.platform}`);
} else if (process.platform === "darwin" && os.release().startsWith("22")) {
if (process.platform === "darwin" && os.release().startsWith("22")) {
// Workaround for intermittent hangs in CI
console.log("Skipping docstrings tests on macOS 13");
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis_tests/tests-generic-jsx-transform/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build:
yarn build

test: build
./test.sh
bash ./test.sh

clean:
yarn clean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build:
yarn build > /dev/null 2>&1 || true

test: build
./test.sh
bash ./test.sh

clean:
yarn clean
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis_tests/tests-namespaced-references/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ build:
cp lib/bs/MyNamespace.cmt lib/bs/___incremental/MyNamespace.cmt

test: build
./test.sh
bash ./test.sh

clean:
yarn clean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ COPIES ?= 50

generate:
chmod +x generate.sh
./generate.sh $(COPIES)
bash ./generate.sh $(COPIES)

node_modules/.bin/rescript:
yarn install
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis_tests/tests-reanalyze/deadcode/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build:
yarn build

test: build node_modules/.bin/rescript
./test.sh
bash ./test.sh

# Order-independence test for reanalyze - not run by default (takes longer)
# Verifies that processing files in different orders produces identical results
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis_tests/tests-reanalyze/termination/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build:
yarn build

test: build
./test.sh
bash ./test.sh

clean:
yarn clean
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis_tests/tests-sourcedirs-dependency/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build:
yarn build

test: build
./test.sh
bash ./test.sh

clean:
yarn clean
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis_tests/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build:
yarn build

test: build
./test.sh
bash ./test.sh

clean:
yarn clean
Expand Down
4 changes: 4 additions & 0 deletions tests/analysis_tests/tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ for file in src/*.{res,resi}; do
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
if [ "$RUNNER_OS" == "Windows" ]; then
perl -pi -e 's/\r\n/\n/g' -- $output
# Completion data holds a native path. Use the snapshots' separator.
perl -pi -e 's{(?<="filePath": ")[^"]*}{$& =~ s#\\\\#/#gr}ge' -- $output
fi
done

Expand All @@ -13,6 +15,8 @@ for file in not_compiled/*.{res,resi}; do
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
if [ "$RUNNER_OS" == "Windows" ]; then
perl -pi -e 's/\r\n/\n/g' -- $output
# Completion data holds a native path. Use the snapshots' separator.
perl -pi -e 's{(?<="filePath": ")[^"]*}{$& =~ s#\\\\#/#gr}ge' -- $output
fi
done

Expand Down
18 changes: 15 additions & 3 deletions tests/build_tests/duplicated_symlinked_packages/input.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @ts-check

import * as assert from "node:assert";
import * as fs from "node:fs/promises";
import * as path from "node:path";
import { runtimePath } from "#cli/runtime";
import { setup } from "#dev/process";

Expand All @@ -9,13 +11,23 @@ process.env.RESCRIPT_RUNTIME = runtimePath;

const { execBuild, execClean } = setup(import.meta.dirname);

if (process.platform === "win32") {
console.log("Skipping test on Windows");
// Without core.symlinks, Git on Windows checks the links out as plain files.
// CI enables it, so only local checkouts may skip.
const link = await fs.lstat(
path.join(import.meta.dirname, "node_modules", "a"),
);
if (!link.isSymbolicLink()) {
if (process.env.CI) {
assert.fail("node_modules/a was not checked out as a symlink");
}
console.log("Skipping test: symlinks are not checked out as symlinks");
process.exit(0);
}

await execClean();
const { stderr } = await execBuild();
const { stderr: rawStderr } = await execBuild();
// Windows joins the package paths with backslashes.
const stderr = rawStderr.replaceAll("\\", "/");

// c reaches a and b through node_modules symlinks and counts once; z has two
// copies, node_modules/z and a/node_modules/z, the one duplicate to report.
Expand Down
5 changes: 0 additions & 5 deletions tests/build_tests/unicode/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ import { setup } from "#dev/process";

const { execBuildOrThrow, execClean } = setup(import.meta.dirname);

if (process.platform === "win32") {
console.log("Skipping test on Windows");
process.exit(0);
}

await execBuildOrThrow();

await fs.access(
Expand Down
6 changes: 4 additions & 2 deletions tests/ounit_tests/ounit_compiler_request_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1604,9 +1604,11 @@ let concurrent_async_context_tests _context =
write directory "Sync.res" sync_source;
Domain.spawn (fun () ->
ignore (Atomic.fetch_and_add ready 1);
let deadline = Unix.gettimeofday () +. 5. in
(* Sleep rather than spin: each spawn stops the world, and spinning
domains outnumbering the cores starve the domain that spawns. *)
let deadline = Unix.gettimeofday () +. 30. in
while Atomic.get ready < 8 && Unix.gettimeofday () < deadline do
Domain.cpu_relax ()
Unix.sleepf 0.001
done;
check (Atomic.get ready = 8) "async requests did not overlap";
for _ = 1 to 3 do
Expand Down
2 changes: 1 addition & 1 deletion tests/tools_tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build:
yarn build

test: build
./test.sh
bash ./test.sh
yarn build

clean:
Expand Down
9 changes: 8 additions & 1 deletion tests/tools_tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@ for file in src/*.{res,resi}; do
fi
done

# bsc runs the PPX command through the system shell, and cmd.exe needs
# backslashes in the program path.
ppx_command="../../_build/install/default/bin/rescript-tools ppx"
if [ "${RUNNER_OS:-}" == "Windows" ]; then
ppx_command='..\..\_build\install\default\bin\rescript-tools.exe ppx'
fi

for file in ppx/*.res; do
output="src/expected/$(basename $file).jsout"
../../cli/bsc.js -ppx "../../_build/install/default/bin/rescript-tools ppx" $file > $output
../../cli/bsc.js -ppx "$ppx_command" $file > $output
if [ "${RUNNER_OS:-}" == "Windows" ]; then
perl -pi -e 's/\r\n/\n/g' -- $output
fi
Expand Down
Loading