From 493f111a6b33bfd009e3c0b4c588994f1e62b174 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 26 Oct 2025 09:06:32 +0100 Subject: [PATCH 1/2] suite-ci.sh -> suite.sh --- .github/workflows/ci.yml | 4 ++-- AGENTS.md | 2 +- Makefile | 2 +- rewatch/tests/suite-ci.sh | 47 --------------------------------------- rewatch/tests/suite.sh | 46 +++++++++++++++++++++++++++++++++++++- 5 files changed, 49 insertions(+), 52 deletions(-) delete mode 100755 rewatch/tests/suite-ci.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c1393e5c6..c3405f124f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -363,7 +363,7 @@ jobs: shell: bash - name: Run rewatch tests - run: ./rewatch/tests/suite-ci.sh + run: ./rewatch/tests/suite.sh shell: bash - name: Run syntax benchmarks @@ -671,7 +671,7 @@ jobs: working-directory: rewatch/testrepo - name: Run rewatch integration tests - run: ./rewatch/tests/suite-ci.sh node_modules/.bin/rescript + run: ./rewatch/tests/suite.sh node_modules/.bin/rescript shell: bash publish: diff --git a/AGENTS.md b/AGENTS.md index 30801092cb..9afb254749 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -373,7 +373,7 @@ make test-rewatch # Run integration tests **Note**: The rewatch project is located in the `rewatch/` directory with its own `Cargo.toml` file. All cargo commands should be run from the project root using the `--manifest-path rewatch/Cargo.toml` flag, as shown in the CI workflow. -**Integration Tests**: The `make test-rewatch` command runs bash-based integration tests located in `rewatch/tests/suite-ci.sh`. These tests use the `rewatch/testrepo/` directory as a test workspace with various package configurations to verify rewatch's behavior across different scenarios. +**Integration Tests**: The `make test-rewatch` command runs bash-based integration tests located in `rewatch/tests/suite.sh`. These tests use the `rewatch/testrepo/` directory as a test workspace with various package configurations to verify rewatch's behavior across different scenarios. #### Debugging diff --git a/Makefile b/Makefile index c5e274b66c..d1b5935bd4 100644 --- a/Makefile +++ b/Makefile @@ -176,7 +176,7 @@ test-gentype: | $(YARN_INSTALL_STAMP) make -C tests/gentype_tests/stdlib-no-shims clean test test-rewatch: $(RESCRIPT_EXE) | $(YARN_INSTALL_STAMP) - ./rewatch/tests/suite-ci.sh + ./rewatch/tests/suite.sh test-all: test test-gentype test-analysis test-tools test-rewatch diff --git a/rewatch/tests/suite-ci.sh b/rewatch/tests/suite-ci.sh deleted file mode 100755 index 0e6c4a9abd..0000000000 --- a/rewatch/tests/suite-ci.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -unset CLICOLOR_FORCE - -# Make sure we are in the right directory -cd $(dirname $0) - -# Get rewatch executable location from the first argument or use default -if [ -n "$1" ]; then - REWATCH_EXECUTABLE="$1" -else - REWATCH_EXECUTABLE="../target/release/rescript" - eval $(node ./get_bin_paths.js) -fi - -export REWATCH_EXECUTABLE -export RESCRIPT_BSC_EXE -export RESCRIPT_RUNTIME - -source ./utils.sh - -bold "Yarn install" -(cd ../testrepo && yarn) - -bold "Rescript version" -(cd ../testrepo && ./node_modules/.bin/rescript --version) - -# we need to reset the yarn.lock and package.json to the original state -# so there is not diff in git. The CI will install new ReScript package -bold "Reset package.json and yarn.lock" -git checkout ../testrepo/yarn.lock &> /dev/null -git checkout ../testrepo/package.json &> /dev/null -success "Reset package.json and yarn.lock" - -bold "Make sure the testrepo is clean" -if git diff --exit-code ../testrepo &> diff.txt; -then - rm diff.txt - success "Testrepo has no changes" -else - error "Testrepo is not clean to start with" - cat diff.txt - rm diff.txt - exit 1 -fi - -./compile.sh && ./watch.sh && ./lock.sh && ./suffix.sh && ./format.sh && ./clean.sh && ./experimental.sh && ./experimental-invalid.sh && ./compiler-args.sh diff --git a/rewatch/tests/suite.sh b/rewatch/tests/suite.sh index 8241a09ab2..0e6c4a9abd 100755 --- a/rewatch/tests/suite.sh +++ b/rewatch/tests/suite.sh @@ -1,3 +1,47 @@ #!/bin/bash + +unset CLICOLOR_FORCE + +# Make sure we are in the right directory cd $(dirname $0) -./suite-ci.sh + +# Get rewatch executable location from the first argument or use default +if [ -n "$1" ]; then + REWATCH_EXECUTABLE="$1" +else + REWATCH_EXECUTABLE="../target/release/rescript" + eval $(node ./get_bin_paths.js) +fi + +export REWATCH_EXECUTABLE +export RESCRIPT_BSC_EXE +export RESCRIPT_RUNTIME + +source ./utils.sh + +bold "Yarn install" +(cd ../testrepo && yarn) + +bold "Rescript version" +(cd ../testrepo && ./node_modules/.bin/rescript --version) + +# we need to reset the yarn.lock and package.json to the original state +# so there is not diff in git. The CI will install new ReScript package +bold "Reset package.json and yarn.lock" +git checkout ../testrepo/yarn.lock &> /dev/null +git checkout ../testrepo/package.json &> /dev/null +success "Reset package.json and yarn.lock" + +bold "Make sure the testrepo is clean" +if git diff --exit-code ../testrepo &> diff.txt; +then + rm diff.txt + success "Testrepo has no changes" +else + error "Testrepo is not clean to start with" + cat diff.txt + rm diff.txt + exit 1 +fi + +./compile.sh && ./watch.sh && ./lock.sh && ./suffix.sh && ./format.sh && ./clean.sh && ./experimental.sh && ./experimental-invalid.sh && ./compiler-args.sh From bc23f3ee4d223b05b7b1feb85f8eb74e7c4e9881 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 26 Oct 2025 09:07:07 +0100 Subject: [PATCH 2/2] More Makefile fixes (test dependencies, test-rewatch) --- .github/workflows/ci.yml | 4 ++-- Makefile | 22 ++++++++++++---------- rewatch/tests/clean.sh | 6 +++--- rewatch/tests/compile.sh | 2 +- rewatch/tests/compiler-args.sh | 4 ++-- rewatch/tests/format.sh | 2 +- rewatch/tests/get_bin_paths.js | 11 +---------- rewatch/tests/suite.sh | 25 +++++++++++++++++-------- 8 files changed, 39 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3405f124f..177ee19207 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -363,7 +363,7 @@ jobs: shell: bash - name: Run rewatch tests - run: ./rewatch/tests/suite.sh + run: ./rewatch/tests/suite.sh rewatch/target/release/rescript shell: bash - name: Run syntax benchmarks @@ -671,7 +671,7 @@ jobs: working-directory: rewatch/testrepo - name: Run rewatch integration tests - run: ./rewatch/tests/suite.sh node_modules/.bin/rescript + run: ./rewatch/tests/suite.sh rewatch/testrepo/node_modules/.bin/rescript shell: bash publish: diff --git a/Makefile b/Makefile index d1b5935bd4..1ad85cf89d 100644 --- a/Makefile +++ b/Makefile @@ -148,35 +148,37 @@ clean-lib: yarn workspace @rescript/runtime rescript clean rm -f $(RUNTIME_BUILD_STAMP) -# Tests / artifacts / analysis +# Artifact list artifacts: lib ./scripts/updateArtifactList.js -bench: $(COMPILER_BUILD_STAMP) +# Tests + +bench: compiler $(DUNE_BIN_DIR)/syntax_benchmarks -test: lib ninja | $(YARN_INSTALL_STAMP) +test: lib ninja node scripts/test.js -all -test-analysis: | $(YARN_INSTALL_STAMP) +test-analysis: lib ninja make -C tests/analysis_tests clean test -test-tools: | $(YARN_INSTALL_STAMP) +test-tools: lib ninja make -C tests/tools_tests clean test -test-syntax: | $(YARN_INSTALL_STAMP) +test-syntax: compiler ./scripts/test_syntax.sh -test-syntax-roundtrip: | $(YARN_INSTALL_STAMP) +test-syntax-roundtrip: compiler ROUNDTRIP_TEST=1 ./scripts/test_syntax.sh -test-gentype: | $(YARN_INSTALL_STAMP) +test-gentype: lib ninja make -C tests/gentype_tests/typescript-react-example clean test make -C tests/gentype_tests/stdlib-no-shims clean test -test-rewatch: $(RESCRIPT_EXE) | $(YARN_INSTALL_STAMP) - ./rewatch/tests/suite.sh +test-rewatch: lib + ./rewatch/tests/suite.sh $(RESCRIPT_EXE) test-all: test test-gentype test-analysis test-tools test-rewatch diff --git a/rewatch/tests/clean.sh b/rewatch/tests/clean.sh index 2f71b8d7ef..217be8a607 100755 --- a/rewatch/tests/clean.sh +++ b/rewatch/tests/clean.sh @@ -17,7 +17,7 @@ else fi # Then we clean a single project -error_output=$(cd packages/file-casing && "../../$REWATCH_EXECUTABLE" clean 2>&1) +error_output=$(cd packages/file-casing && "$REWATCH_EXECUTABLE" clean 2>&1) clean_status=$? if [ $clean_status -ne 0 ]; then @@ -86,7 +86,7 @@ fi bold "Test: It should clean dependencies from node_modules" # Build a package with external dependencies -error_output=$(cd packages/with-dev-deps && "../../$REWATCH_EXECUTABLE" build 2>&1) +error_output=$(cd packages/with-dev-deps && "$REWATCH_EXECUTABLE" build 2>&1) if [ $? -eq 0 ]; then success "Built with-dev-deps" @@ -97,7 +97,7 @@ else fi # Then we clean a single project -error_output=$(cd packages/with-dev-deps && "../../$REWATCH_EXECUTABLE" clean 2>&1) +error_output=$(cd packages/with-dev-deps && "$REWATCH_EXECUTABLE" clean 2>&1) clean_status=$? if [ $clean_status -ne 0 ]; then diff --git a/rewatch/tests/compile.sh b/rewatch/tests/compile.sh index 73cbbb32cd..3c99d9bbe4 100755 --- a/rewatch/tests/compile.sh +++ b/rewatch/tests/compile.sh @@ -37,7 +37,7 @@ fi # Build from standalone package folder using `rescript build` bold "Test: Standalone package can build via rescript from package folder" pushd ./packages/standalone > /dev/null -error_output=$("../../$REWATCH_EXECUTABLE" build 2>&1) +error_output=$("$REWATCH_EXECUTABLE" build 2>&1) if [ $? -eq 0 ]; then success "Standalone package built" diff --git a/rewatch/tests/compiler-args.sh b/rewatch/tests/compiler-args.sh index 7402d4ea54..c1c8ac8578 100755 --- a/rewatch/tests/compiler-args.sh +++ b/rewatch/tests/compiler-args.sh @@ -6,7 +6,7 @@ cd ../testrepo bold "Test: It should not matter where we grab the compiler-args for a file" # Capture stdout for both invocations stdout_root=$(rewatch compiler-args packages/file-casing/src/Consume.res 2>/dev/null) -stdout_pkg=$(cd packages/file-casing && "../../$REWATCH_EXECUTABLE" compiler-args src/Consume.res 2>/dev/null) +stdout_pkg=$(cd packages/file-casing && "$REWATCH_EXECUTABLE" compiler-args src/Consume.res 2>/dev/null) error_output=$(rewatch compiler-args packages/file-casing/src/Consume.res 2>&1) if [ $? -ne 0 ]; then @@ -14,7 +14,7 @@ if [ $? -ne 0 ]; then printf "%s\n" "$error_output" >&2 exit 1 fi -error_output=$(cd packages/file-casing && "../../$REWATCH_EXECUTABLE" compiler-args src/Consume.res 2>&1) +error_output=$(cd packages/file-casing && "$REWATCH_EXECUTABLE" compiler-args src/Consume.res 2>&1) if [ $? -ne 0 ]; then error "Error grabbing compiler args for src/Consume.res in packages/file-casing" printf "%s\n" "$error_output" >&2 diff --git a/rewatch/tests/format.sh b/rewatch/tests/format.sh index 69e8337514..2b409f85c2 100755 --- a/rewatch/tests/format.sh +++ b/rewatch/tests/format.sh @@ -45,7 +45,7 @@ fi bold "Test: It should format only the current project" -error_output=$(cd packages/file-casing && "../../$REWATCH_EXECUTABLE" format) +error_output=$(cd packages/file-casing && "$REWATCH_EXECUTABLE" format) git_diff_file_count=$(git diff --name-only ./ | wc -l | xargs) if [ $? -eq 0 ] && [ $git_diff_file_count -eq 2 ]; then diff --git a/rewatch/tests/get_bin_paths.js b/rewatch/tests/get_bin_paths.js index 1d52447282..74e6b994a1 100644 --- a/rewatch/tests/get_bin_paths.js +++ b/rewatch/tests/get_bin_paths.js @@ -1,15 +1,6 @@ // @ts-check import { bsc_exe } from "../../cli/common/bins.js"; -import path from "node:path"; - -const runtimePath = path.resolve( - import.meta.dirname, - "..", - "..", - "packages", - "@rescript", - "runtime" -); +import { runtimePath } from "../../cli/common/runtime.js"; console.log(`RESCRIPT_BSC_EXE='${bsc_exe}'`); console.log(`RESCRIPT_RUNTIME='${runtimePath}'`); diff --git a/rewatch/tests/suite.sh b/rewatch/tests/suite.sh index 0e6c4a9abd..08af67d5c3 100755 --- a/rewatch/tests/suite.sh +++ b/rewatch/tests/suite.sh @@ -1,22 +1,31 @@ #!/bin/bash +set -e + unset CLICOLOR_FORCE +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +REWATCH_EXECUTABLE="$(realpath "$1")" +export REWATCH_EXECUTABLE + # Make sure we are in the right directory cd $(dirname $0) -# Get rewatch executable location from the first argument or use default -if [ -n "$1" ]; then - REWATCH_EXECUTABLE="$1" +if [[ "$REWATCH_EXECUTABLE" == */cli/rescript.js ]]; then + echo "Using rewatch CLI script: $REWATCH_EXECUTABLE" else - REWATCH_EXECUTABLE="../target/release/rescript" + echo "Using rewatch executable: $REWATCH_EXECUTABLE" eval $(node ./get_bin_paths.js) + export RESCRIPT_BSC_EXE + export RESCRIPT_RUNTIME + echo Using bsc executable: $RESCRIPT_BSC_EXE + echo Using runtime path: $RESCRIPT_RUNTIME fi -export REWATCH_EXECUTABLE -export RESCRIPT_BSC_EXE -export RESCRIPT_RUNTIME - source ./utils.sh bold "Yarn install"