Skip to content

Commit

Permalink
Add filter_test_dir test utility
Browse files Browse the repository at this point in the history
  • Loading branch information
madman-bob committed Sep 1, 2023
1 parent 09e08ab commit c346519
Show file tree
Hide file tree
Showing 29 changed files with 58 additions and 118 deletions.
2 changes: 0 additions & 2 deletions tests/chez/chez017/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
File Exists
False
True
Just "__PWD__testdir"
Just "__TEST_DIR__/testdir"
hello
8 changes: 0 additions & 8 deletions tests/chez/chez017/gen_expected.sh

This file was deleted.

4 changes: 2 additions & 2 deletions tests/chez/chez017/run
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
. ../../testutils.sh

./gen_expected.sh
run dir.idr
run dir.idr | filter_test_dir

cat testdir/test.txt
rm -rf testdir
2 changes: 0 additions & 2 deletions tests/idris2/pkg010/.gitignore

This file was deleted.

6 changes: 6 additions & 0 deletions tests/idris2/pkg010/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
1/1: Building Main (Main.idr)
Installing __TEST_DIR__/build/ttc/Main.ttc to __TEST_DIR__/currently/nonexistent/dir/idris2-0.6.0/testpkg-0
Installing __TEST_DIR__/build/ttc/Main.ttm to __TEST_DIR__/currently/nonexistent/dir/idris2-0.6.0/testpkg-0
Installing __TEST_DIR__/build/ttc/Main.ttc to __TEST_DIR__/currently/nonexistent/dir/idris2-0.6.0/testpkg-0
Installing __TEST_DIR__/build/ttc/Main.ttm to __TEST_DIR__/currently/nonexistent/dir/idris2-0.6.0/testpkg-0
Installing package file for testpkg to __TEST_DIR__/currently/nonexistent/dir/idris2-0.6.0/testpkg-0
6 changes: 0 additions & 6 deletions tests/idris2/pkg010/expected.in

This file was deleted.

3 changes: 0 additions & 3 deletions tests/idris2/pkg010/gen_expected.sh

This file was deleted.

15 changes: 3 additions & 12 deletions tests/idris2/pkg010/run
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
. ../../testutils.sh

if [ "$OS" = "windows" ]; then
MY_PWD="$(cygpath -m "$(pwd)")\\\\"
else
MY_PWD="$(pwd)/"
fi

MY_PWD="${MY_PWD}" ./gen_expected.sh

export IDRIS2_PACKAGE_PATH=$IDRIS2_PREFIX/$NAME_VERSION
export IDRIS2_PREFIX=${MY_PWD}currently/nonexistent/dir/
export IDRIS2_PREFIX=$test_dir/currently/nonexistent/dir/

export IDRIS2_INC_CGS=

idris2 --install ./testpkg.ipkg | sed -r "s/.([0-9]){10}//g"
idris2 --install ./testpkg.ipkg | sed -r "s/.([0-9]){10}//g" | filter_test_dir

# ../ is there for some extra safety for using rm -rf
rm -rf ../pkg010/build ../pkg010/currently
rm -rf currently
2 changes: 0 additions & 2 deletions tests/idris2/pkg013/.gitignore

This file was deleted.

1 change: 1 addition & 0 deletions tests/idris2/pkg013/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LOG package.depends:10: all depends: ["__TEST_DIR__/depends/bar-0.7.2", "__TEST_DIR__/depends/foo-0.1.0"]
1 change: 0 additions & 1 deletion tests/idris2/pkg013/expected.in

This file was deleted.

3 changes: 0 additions & 3 deletions tests/idris2/pkg013/gen_expected.sh

This file was deleted.

10 changes: 1 addition & 9 deletions tests/idris2/pkg013/run
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
. ../../testutils.sh

if [ "$OS" = "windows" ]; then
MY_PWD="$(cygpath -m "$(pwd)")\\\\"
else
MY_PWD="$(pwd)/"
fi

MY_PWD="${MY_PWD}" ./gen_expected.sh

idris2 --build test.ipkg --log package.depends:10
idris2 --build test.ipkg --log package.depends:10 | filter_test_dir
2 changes: 0 additions & 2 deletions tests/idris2/pkg014/.gitignore

This file was deleted.

1 change: 1 addition & 0 deletions tests/idris2/pkg014/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LOG package.depends:10: all depends: ["__TEST_DIR__/depends/bar-0.1.0", "__TEST_DIR__/depends/baz-0.2.0", "__TEST_DIR__/depends/foo-0.2.0"]
1 change: 0 additions & 1 deletion tests/idris2/pkg014/expected.in

This file was deleted.

3 changes: 0 additions & 3 deletions tests/idris2/pkg014/gen_expected.sh

This file was deleted.

10 changes: 1 addition & 9 deletions tests/idris2/pkg014/run
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
. ../../testutils.sh

if [ "$OS" = "windows" ]; then
MY_PWD="$(cygpath -m "$(pwd)")\\\\"
else
MY_PWD="$(pwd)/"
fi

MY_PWD="${MY_PWD}" ./gen_expected.sh

idris2 --build test.ipkg --log package.depends:10
idris2 --build test.ipkg --log package.depends:10 | filter_test_dir
2 changes: 0 additions & 2 deletions tests/idris2/pkg017/.gitignore

This file was deleted.

22 changes: 22 additions & 0 deletions tests/idris2/pkg017/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(:protocol-version 2 1)
(:return (:ok "Current working directory is \"__TEST_DIR__/b1\"") 1)
(:write-string "1/1: Building B1 (src/B1.idr)" 2)
(:return (:ok ()) 2)
(:return (:ok "1" ((0 1 ((:decor :data))))) 4)
(:return (:ok (("A.i" (:filename "__TEST_DIR__/prefix/idris2-0.6.0/a1-0/A.idr") (:start 2 0) (:end 3 7)))) 5)
(:return (:ok "Current working directory is \"__TEST_DIR__/b2\"") 6)
(:write-string "1/1: Building B2 (src/B2.idr)" 7)
(:return (:ok ()) 7)
(:return (:ok "2" ((0 1 ((:decor :data))))) 8)
(:return (:ok (("A.i" (:filename "__TEST_DIR__/prefix/idris2-0.6.0/a2-0/A.idr") (:start 2 0) (:end 3 7)))) 9)
he file is done, aborting
(:protocol-version 2 1)
(:return (:ok "Current working directory is \"__TEST_DIR__/b2\"") 1)
(:return (:ok ()) 2)
(:return (:ok "2" ((0 1 ((:decor :data))))) 4)
(:return (:ok (("A.i" (:filename "__TEST_DIR__/prefix/idris2-0.6.0/a2-0/A.idr") (:start 2 0) (:end 3 7)))) 5)
(:return (:ok "Current working directory is \"__TEST_DIR__/b1\"") 6)
(:return (:ok ()) 7)
(:return (:ok "1" ((0 1 ((:decor :data))))) 8)
(:return (:ok (("A.i" (:filename "__TEST_DIR__/prefix/idris2-0.6.0/a1-0/A.idr") (:start 2 0) (:end 3 7)))) 9)
he file is done, aborting
22 changes: 0 additions & 22 deletions tests/idris2/pkg017/expected.in

This file was deleted.

3 changes: 0 additions & 3 deletions tests/idris2/pkg017/gen_expected.sh

This file was deleted.

16 changes: 4 additions & 12 deletions tests/idris2/pkg017/run
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
. ../../testutils.sh

if [ "$OS" = "windows" ]; then
MY_PWD="$(cygpath -m "$(pwd)")\\\\"
else
MY_PWD="$(pwd)/"
fi

MY_PWD="${MY_PWD}" ./gen_expected.sh

mkdir prefix

IDRIS2_PREFIX="${MY_PWD}/prefix" idris2 --install-with-src a1/a1.ipkg > /dev/null
IDRIS2_PREFIX="${MY_PWD}/prefix" idris2 --install-with-src a2/a2.ipkg > /dev/null
IDRIS2_PREFIX="$test_dir/prefix" idris2 --install-with-src a1/a1.ipkg > /dev/null
IDRIS2_PREFIX="$test_dir/prefix" idris2 --install-with-src a2/a2.ipkg > /dev/null

IDRIS2_PREFIX="${MY_PWD}/prefix" idris2 --no-prelude --ide-mode < input1 | grep -v ":highlight-source" | cut -c 7-
IDRIS2_PREFIX="${MY_PWD}/prefix" idris2 --no-prelude --ide-mode < input2 | grep -v ":highlight-source" | cut -c 7-
IDRIS2_PREFIX="$test_dir/prefix" idris2 --no-prelude --ide-mode < input1 | grep -v ":highlight-source" | cut -c 7- | filter_test_dir
IDRIS2_PREFIX="$test_dir/prefix" idris2 --no-prelude --ide-mode < input2 | grep -v ":highlight-source" | cut -c 7- | filter_test_dir

rm -r a1/build a2/build b1/build b2/build
rm -rf prefix
2 changes: 0 additions & 2 deletions tests/node/node017/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
File Exists
False
True
Just "__PWD__testdir"
Just "__TEST_DIR__/testdir"
hello
8 changes: 0 additions & 8 deletions tests/node/node017/gen_expected.sh

This file was deleted.

3 changes: 1 addition & 2 deletions tests/node/node017/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@

rm -rf testdir

./gen_expected.sh
run --cg node dir.idr
run --cg node dir.idr | filter_test_dir
cat testdir/test.txt
14 changes: 14 additions & 0 deletions tests/testutils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,17 @@ check() {
run() {
idris2 --exec main "$@"
}

# Folder containing the currently running test
if [ "$OS" = "windows" ]; then
test_dir="$(cygpath -m "$(pwd)")\\\\"
else
test_dir="$(pwd)/"
fi

# Remove test directory from output
# Useful for consistency of output between machines
# Usage: run SomeTest.idr | filter_test_dir
filter_test_dir() {
sed -e "s|$test_dir|__TEST_DIR__/|g"
}

0 comments on commit c346519

Please sign in to comment.