diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9da4324e..ffd0cab7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,70 +45,24 @@ default: echo "sourcing the generic CI environment" . /tmp/ci_env.sh - # generic_anod_ci modifies the rebuild strategy of anod. - # Set it back to full, so we do not rebuild the packages depending - # on gnatcoll-core and contained in GNAT. - exec anod tune --full exec anod vcs --list ######## # JOBS # ######## -build_and_test_py39: +build_and_test: services: - image:e3 - cpu:2 stage: build + interruptible: true + parallel: + matrix: + - PYTHON: ["3.9", "3.10", "3.11", "3.12"] script: - - anod vcs --add-repo gnatcoll-bindings $CI_PROJECT_DIR - - anod build --latest gnatcoll-bindings -Qpython=3.9 - - BS=`anod info build gnatcoll-bindings -Qpython=3.9 --show build_space` - - eval `anod printenv gnatcoll-bindings -Qpython=3.9 --build-env` - - export GPR_PROJECT_PATH=/tmp/it/wave/x86_64-linux/$BS/install/share/gpr:$GPR_PROJECT_PATH - - export ADA_PYTHON_HOME=/tmp/it/wave/x86_64-linux/tp-python_3.9/install - - ls /tmp/it/wave/x86_64-linux/$BS/install/share/gpr || ls -R /tmp/it/wave/x86_64-linux/ - - cd $CI_PROJECT_DIR/python3/tests && /it/e3/bin/python ./testsuite.py -v - -build_and_test_py310: - services: - - image:e3 - - cpu:2 - stage: build - script: - - anod vcs --add-repo gnatcoll-bindings $CI_PROJECT_DIR - - anod build --latest gnatcoll-bindings -Qpython=3.10 - - BS=`anod info build gnatcoll-bindings -Qpython=3.10 --show build_space` - - eval `anod printenv gnatcoll-bindings -Qpython=3.10 --build-env` - - export GPR_PROJECT_PATH=/tmp/it/wave/x86_64-linux/$BS/install/share/gpr:$GPR_PROJECT_PATH - - export ADA_PYTHON_HOME=/tmp/it/wave/x86_64-linux/tp-python_3.10/install - - cd $CI_PROJECT_DIR/python3/tests && /it/e3/bin/python ./testsuite.py -v - -build_and_test_py311: - services: - - image:e3 - - cpu:2 - stage: build - script: - - anod vcs --add-repo gnatcoll-bindings $CI_PROJECT_DIR - - anod build --latest gnatcoll-bindings -Qpython=3.11 - - BS=`anod info build gnatcoll-bindings -Qpython=3.11 --show build_space` - - eval `anod printenv gnatcoll-bindings -Qpython=3.11 --build-env` - - export GPR_PROJECT_PATH=/tmp/it/wave/x86_64-linux/$BS/install/share/gpr:$GPR_PROJECT_PATH - - export ADA_PYTHON_HOME=/tmp/it/wave/x86_64-linux/tp-python/install - - cd $CI_PROJECT_DIR/python3/tests && /it/e3/bin/python ./testsuite.py -v - -build_and_test_py312: - services: - - image:e3 - - cpu:2 - stage: build - script: - - anod vcs --add-repo gnatcoll-bindings $CI_PROJECT_DIR - - anod build --latest gnatcoll-bindings -Qpython=3.12 - - BS=`anod info build gnatcoll-bindings -Qpython=3.12 --show build_space` - - eval `anod printenv gnatcoll-bindings -Qpython=3.12 --build-env` - - export GPR_PROJECT_PATH=/tmp/it/wave/x86_64-linux/$BS/install/share/gpr:$GPR_PROJECT_PATH - - export ADA_PYTHON_HOME=/tmp/it/wave/x86_64-linux/tp-python_3.12/install - - cd $CI_PROJECT_DIR/python3/tests && /it/e3/bin/python ./testsuite.py -v - + - anod test --latest gnatcoll-bindings -Qpython=$PYTHON + - testsuite_reports + artifacts: + reports: + junit: xunit-*.xml diff --git a/testsuite/support/test.gpr b/testsuite/support/test.gpr index 4a2ba5e3..8f207280 100644 --- a/testsuite/support/test.gpr +++ b/testsuite/support/test.gpr @@ -3,7 +3,6 @@ -- The scenario variable TEST_SOURCES is automatically set by the -- driver to point to the test sources. with "gnatcoll_core"; -with "gnatcoll_iconv"; project Test is Test_Sources := External("TEST_SOURCES"); diff --git a/testsuite/support/test_assert.adb b/testsuite/support/test_assert.adb index d727a06b..acbd56d4 100644 --- a/testsuite/support/test_assert.adb +++ b/testsuite/support/test_assert.adb @@ -21,14 +21,10 @@ -- -- ------------------------------------------------------------------------------ -with Ada.Exceptions; -with Ada.Strings.Unbounded; with Ada.Text_IO; -with GNATCOLL.Iconv; package body Test_Assert is package IO renames Ada.Text_IO; - package Iconv renames GNATCOLL.Iconv; ------------ -- Assert -- @@ -81,100 +77,6 @@ package body Test_Assert is end if; end Assert; - ------------ - -- Assert -- - ------------ - - function Bytes_Image (Input : String) return String; - function Bytes_Image (Input : String) return String - is - Result : Ada.Strings.Unbounded.Unbounded_String; - begin - for C in Input'Range loop - Ada.Strings.Unbounded.Append (Result, Character'Pos (Input (C))'Img); - end loop; - return Ada.Strings.Unbounded.To_String (Result); - end Bytes_Image; - - procedure Assert_Iconv - (Input : String; - Expected : String; - From_Code : String; - To_Code : String; - Transliteration : Boolean := False; - Ignore : Boolean := False; - Msg : String := ""; - Location : String := SI.Source_Location) - is - begin - declare - Result : constant String := Iconv.Iconv - (Input => Input, - To_Code => To_Code, - From_Code => From_Code, - Transliteration => Transliteration, - Ignore => Ignore); - Success : constant Boolean := Result = Expected; - begin - Assert (Success, Msg, Location); - if not Success then - IO.Put_Line ("iconv(" & Bytes_Image (Input) & - ", to_code => " & To_Code & - ", from_code => " & From_code & - ", transliteration => " & Transliteration'Img & - ", ignore => " & Ignore'Img); - IO.Put_Line ("- expect: " & Bytes_Image (Expected)); - - IO.Put_Line ("- got: " & Bytes_Image (Result)); - end if; - end; - exception - when E : others => - Assert (False, Msg, Location); - IO.Put_Line ("got exception: " & ASCII.LF & - Ada.Exceptions.Exception_Information (E)); - end Assert_Iconv; - - procedure Assert_Invalid_Sequence - (Input : String; - From_Code : String; - To_Code : String; - Transliteration : Boolean := False; - Ignore : Boolean := False; - Msg : String := ""; - Location : String := SI.Source_Location) - is - begin - declare - Result : constant String := Iconv.Iconv - (Input => Input, - To_Code => To_Code, - From_Code => From_Code, - Transliteration => Transliteration, - Ignore => Ignore); - begin - Assert (False, Msg, Location); - IO.Put_Line ("iconv(" & Input & - ", to_code => " & To_Code & - ", from_code => " & From_code & - ", transliteration => " & Transliteration'Img & - ", ignore => " & Ignore'Img); - IO.Put_Line ("- expect: Invalid_Sequence_Error "); - IO.Put ("- got: "); - for C in Result'Range loop - IO.Put (Character'Pos (Result (C))'Img); - end loop; - IO.New_Line; - end; - exception - when Iconv.Invalid_Sequence_Error => - Assert (True, Msg, Location); - when E : others => - Assert (False, Msg, Location); - IO.Put_Line ("got exception: " & ASCII.LF & - Ada.Exceptions.Exception_Information (E)); - end Assert_Invalid_Sequence; - ------------ -- Report -- ------------ diff --git a/testsuite/support/test_assert.ads b/testsuite/support/test_assert.ads index b9d52bb4..dfe4e3a7 100644 --- a/testsuite/support/test_assert.ads +++ b/testsuite/support/test_assert.ads @@ -46,29 +46,6 @@ package Test_Assert is -- If Left = Right then test case is considered PASSED, otherwise -- the test status is FAILED and Final_Status set to 1. - procedure Assert_Iconv - (Input : String; - Expected : String; - From_Code : String; - To_Code : String; - Transliteration : Boolean := False; - Ignore : Boolean := False; - Msg : String := ""; - Location : String := SI.Source_Location); - -- Transform Input using Iconv and expect Expected as a result - -- The other parameters are for GNATCOLL.Iconv.Iconv - - procedure Assert_Invalid_Sequence - (Input : String; - From_Code : String; - To_Code : String; - Transliteration : Boolean := False; - Ignore : Boolean := False; - Msg : String := ""; - Location : String := SI.Source_Location); - -- Assert that input sequence will be considered by Iconv as an invalid - -- sequence. - function Report return Natural; -- Report should be called the following way at the end of a test -- program main function: diff --git a/testsuite/tests/coders/test.gpr b/testsuite/tests/coders/test.gpr index d33866c9..b006a47a 100644 --- a/testsuite/tests/coders/test.gpr +++ b/testsuite/tests/coders/test.gpr @@ -1,5 +1,4 @@ with "gnatcoll_core"; -with "gnatcoll_iconv"; with "gnatcoll_lzma"; with "gnatcoll_zlib"; diff --git a/testsuite/tests/iconv/iconv1/test.adb b/testsuite/tests/iconv/iconv1/test.adb index 56b96000..b12bf1d6 100644 --- a/testsuite/tests/iconv/iconv1/test.adb +++ b/testsuite/tests/iconv/iconv1/test.adb @@ -1,3 +1,7 @@ +with Ada.Exceptions; +with Ada.Strings.Unbounded; +with Ada.Text_IO; +with GNAT.Source_Info; with GNATCOLL.Iconv; with Test_Assert; @@ -5,6 +9,105 @@ function Test return Integer is package A renames Test_Assert; package Iconv renames GNATCOLL.Iconv; + package IO renames Ada.Text_IO; + package SI renames GNAT.Source_Info; + + + function Bytes_Image (Input : String) return String; + function Bytes_Image (Input : String) return String + is + Result : Ada.Strings.Unbounded.Unbounded_String; + begin + for C in Input'Range loop + Ada.Strings.Unbounded.Append (Result, Character'Pos (Input (C))'Img); + end loop; + return Ada.Strings.Unbounded.To_String (Result); + end Bytes_Image; + + procedure Assert_Iconv + (Input : String; + Expected : String; + From_Code : String; + To_Code : String; + Transliteration : Boolean := False; + Ignore : Boolean := False; + Msg : String := ""; + Location : String := SI.Source_Location) + is + -- Transform Input using Iconv and expect Expected as a result + -- The other parameters are for GNATCOLL.Iconv.Iconv + begin + declare + Result : constant String := Iconv.Iconv + (Input => Input, + To_Code => To_Code, + From_Code => From_Code, + Transliteration => Transliteration, + Ignore => Ignore); + Success : constant Boolean := Result = Expected; + begin + A.Assert (Success, Msg, Location); + if not Success then + IO.Put_Line ("iconv(" & Bytes_Image (Input) & + ", to_code => " & To_Code & + ", from_code => " & From_code & + ", transliteration => " & Transliteration'Img & + ", ignore => " & Ignore'Img); + IO.Put_Line ("- expect: " & Bytes_Image (Expected)); + + IO.Put_Line ("- got: " & Bytes_Image (Result)); + end if; + end; + exception + when E : others => + A.Assert (False, Msg, Location); + IO.Put_Line ("got exception: " & ASCII.LF & + Ada.Exceptions.Exception_Information (E)); + end Assert_Iconv; + + + procedure Assert_Invalid_Sequence + (Input : String; + From_Code : String; + To_Code : String; + Transliteration : Boolean := False; + Ignore : Boolean := False; + Msg : String := ""; + Location : String := SI.Source_Location) + is + -- Assert that input sequence will be considered by Iconv as an invalid + -- sequence. + begin + declare + Result : constant String := Iconv.Iconv + (Input => Input, + To_Code => To_Code, + From_Code => From_Code, + Transliteration => Transliteration, + Ignore => Ignore); + begin + A.Assert (False, Msg, Location); + IO.Put_Line ("iconv(" & Input & + ", to_code => " & To_Code & + ", from_code => " & From_code & + ", transliteration => " & Transliteration'Img & + ", ignore => " & Ignore'Img); + IO.Put_Line ("- expect: Invalid_Sequence_Error "); + IO.Put ("- got: "); + for C in Result'Range loop + IO.Put (Character'Pos (Result (C))'Img); + end loop; + IO.New_Line; + end; + exception + when Iconv.Invalid_Sequence_Error => + A.Assert (True, Msg, Location); + when E : others => + A.Assert (False, Msg, Location); + IO.Put_Line ("got exception: " & ASCII.LF & + Ada.Exceptions.Exception_Information (E)); + end Assert_Invalid_Sequence; + Eacute : constant Character := Character'Val (16#E9#); -- in Iso_8859-1 @@ -26,22 +129,22 @@ function Test return Integer is Character'Val (16#C7#) & Character'Val (16#82#); begin - A.Assert_Iconv ("Simple test", "Simple test", "", "", Msg => "simple test"); - A.Assert_Iconv ("Simple " & Eacute, "Simple " & Eacute_UTF8, Iconv.Iso_8859_1, Iconv.UTF8); - A.Assert_Iconv ("Simple " & R_Koi8, "Simple " & R_UTF8, Iconv.KOI8_R, Iconv.UTF8); + Assert_Iconv ("Simple test", "Simple test", "", "", Msg => "simple test"); + Assert_Iconv ("Simple " & Eacute, "Simple " & Eacute_UTF8, Iconv.Iso_8859_1, Iconv.UTF8); + Assert_Iconv ("Simple " & R_Koi8, "Simple " & R_UTF8, Iconv.KOI8_R, Iconv.UTF8); - A.Assert_Invalid_Sequence + Assert_Invalid_Sequence ("Simple " & Eacute, Iconv.Iso_8859_1, Iconv.KOI8_R); -- Test with invalid character both in the middle and at the end - A.Assert_Iconv + Assert_Iconv ("Simple " & Eacute, "Simple ", Iconv.Iso_8859_1, Iconv.KOI8_R, Ignore => True); - A.Assert_Iconv + Assert_Iconv ("T" & Eacute & "Simple", "TSimple", Iconv.Iso_8859_1, Iconv.KOI8_R, Ignore => True); - A.Assert_Iconv + Assert_Iconv (Input => Ellipsis_UTF8, Expected => "...", From_Code => Iconv.UTF8, @@ -49,7 +152,7 @@ begin Transliteration => True, Msg => "Test transliteration on ellipsis"); - A.Assert_Iconv + Assert_Iconv (Input => Ellipsis_UTF8, Expected => "", From_Code => Iconv.UTF8, @@ -58,7 +161,7 @@ begin Ignore => True, Msg => "Test UTF-8 to ASCII of ellipsis without transliteration"); - A.Assert_Iconv + Assert_Iconv (Input => Alveolar_Click & "A", Expected => "?" & "A", From_Code => Iconv.UTF8, diff --git a/testsuite/tests/omp/sort/test.gpr b/testsuite/tests/omp/sort/test.gpr index 3719e3cd..77310bc0 100644 --- a/testsuite/tests/omp/sort/test.gpr +++ b/testsuite/tests/omp/sort/test.gpr @@ -1,4 +1,3 @@ -with "gnatcoll_iconv"; with "gnatcoll_omp"; project Test is