forked from purescript/purescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glob-test.sh
113 lines (89 loc) · 2.33 KB
/
glob-test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env bash
# This script assumes `ci/build.sh && cd sdist-test` has been run
# and that the program `tree` has been installed.
# Creates the following structure
# Foo.purs
# src/Bar.purs
# src/Bar/Baz.purs
#
# and verifies that the two kinds of input globs interact consistently.
set -eu -o pipefail
shopt -s nullglob
PURS="$(stack path --local-doc-root)/../bin/purs"
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT
cd "$tmpdir"
echo ::group::Environment info
echo "purs: ${PURS}"
echo "purs --version"
"${PURS}" --version
echo ::endgroup::
echo ::group::Setting up structure
mkdir -p "src/Bar"
cat > "Foo.purs" <<EOF
module Foo where
foo = 1 :: Int
EOF
cat > "src/Bar.purs" <<EOF
module Bar where
bar = 1 :: Int
EOF
cat > "src/Bar/Baz.purs" <<EOF
module Bar.Baz where
baz = 1 :: Int
EOF
cat > "globsAll" <<EOF
# Generated by Spago. Do not edit!
Foo.purs
src/**/*.purs
test/**/*.purs
EOF
cat > "globsNoFoo" <<EOF
# Generated by Spago. Do not edit!
src/**/*.purs
test/**/*.purs
EOF
tree . -L 3
echo ::endgroup::
echo ::group::Calling purs compile
"${PURS}" compile --output "out1" 'Foo.purs' 'src/**/*.purs' 'test/**/*.purs' 2>&1
EXPECTED=$(cd out1 && tree . 2>&1)
"${PURS}" compile --output "out2" --source-globs-file globsAll 2>&1
SOURCE_GLOBS=$(cd out2 && tree . 2>&1)
"${PURS}" compile --output "out3" --source-globs-file globsAll 'Foo.purs' 2>&1
MIXED_ALL=$(cd out3 && tree . 2>&1)
"${PURS}" compile --output "out4" --source-globs-file globsNoFoo 'Foo.purs' 2>&1
MIXED_NO_FOO=$(cd out4 && tree . 2>&1)
echo ::endgroup::
echo ::group::Running checks
if [ "${EXPECTED}" = "" ] ; then
echo "'purs compile' output should not be empty"
exit 1
fi
if [ "${EXPECTED}" = "${SOURCE_GLOBS}" ]; then
echo "SOURCE_GLOBS is correct"
else
echo "SOURCE_GLOBS output different from EXPECTED"
echo "Expected: ${EXPECTED}"
echo "SOURCE_GLOBS: ${SOURCE_GLOBS}"
exit 1
fi
if [ "${EXPECTED}" = "${MIXED_ALL}" ]; then
echo "MIXED_ALL is correct"
else
echo "MIXED_ALL output different from EXPECTED"
echo "Expected: ${MIXED_ALL}"
echo "MIXED_ALL: ${MIXED_ALL}"
exit 1
fi
if [ "${EXPECTED}" = "${MIXED_NO_FOO}" ]; then
echo "MIXED_NO_FOO is correct"
else
echo "MIXED_NO_FOO output different from EXPECTED"
echo "Expected: ${MIXED_NO_FOO}"
echo "MIXED_NO_FOO: ${MIXED_NO_FOO}"
exit 1
fi
echo "Tests passed"
echo ::endgroup::
exit 0