Skip to content

Commit 4c746a3

Browse files
committed
[ refactor ] removing a lot of duplicate code
1 parent 86612f5 commit 4c746a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+75
-999
lines changed

tests/_config/config.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,32 @@ fi
1616
if [ -z ${GHC_EXEC} ]; then
1717
export GHC_EXEC=ghc-9.2.8
1818
fi
19+
20+
goldenTest () {
21+
22+
AGDA=$1
23+
TEST_NAME=$2
24+
25+
sed "s/TEST_NAME/$TEST_NAME/g" ../../_config/template.agda-lib > "$TEST_NAME".agda-lib
26+
sed "s/TEST_NAME/$TEST_NAME/g" ../../_config/template.cabal > "$TEST_NAME".cabal
27+
28+
# Set up clean logs directory
29+
rm -rf logs/
30+
mkdir logs
31+
32+
# Use pre-existing build directory to avoid rechecking stdlib modules
33+
ln -sf ../../_build _build
34+
35+
# Compile the Agda module and build the generated code
36+
$AGDA --compile-dir=_build -c --ghc-dont-call-ghc Main.agda > logs/agda-build
37+
cabal build "$TEST_NAME" --with-compiler "$GHC_EXEC" > logs/cabal-build
38+
39+
# Run the test
40+
cabal exec -v0 "$TEST_NAME" --with-compiler "$GHC_EXEC" > output
41+
42+
# Clean up after ourselves
43+
rm "$TEST_NAME".cabal
44+
rm -R dist-newstyle
45+
rm -R _build/MAlonzo/Code/
46+
47+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: list
1+
name: TEST_NAME
22
include: ../../../src/ .
33
flags:
44
--warning=noUnsupportedIndexedMatch

tests/_config/template.cabal

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ build-type: Simple
55
description: Run this test
66
license: MIT
77

8-
tested-with:
9-
GHC == 9.2.8
10-
118
common common-build-parameters
129
default-language:
1310
Haskell2010

tests/data/appending/appending.cabal

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ build-type: Simple
55
description: Run this test
66
license: MIT
77

8-
tested-with:
9-
GHC == 9.2.8
10-
118
common common-build-parameters
129
default-language:
1310
Haskell2010

tests/data/appending/run

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
TEST_NAME=appending
22

33
# Get configuration information
4-
. ../../config.sh
4+
. ../../_config/config.sh
5+
6+
sed "s/TEST_NAME/$TEST_NAME/g" ../../_config/template.agda-lib > "$TEST_NAME".agda-lib
57

68
# Set up clean logs directory
79
rm -rf logs/

tests/data/colist/colist.agda-lib

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/data/colist/colist.cabal

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/data/colist/run

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,2 @@
1-
TEST_NAME=colist
2-
3-
# Get configuration information
4-
. ../../config.sh
5-
6-
# Set up clean logs directory
7-
rm -rf logs/
8-
mkdir logs
9-
10-
# Use pre-existing build directory to avoid rechecking stdlib modules
11-
ln -sf ../../_build _build
12-
13-
# Compile the Agda module and build the generated code
14-
$1 --compile-dir=_build -c --ghc-dont-call-ghc Main.agda > logs/agda-build
15-
cabal build "$TEST_NAME" --with-compiler "$GHC_EXEC" > logs/cabal-build
16-
17-
# Run the test
18-
cabal exec -v0 "$TEST_NAME" --with-compiler "$GHC_EXEC" > output
19-
20-
# Clean up after ourselves
21-
rm -R dist-newstyle
22-
rm -R _build/MAlonzo/Code/
1+
. ../../_config/config.sh
2+
goldenTest $1 "colist"

tests/data/list/list.cabal

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/data/list/run

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,2 @@
1-
TEST_NAME=list
2-
3-
# Get configuration information
4-
. ../../config.sh
5-
6-
# Set up clean logs directory
7-
rm -rf logs/
8-
mkdir logs
9-
10-
# Use pre-existing build directory to avoid rechecking stdlib modules
11-
ln -sf ../../_build _build
12-
13-
# Compile the Agda module and build the generated code
14-
$1 --compile-dir=_build -c --ghc-dont-call-ghc Main.agda > logs/agda-build
15-
cabal build "$TEST_NAME" --with-compiler "$GHC_EXEC" > logs/cabal-build
16-
17-
# Run the test
18-
cabal exec -v0 "$TEST_NAME" --with-compiler "$GHC_EXEC" > output
19-
20-
# Clean up after ourselves
21-
rm -R dist-newstyle
22-
rm -R _build/MAlonzo/Code/
1+
. ../../_config/config.sh
2+
goldenTest $1 "list"

0 commit comments

Comments
 (0)