Skip to content

Commit

Permalink
Also move syntax testrunner and benchmarks to the tests folder (#7097)
Browse files Browse the repository at this point in the history
* compiler/syntax/benchmarks -> tests/syntax_benchmarks

* tests/syntax_tests/* -> tests/syntax_tests/data/*

* compiler/syntax/testrunner -> tests/syntax_tests

* Fix reanalyze

* Fix docs

* CHANGELOG
  • Loading branch information
cknitt authored Oct 11, 2024
1 parent b82fbce commit 5f5917e
Show file tree
Hide file tree
Showing 1,791 changed files with 220 additions and 220 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
- Rename folder "jscomp" to "compiler". https://github.com/rescript-lang/rescript-compiler/pull/7086
- Disable -bs-cross-module-opt for tests. https://github.com/rescript-lang/rescript-compiler/pull/7071
- Move `ounit_tests` into the `tests` folder. https://github.com/rescript-lang/rescript-compiler/pull/7096
- Move `syntax_tests` into the `tests` folder. https://github.com/rescript-lang/rescript-compiler/pull/7090 https://github.com/rescript-lang/rescript-compiler/pull/7097

# 12.0.0-alpha.3

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ node scripts/test.js -bsb

**Run ounit tests:**

This will run unit tests for compiler related modules. The tests can be found in `compiler/ounit_tests`.
This will run unit tests for compiler related modules. The tests can be found in `tests/ounit_tests`.

```
node scripts/test.js -ounit
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test-gentype:
test-all: test test-gentype

reanalyze:
reanalyze.exe -set-exit-code -all-cmt _build/default/compiler -suppress compiler/syntax/testrunner -exclude-paths compiler/outcome_printer,compiler/ounit_tests,compiler/ml,compiler/js_parser,compiler/frontend,compiler/ext,compiler/depends,compiler/core,compiler/common,compiler/cmij,compiler/bsb_helper,compiler/bsb
reanalyze.exe -set-exit-code -all-cmt _build/default/compiler _build/default/tests -exclude-paths compiler/outcome_printer,compiler/ml,compiler/js_parser,compiler/frontend,compiler/ext,compiler/depends,compiler/core,compiler/common,compiler/cmij,compiler/bsb_helper,compiler/bsb

lib: build node_modules/.bin/semver
./scripts/buildRuntime.sh
Expand Down
2 changes: 1 addition & 1 deletion compiler/syntax/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(dirs compiler-libs-406 src cli benchmarks testrunner)
(dirs compiler-libs-406 src cli)

(env
(dev
Expand Down
2 changes: 1 addition & 1 deletion compiler/syntax/src/res_io.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ let write_file ~filename ~contents:txt =
let chan = open_out_bin filename in
output_string chan txt;
close_out chan
[@@raises Sys_error]
[@@raises Sys_error] [@@dead "+write_file"]
1 change: 1 addition & 0 deletions compiler/syntax/src/res_io.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ val read_file : filename:string -> string

(* writes "content" into file with name "filename" *)
val write_file : filename:string -> contents:string -> unit
[@@dead "+write_file"]
2 changes: 1 addition & 1 deletion compiler/syntax/src/res_multi_printer.mli
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(* Interface to print source code to res.
* Takes a filename called "input" and returns the corresponding formatted res syntax *)
val print : ?ignore_parse_errors:bool -> string -> string
val print : ?ignore_parse_errors:bool -> string -> string [@@dead "+print"]
2 changes: 1 addition & 1 deletion scripts/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ shopt -s extglob

dune build @fmt --auto-promote

files=$(find runtime tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*" ! -path "tests/syntax_tests/*" ! -path "tests/gentype_tests/typescript-react-example/node_modules/*")
files=$(find runtime tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*" ! -path "tests/syntax_*/*" ! -path "tests/gentype_tests/typescript-react-example/node_modules/*")
./cli/rescript format $files
2 changes: 1 addition & 1 deletion scripts/format_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ case "$(uname -s)" in
fi

echo "Checking ReScript code formatting..."
files=$(find runtime tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*" ! -path "tests/syntax_tests/*" ! -path "tests/gentype_tests/typescript-react-example/node_modules/*")
files=$(find runtime tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*" ! -path "tests/syntax_*/*" ! -path "tests/gentype_tests/typescript-react-example/node_modules/*")
if ./cli/rescript format -check $files; then
printf "${successGreen}✅ ReScript code formatting ok.${reset}\n"
else
Expand Down
14 changes: 6 additions & 8 deletions scripts/test_syntax.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ scriptDir=`dirname $0`
# so let's use this workaround instead.
DUNE_BIN_DIR=`cd "$scriptDir/../_build/install/default/bin"; pwd -P`

$DUNE_BIN_DIR/syntax_tests

function exp {
echo "$(dirname $1)/expected/$(basename $1).txt"
}
Expand All @@ -29,23 +27,23 @@ rm -rf temp
mkdir temp

# parsing
find syntax_tests/parsing/{errors,infiniteLoops,recovery} -name "*.res" -o -name "*.resi" >temp/files.txt
find syntax_tests/data/parsing/{errors,infiniteLoops,recovery} -name "*.res" -o -name "*.resi" >temp/files.txt
while read file; do
$DUNE_BIN_DIR/res_parser -recover -print ml $file &> $(exp $file) & maybeWait
done <temp/files.txt
find syntax_tests/parsing/{grammar,other} -name "*.res" -o -name "*.resi" >temp/files.txt
find syntax_tests/data/parsing/{grammar,other} -name "*.res" -o -name "*.resi" >temp/files.txt
while read file; do
$DUNE_BIN_DIR/res_parser -print ml $file &> $(exp $file) & maybeWait
done <temp/files.txt

# printing
find syntax_tests/{printer,conversion} -name "*.res" -o -name "*.resi" -o -name "*.ml" -o -name "*.mli" >temp/files.txt
find syntax_tests/data/{printer,conversion} -name "*.res" -o -name "*.resi" -o -name "*.ml" -o -name "*.mli" >temp/files.txt
while read file; do
$DUNE_BIN_DIR/res_parser $file &> $(exp $file) & maybeWait
done <temp/files.txt

# printing with ppx
find syntax_tests/ppx/react -name "*.res" -o -name "*.resi" >temp/files.txt
find syntax_tests/data/ppx/react -name "*.res" -o -name "*.resi" >temp/files.txt
while read file; do
$DUNE_BIN_DIR/res_parser -jsx-version 4 -jsx-mode "automatic" $file &> $(exp $file) & maybeWait
done <temp/files.txt
Expand All @@ -61,7 +59,7 @@ diff=$(cat temp/diff.txt)
if [[ $diff = "" ]]; then
printf "${successGreen}✅ No unstaged tests difference.${reset}\n"
else
printf "${warningYellow}⚠️ There are unstaged differences in syntax_tests/! Did you break a test?\n${diff}\n${reset}"
printf "${warningYellow}⚠️ There are unstaged differences in syntax_tests/data/! Did you break a test?\n${diff}\n${reset}"
rm -r temp/
exit 1
fi
Expand All @@ -72,7 +70,7 @@ if [[ $ROUNDTRIP_TEST = 1 ]]; then
roundtripTestsResult="temp/result.txt"
touch $roundtripTestsResult

find syntax_tests/{idempotency,printer} -name "*.res" -o -name "*.resi" >temp/files.txt
find syntax_tests/data/{idempotency,printer} -name "*.res" -o -name "*.resi" >temp/files.txt
while read file; do {
mkdir -p temp/$(dirname $file)
sexpAst1=temp/$file.sexp
Expand Down
2 changes: 1 addition & 1 deletion tests/dune
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(dirs ounit_tests)
(dirs ounit_tests syntax_benchmarks syntax_tests)
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ end = struct
Benchmark.report b

let run () =
let data_dir = "compiler/syntax/benchmarks/data" in
let data_dir = "tests/syntax_benchmarks/data" in
benchmark (Filename.concat data_dir "RedBlackTree.res") Rescript Parse;
benchmark (Filename.concat data_dir "RedBlackTree.res") Rescript Print;
benchmark
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 5f5917e

Please sign in to comment.