Skip to content

Commit

Permalink
Throw more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chenglou committed Apr 29, 2021
1 parent e7a4127 commit 1a10561
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 14 deletions.
3 changes: 3 additions & 0 deletions analysis/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ tests/node_modules/.bin/rescript:

test: dce tests/node_modules/.bin/rescript
@cd tests && node_modules/.bin/rescript
OCAMLOPT -o testmore.exe ./testmore.ml
OCAMLOPT -o testfile.exe ./testfile.ml
OCAMLOPT -o testfile2.exe ./testfile2.ml
./test.sh

clean:
Expand Down
3 changes: 3 additions & 0 deletions analysis/basetest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
hello
world
this is basetest
3 changes: 3 additions & 0 deletions analysis/randomfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
hello this is used
by
testfile
45 changes: 31 additions & 14 deletions analysis/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,46 @@ function exp {
echo "$(dirname $1)/expected/$(basename $1).txt"
}

echo "cat -A test.sh"
cat -A tests/src/expected/Auto.res.txt
echo "done---------"
echo "git diff test.sh"
git diff tests/src/expected/Auto.res.txt
echo "done---------"

for file in tests/src/*.{res,resi}; do
./rescript-editor-analysis.exe test $file &> $(exp $file)
done

./testmore.exe > helloworld.txt
./testfile.exe > helloworld2.txt
./testfile2.exe > helloworld3.txt

echo "cat basetest.txt"
cat -A basetest.txt
echo "------"
echo "cat basetest.txt > pipetest.txt then cat"
cat basetest.txt > pipetest.txt
cat -A pipetest.txt
echo "------"
echo "cat helloworld.txt"
cat -A helloworld.txt
echo "------"
echo "cat helloworld2.txt"
cat -A helloworld2.txt
echo "------"
echo "cat helloworld3.txt"
cat -A helloworld3.txt
echo "------"
echo "dox2unix helloworld.txt"
dos2unix helloworld.txt
echo "------"
echo "dox2unix helloworld2.txt"
dos2unix helloworld2.txt
echo "------"
echo "dox2unix helloworld3.txt"
dos2unix helloworld3.txt
echo "------"
echo "========all done!========="

# # CI
# if [ "$RUNNER_OS" == "Windows" ]; then
# dos2unix tests/src/expected/*
# fi

echo "cat -A test.sh last"
cat -A tests/src/expected/Auto.res.txt
echo "done cat last---------"
echo "git diff test.sh last"
diff -u tests/src/expected/Auto.res.txt tests/src/expected/Auto.res.2.txt
echo "done git last---------"

warningYellow='\033[0;33m'
successGreen='\033[0;32m'
reset='\033[0m'
Expand Down
14 changes: 14 additions & 0 deletions analysis/testfile.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
let readFile ~filename =
try
(* windows can't use open_in *)
let chan = open_in_bin filename in
let content = really_input_string chan (in_channel_length chan) in
close_in_noerr chan;
Some content
with _ -> None

let content = readFile "./randomfile.txt"

let () = match content with
| None -> raise Not_found
| Some content -> print_endline content
6 changes: 6 additions & 0 deletions analysis/testfile2.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let content = {|
hello
how are you
|}

let () = print_endline content
1 change: 1 addition & 0 deletions analysis/testmore.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print_endline "hello, world!"

0 comments on commit 1a10561

Please sign in to comment.