|
| 1 | +#!/bin/env bash |
| 2 | +set -o errexit |
| 3 | +set -o nounset |
| 4 | +set -o pipefail |
| 5 | + |
| 6 | +# Default configuration |
| 7 | +BUILD_DIR=${BUILD_DIR:=./_build} |
| 8 | +INSTALL_DIR=${INSTALL_DIR:=install} |
| 9 | + |
| 10 | +POSTGRE_HOST=${POSTGRE_HOST:=localhost} |
| 11 | +POSTGRE_PORT=${POSTGRE_PORT:=5432} |
| 12 | +POSTGRE_USER=${POSTGRE_USER:=test} |
| 13 | +POSTGRE_PWD=${POSTGRE_PWD:=test} |
| 14 | +POSTGRE_DB1=${POSTGRE_DB1:=testdb1} |
| 15 | +POSTGRE_DB2=${POSTGRE_DB2:=testdb2} |
| 16 | + |
| 17 | +GNUCOBOL_DIR=${GNUCOBOL_DIR:=/usr/local/gnucobol} |
| 18 | +TEST_VERBOSITY=${TEST_VERBOSITY:=0} |
| 19 | +TEST_DIR=${TEST_DIR:=/tmp/gixsql-test} |
| 20 | +GIXTEST_LOCAL_CONFIG="$TEST_DIR/config.xml" |
| 21 | + |
| 22 | +INSTALL_PATH="$PWD/$BUILD_DIR/$INSTALL_DIR" |
| 23 | +LD_LIBRARY_PATH="$GNUCOBOL_DIR/lib" |
| 24 | + |
| 25 | +# Build and locally install the project |
| 26 | +if [ ! -f "./extra_files.mk" ]; then |
| 27 | + touch "extra_files.mk" |
| 28 | +fi |
| 29 | + |
| 30 | +if [ ! -d "$BUILD_DIR" ]; then |
| 31 | + mkdir "$BUILD_DIR" |
| 32 | + echo "Create directory $BUILD_DIR" |
| 33 | +fi |
| 34 | + |
| 35 | +echo "Compiling gixsql..." |
| 36 | +cd $BUILD_DIR |
| 37 | + |
| 38 | +if [ ! -d "$INSTALL_DIR" ]; then |
| 39 | + mkdir "$INSTALL_DIR" |
| 40 | + echo "Install gixsql in $INSTALL_PATH" |
| 41 | +fi |
| 42 | + |
| 43 | +../configure --prefix="$INSTALL_PATH" > /dev/null |
| 44 | +make -j 8 > /dev/null |
| 45 | +make install > /dev/null |
| 46 | +cd .. |
| 47 | + |
| 48 | +echo "Preparing tests..." |
| 49 | +if [ -d "$TEST_DIR" ]; then |
| 50 | + while true; do |
| 51 | + read -p "We need to erase the directory $TEST_DIR. Remove it? " yn |
| 52 | + case $yn in |
| 53 | + [Yy]* ) rm -Rf $TEST_DIR; break;; |
| 54 | + [Nn]* ) exit;; |
| 55 | + * ) echo "Please answer yes or no.";; |
| 56 | + esac |
| 57 | + done |
| 58 | +fi |
| 59 | + |
| 60 | +mkdir "$TEST_DIR" |
| 61 | + |
| 62 | +# Output the configuration file for the runner |
| 63 | +cat <<EOF >> $TEST_DIR/config.xml |
| 64 | +<?xml version="1.0" encoding="utf-8" ?> |
| 65 | +<test-local-config> |
| 66 | +
|
| 67 | + <global> |
| 68 | + <gixsql-install-base>$INSTALL_PATH</gixsql-install-base> |
| 69 | + <keep-temps>1</keep-temps> |
| 70 | + <verbose>$TEST_VERBOSITY</verbose> |
| 71 | + <test-filter></test-filter> |
| 72 | + <dbtype-filter>pgsql</dbtype-filter> |
| 73 | + <mem-check></mem-check> |
| 74 | + <temp-dir>$TEST_DIR</temp-dir> |
| 75 | + <environment> |
| 76 | + <variable key="GIXSQL_FIXUP_PARAMS" value="on" /> |
| 77 | + <variable key="LD_LIBRARY_PATH" value="$LD_LIBRARY_PATH" /> |
| 78 | + </environment> |
| 79 | + </global> |
| 80 | +
|
| 81 | + <architectures> |
| 82 | + <architecture id="x64" /> |
| 83 | + </architectures> |
| 84 | + <compiler-types> |
| 85 | + <compiler-type id="gcc" /> |
| 86 | + </compiler-types> |
| 87 | +
|
| 88 | + <compilers> |
| 89 | + <compiler type="gcc" architecture="x64" id="gnucobol-3.1.2-linux-gcc-x64"> |
| 90 | + <bin_dir_path>$GNUCOBOL_DIR/bin</bin_dir_path> |
| 91 | + <lib_dir_path>$GNUCOBOL_DIR/lib</lib_dir_path> |
| 92 | + <config_dir_path>$GNUCOBOL_DIR/share/gnucobol/config</config_dir_path> |
| 93 | + <environment> |
| 94 | + </environment> |
| 95 | + </compiler> |
| 96 | + </compilers> |
| 97 | +
|
| 98 | + <data-source-clients> |
| 99 | + <data-source-client type="pgsql" architecture="x64"> |
| 100 | + <environment> |
| 101 | + </environment> |
| 102 | + <provider value="Npgsql" /> |
| 103 | + </data-source-client> |
| 104 | + </data-source-clients> |
| 105 | +
|
| 106 | + <data-sources> |
| 107 | + <data-source type="pgsql" index="1"> |
| 108 | + <hostname>localhost</hostname> |
| 109 | + <type>pgsql</type> |
| 110 | + <port>$POSTGRE_PORT</port> |
| 111 | + <dbname>$POSTGRE_DB1</dbname> |
| 112 | + <username>$POSTGRE_USER</username> |
| 113 | + <password>$POSTGRE_PWD</password> |
| 114 | + <options>native_cursors=off</options> |
| 115 | + </data-source> |
| 116 | + <data-source type="pgsql" index="2"> |
| 117 | + <hostname>localhost</hostname> |
| 118 | + <type>pgsql</type> |
| 119 | + <port>$POSTGRE_PORT</port> |
| 120 | + <dbname>$POSTGRE_DB2</dbname> |
| 121 | + <username>$POSTGRE_USER</username> |
| 122 | + <password>$POSTGRE_PWD</password> |
| 123 | + <options>native_cursors=off</options> |
| 124 | + </data-source> |
| 125 | + </data-sources> |
| 126 | +</test-local-config> |
| 127 | +EOF |
| 128 | + |
| 129 | +echo "Building runner..." |
| 130 | +# We have to rebuild the test runner because it includes test files... |
| 131 | +dotnet build "gixsql-tests-nunit/gixsql-tests-nunit.csproj" > /dev/null |
| 132 | + |
| 133 | +# Start the runner |
| 134 | +dotnet "gixsql-tests-nunit/bin/Debug/net6.0/gixsql-tests-nunit.dll" |
| 135 | + |
| 136 | +echo "Results of the tests can found in $TEST_DIR" |
0 commit comments