diff --git a/flake.nix b/flake.nix index 1f19f07..517f42f 100644 --- a/flake.nix +++ b/flake.nix @@ -26,10 +26,15 @@ spdlog fmt postgresql + gmp ]; shellHook = '' - PATH="${pkgs.gnucobol}/bin:$PATH" + export PATH="${pkgs.gnucobol.bin}/bin:$PATH" + export LD_LIBRARY_PATH="${pkgs.gnucobol.lib}/lib:$LD_LIBRARY_PATH" + export GNUCOBOL_BIN="${pkgs.gnucobol.bin}/bin" + export GNUCOBOL_LIB="${pkgs.gnucobol.lib}/lib" + export GNUCOBOL_SHARE="${pkgs.gnucobol.bin}/share" ''; }; }; diff --git a/gixsql-tests-nunit/CompilerConfig.cs b/gixsql-tests-nunit/CompilerConfig.cs index f1f0bc7..4b40724 100644 --- a/gixsql-tests-nunit/CompilerConfig.cs +++ b/gixsql-tests-nunit/CompilerConfig.cs @@ -1,4 +1,4 @@ -//using Microsoft.VisualStudio.TestTools.UnitTesting; +//using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.IO; using System.Xml; @@ -18,7 +18,6 @@ internal class CompilerConfig public string cobc_homedir { get; private set; } public string cobc_bin_dir_path { get; private set; } public string cobc_lib_dir_path { get; private set; } - public string cobc_config_dir_path { get; private set; } public string link_lib_dir_path { get; private set; } public string link_lib_name { get; private set; } @@ -68,10 +67,6 @@ public static CompilerConfig init(CompilerType ctype, string configuration, stri cc.cobc_lib_dir_path = cc.cobc_lib_dir_path.Replace("${homedir}", cc.cobc_homedir).Replace("${gixdata}", cc.gix_data_dir); Assert.IsTrue(Directory.Exists(cc.cobc_lib_dir_path)); - cc.cobc_config_dir_path = xp.SelectSingleNode("config_dir_path")?.InnerText; - cc.cobc_config_dir_path = cc.cobc_config_dir_path.Replace("${homedir}", cc.cobc_homedir).Replace("${gixdata}", cc.gix_data_dir); - Assert.IsTrue(Directory.Exists(cc.cobc_config_dir_path)); - cc.gix_copy_path = Path.Combine(gix_base_path, "lib", "copy"); Assert.IsTrue(Directory.Exists(cc.gix_copy_path)); Assert.IsTrue(File.Exists(Path.Combine(cc.gix_copy_path, "SQLCA.cpy"))); diff --git a/gixsql-tests-nunit/CompilerConfig2.cs b/gixsql-tests-nunit/CompilerConfig2.cs index 3596ad6..7dc3a1a 100644 --- a/gixsql-tests-nunit/CompilerConfig2.cs +++ b/gixsql-tests-nunit/CompilerConfig2.cs @@ -1,4 +1,4 @@ -//using Microsoft.VisualStudio.TestTools.UnitTesting; +//using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.IO; using System.Xml; @@ -12,7 +12,6 @@ public class CompilerConfig2 public string cobc_bin_dir_path { get; private set; } public string cobc_lib_dir_path { get; private set; } - public string cobc_config_dir_path { get; private set; } public string gixsql_bin_path { get; private set; } public string gixsql_lib_path { get; private set; } @@ -50,9 +49,6 @@ public static CompilerConfig2 init(XmlElement xc) cc.cobc_lib_dir_path = Environment.ExpandEnvironmentVariables(xc.SelectSingleNode("lib_dir_path")?.InnerText); if (!Directory.Exists(cc.cobc_lib_dir_path)) throw new Exception(cc.cobc_lib_dir_path); - cc.cobc_config_dir_path = Environment.ExpandEnvironmentVariables(xc.SelectSingleNode("config_dir_path")?.InnerText); - if (!Directory.Exists(cc.cobc_config_dir_path)) throw new Exception(cc.cobc_config_dir_path); - if (isWindows) cc.gixsql_copy_path = Path.Combine(gix_base_path, "lib", "copy"); else @@ -61,8 +57,8 @@ public static CompilerConfig2 init(XmlElement xc) if (!Directory.Exists(cc.gixsql_copy_path)) throw new Exception(cc.gixsql_copy_path); if (!File.Exists(Path.Combine(cc.gixsql_copy_path, "SQLCA.cpy"))) throw new Exception(); - cc.gixsql_bin_path = Path.Combine(gix_base_path, "bin"); - + cc.gixsql_bin_path = Path.Combine(gix_base_path, "bin"); + cc.gixsql_lib_path = Path.Combine(gix_base_path, "lib"); if (isWindows) cc.gixsql_link_lib_dir_path = Path.Combine(cc.gixsql_lib_path, compiler_arch, compiler_type); diff --git a/gixsql-tests-nunit/GixSqlDynamicTestRunner.cs b/gixsql-tests-nunit/GixSqlDynamicTestRunner.cs index 61e456e..3a27e27 100644 --- a/gixsql-tests-nunit/GixSqlDynamicTestRunner.cs +++ b/gixsql-tests-nunit/GixSqlDynamicTestRunner.cs @@ -370,7 +370,6 @@ private void compile(GixSqlTestData td) .WithArguments(cobc_args) .WithEnvironmentVariables(new Dictionary { - ["COB_CONFIG_DIR"] = cc.cobc_config_dir_path, ["PATH"] = Environment.GetEnvironmentVariable("PATH") + $"{Path.PathSeparator}{cc.cobc_bin_dir_path}" }) .WithValidation(CommandResultValidation.None) diff --git a/gixsql-tests-nunit/Runner.cs b/gixsql-tests-nunit/Runner.cs index 512583f..4920eae 100644 --- a/gixsql-tests-nunit/Runner.cs +++ b/gixsql-tests-nunit/Runner.cs @@ -1,4 +1,4 @@ -using gixsql_tests; +using gixsql_tests; using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; using System; using System.Collections.Generic; @@ -42,7 +42,7 @@ public static int Main(string[] args) } } - int num_results_ok = results.Count(a => a.Value == "KO"); + int num_results_ok = results.Count(a => a.Value == "OK"); int num_results_ko = results.Count(a => a.Value == "KO"); int mlen = results.Select(a => a.Key.Length).Max(); diff --git a/gixsql-tests-nunit/data/gixsql_test_data.xml b/gixsql-tests-nunit/data/gixsql_test_data.xml index 7680b50..7f3c5b2 100644 --- a/gixsql-tests-nunit/data/gixsql_test_data.xml +++ b/gixsql-tests-nunit/data/gixsql_test_data.xml @@ -1,8 +1,8 @@ - + - + Open connection, cursor #000 @@ -234,7 +234,7 @@ - + employee #: [+0123] @@ -2293,7 +2293,7 @@ CREATE TABLE TAB02 (CID INTEGER, FLD CHAR(100)) CREATE TABLE TAB03 (CID INTEGER, FLD CHAR(100)) CREATE TABLE TAB04 (CID INTEGER, FLD CHAR(100)) - + @@ -2785,7 +2785,7 @@ - + Implementation of updatable cursors (with parameters) #000 @@ -3223,7 +3223,7 @@ - + Implementation of updatable cursors (with parameters) #000 diff --git a/libgixpp/ESQLDefinitions.h b/libgixpp/ESQLDefinitions.h index eb3cbf4..8b9ba12 100644 --- a/libgixpp/ESQLDefinitions.h +++ b/libgixpp/ESQLDefinitions.h @@ -113,7 +113,7 @@ struct esql_connection_info_t hostref_or_literal_t *data_source = nullptr; hostref_or_literal_t *username = nullptr; hostref_or_literal_t *password = nullptr; - + // for compatibility hostref_or_literal_t *dbname = nullptr; }; @@ -239,7 +239,7 @@ struct connect_to_info_t }; // This will disappear when the standalone debugger will be the only option -// For now this quick hack prevents compilation errors and having to +// For now this quick hack prevents compilation errors and having to // refactor this into an external file #ifndef _GIXPP_BLOCK_ #define _GIXPP_BLOCK_ @@ -262,7 +262,7 @@ struct PreprocessedBlockInfo { int pp_end_line = 0; int pp_gen_start_line = 0; int pp_gen_end_line = 0; - + PreprocessedBlockType type; std::string command; diff --git a/run_test.sh b/run_test.sh new file mode 100755 index 0000000..2d86ecb --- /dev/null +++ b/run_test.sh @@ -0,0 +1,133 @@ +#!/bin/env bash +set -o errexit +set -o nounset +set -o pipefail + +# Default configuration +BUILD_DIR=${BUILD_DIR:=./_build} +INSTALL_DIR=${INSTALL_DIR:=install} + +POSTGRE_HOST=${POSTGRE_HOST:=localhost} +POSTGRE_PORT=${POSTGRE_PORT:=5432} +POSTGRE_USER=${POSTGRE_USER:=test} +POSTGRE_PWD=${POSTGRE_PWD:=test} +POSTGRE_DB1=${POSTGRE_DB1:=testdb1} +POSTGRE_DB2=${POSTGRE_DB2:=testdb2} + +TEST_VERBOSITY=${TEST_VERBOSITY:=0} +TEST_DIR=${TEST_DIR:=/tmp/gixsql-test} +export GIXTEST_LOCAL_CONFIG="$TEST_DIR/config.xml" + +INSTALL_PATH="$PWD/$BUILD_DIR/$INSTALL_DIR" + +# Build and locally install the project +if [ ! -f "./extra_files.mk" ]; then + touch "extra_files.mk" +fi + +if [ ! -d "$BUILD_DIR" ]; then + mkdir "$BUILD_DIR" + echo "Create directory $BUILD_DIR" +fi + +echo "Compiling gixsql..." +cd $BUILD_DIR + +if [ ! -d "$INSTALL_DIR" ]; then + mkdir "$INSTALL_DIR" + echo "Install gixsql in $INSTALL_PATH" +fi + +../configure --prefix="$INSTALL_PATH" > /dev/null +make -j 8 > /dev/null +make install > /dev/null +cd .. + +echo "Preparing tests..." +if [ -d "$TEST_DIR" ]; then + while true; do + read -p "We need to erase the directory $TEST_DIR. Remove it? " yn + case $yn in + [Yy]* ) rm -Rf $TEST_DIR; break;; + [Nn]* ) exit;; + * ) echo "Please answer yes or no.";; + esac + done +fi + +mkdir "$TEST_DIR" + +# Output the configuration file for the runner +cat <> $TEST_DIR/config.xml + + + + + $INSTALL_PATH + 1 + $TEST_VERBOSITY + + pgsql + + $TEST_DIR + + + + + + + + + + + + + + + $GNUCOBOL_BIN + $GNUCOBOL_LIB + $GNUCOBOL_SHARE/gnucobol/config + + + + + + + + + + + + + + + + localhost + pgsql + $POSTGRE_PORT + $POSTGRE_DB1 + $POSTGRE_USER + $POSTGRE_PWD + native_cursors=off + + + localhost + pgsql + $POSTGRE_PORT + $POSTGRE_DB2 + $POSTGRE_USER + $POSTGRE_PWD + native_cursors=off + + + +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" + +echo "Results of the tests can found in $TEST_DIR"