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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ jobs:
shell: bash

- name: Run rewatch tests
run: ./rewatch/tests/suite-ci.sh
run: ./rewatch/tests/suite.sh rewatch/target/release/rescript
shell: bash

- name: Run syntax benchmarks
Expand Down Expand Up @@ -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 rewatch/testrepo/node_modules/.bin/rescript
shell: bash

publish:
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 12 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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-ci.sh
test-rewatch: lib
./rewatch/tests/suite.sh $(RESCRIPT_EXE)

test-all: test test-gentype test-analysis test-tools test-rewatch

Expand Down
6 changes: 3 additions & 3 deletions rewatch/tests/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rewatch/tests/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions rewatch/tests/compiler-args.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ 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
error "Error grabbing compiler args for packages/file-casing/src/Consume.res"
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
Expand Down
2 changes: 1 addition & 1 deletion rewatch/tests/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 1 addition & 10 deletions rewatch/tests/get_bin_paths.js
Original file line number Diff line number Diff line change
@@ -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}'`);
47 changes: 0 additions & 47 deletions rewatch/tests/suite-ci.sh

This file was deleted.

55 changes: 54 additions & 1 deletion rewatch/tests/suite.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
#!/bin/bash

set -e

unset CLICOLOR_FORCE

if [ "$#" -ne 1 ]; then
echo "Usage: $0 <rewatch executable>"
exit 1
fi

REWATCH_EXECUTABLE="$(realpath "$1")"
export REWATCH_EXECUTABLE

# Make sure we are in the right directory
cd $(dirname $0)
./suite-ci.sh

if [[ "$REWATCH_EXECUTABLE" == */cli/rescript.js ]]; then
echo "Using rewatch CLI script: $REWATCH_EXECUTABLE"
else
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

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
Loading