forked from mridoni/gixsql
-
Notifications
You must be signed in to change notification settings - Fork 3
/
run_test.sh
executable file
·143 lines (119 loc) · 3.55 KB
/
run_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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/env sh
set -eu
# Default configuration
INSTALL_DIR="$PWD/_install"
OUTPUT_DIR="$PWD/_output"
finalizer () {
# Ensure that we try to stop the server even if the script failed
if [ -d "$OUTPUT_DIR" ]; then
echo "Stop PostgreSQL server"
pg_ctl -D "$PG_DIR" stop || true
rm -rf "$OUTPUT_DIR"
fi
}
trap "finalizer" EXIT
# These parameters are exported for PostgreSQL tools
export PGHOST="${POSTGRE_HOST:=localhost}"
export PGPORT="${POSTGRE_PORT:=6666}"
export PGUSER="${POSTGRE_USER:=test}"
export PGPASSWORD="${PGPASSWORD:=test}"
PGDB1=${POSTGRE_DB1:=testdb1}
PGDB2=${POSTGRE_DB2:=testdb2}
TEST_VERBOSITY=${TEST_VERBOSITY:=0}
# These parameters are exported for the test runner
export GIXTEST_LOCAL_CONFIG="$OUTPUT_DIR/config.xml"
PG_DIR="$OUTPUT_DIR/pg"
finalizer
mkdir "$OUTPUT_DIR"
# Configure and start PostgreSQL
echo "test" >> "$OUTPUT_DIR/pg_password"
initdb -U "$PGUSER" -D "$PG_DIR" \
--pwfile="$OUTPUT_DIR/pg_password" > /dev/null
cat <<EOF >> "$PG_DIR/postgresql.conf"
listen_addresses = '$PGHOST'
unix_socket_directories = '.'
port = $PGPORT
EOF
echo "start PostgreSQL server"
pg_ctl -D "$PG_DIR" -l "$OUTPUT_DIR/pg.log" start
echo "create databases"
createdb "$PGDB1" > /dev/null
createdb "$PGDB2" > /dev/null
# Build and locally install the project
if [ ! -f "./extra_files.mk" ]; then
touch "extra_files.mk"
fi
echo "compiling gixsql..."
if [ ! -d "$INSTALL_DIR" ]; then
mkdir "$INSTALL_DIR"
fi
autoreconf -if > /dev/null
./configure --prefix="$INSTALL_DIR" --disable-mysql \
--disable-odbc --disable-sqlite --disable-oracle > /dev/null
make -j 8 > /dev/null
make install > /dev/null
echo "preparing tests..."
# Output the configuration file for the runner
cat <<EOF >> "$OUTPUT_DIR/config.xml"
<?xml version="1.0" encoding="utf-8" ?>
<test-local-config>
<global>
<gixsql-install-base>$INSTALL_DIR</gixsql-install-base>
<keep-temps>1</keep-temps>
<verbose>$TEST_VERBOSITY</verbose>
<test-filter></test-filter>
<dbtype-filter>pgsql</dbtype-filter>
<mem-check></mem-check>
<temp-dir>$OUTPUT_DIR</temp-dir>
<environment>
<variable key="GIXSQL_FIXUP_PARAMS" value="on" />
</environment>
</global>
<architectures>
<architecture id="x64" />
</architectures>
<compiler-types>
<compiler-type id="gcc" />
</compiler-types>
<compilers>
<compiler type="gcc" architecture="x64" id="gnucobol-3.1.2-linux-gcc-x64">
<bin_dir_path>$GNUCOBOL_BIN</bin_dir_path>
<lib_dir_path>$GNUCOBOL_LIB</lib_dir_path>
<environment>
</environment>
</compiler>
</compilers>
<data-source-clients>
<data-source-client type="pgsql" architecture="x64">
<environment>
</environment>
<provider value="Npgsql" />
</data-source-client>
</data-source-clients>
<data-sources>
<data-source type="pgsql" index="1">
<hostname>localhost</hostname>
<type>pgsql</type>
<port>$PGPORT</port>
<dbname>$PGDB1</dbname>
<username>$PGUSER</username>
<password>$PGPASSWORD</password>
<options>native_cursors=off</options>
</data-source>
<data-source type="pgsql" index="2">
<hostname>localhost</hostname>
<type>pgsql</type>
<port>$PGPORT</port>
<dbname>$PGDB2</dbname>
<username>$PGUSER</username>
<password>$PGPASSWORD</password>
<options>native_cursors=off</options>
</data-source>
</data-sources>
</test-local-config>
EOF
echo "building runner..."
# We have to rebuild the test runner because it includes test files...
dotnet build "gixsql-tests-nunit/gixsql-tests-nunit.csproj" > /dev/null
# Start the runner
dotnet "gixsql-tests-nunit/bin/Debug/net6.0/gixsql-tests-nunit.dll"