diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68832e4..383e264 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,36 +1,60 @@ name: Build on: - push: - branches: [ master ] - pull_request: - workflow_dispatch: + workflow_call: + inputs: + build: + description: 'Whether to run a plain `alr build`' + required: false + default: true + type: boolean + crate: + description: 'The crate to build' + required: true + type: string + +env: + AAA_STYLE_CHECKS: enabled + AAA_RUNTIME_CHECKS: enabled + AAA_COMPILE_CHECKS: enabled + AAA_CONTRACTS: enabled jobs: build: + name: test (${{inputs.crate}}, GNAT ${{ matrix.combo.gnat }}, ${{ matrix.combo.os }}) strategy: + fail-fast: false matrix: - os: [macos-latest, windows-latest, ubuntu-latest] - gnat_version: [^10, ^11] - gprbuild_version: [^21] - runs-on: ${{ matrix.os }} - env: - AAA_STYLE_CHECKS: enabled - AAA_RUNTIME_CHECKS: enabled - AAA_COMPILE_CHECKS: enabled - AAA_CONTRACTS: enabled + combo: # Test an assorment of representative combinations + - os: macos-13 + gnat: 13 + - os: macos-latest + gnat: 14 + - os: ubuntu-22.04 + gnat: 10 + - os: ubuntu-latest + gnat: 12 + # Waiting for indexed compiler + # - os: ubuntu-24.04-arm + # gnat: 14 + - os: windows-latest + gnat: 11 + + runs-on: ${{ matrix.combo.os }} steps: - name: Checkout uses: actions/checkout@v2 - name: Set up Alire and toolchain - uses: alire-project/setup-alire@v1 + uses: alire-project/setup-alire@v4 with: - toolchain: gprbuild${{ matrix.gprbuild_version }} gnat_native${{ matrix.gnat_version }} --disable-assistant + version: nightly # for [test] + toolchain: gnat_native^${{ matrix.combo.gnat }} gprbuild - name: Build - run: alr -q build + if: ${{inputs.build}} + run: cd ${{inputs.crate}} && alr -q build - name: Run tests - run: cd tests && alr -q run + run: cd ${{inputs.crate}} && alr test diff --git a/.github/workflows/build_aaa.yml b/.github/workflows/build_aaa.yml new file mode 100644 index 0000000..2d933bc --- /dev/null +++ b/.github/workflows/build_aaa.yml @@ -0,0 +1,13 @@ +name: aaa + +on: + push: + branches: [ main, master ] + pull_request: + workflow_dispatch: + +jobs: + check: + uses: ./.github/workflows/build.yml + with: + crate: aaa_base diff --git a/.github/workflows/build_aaa_texts.yml b/.github/workflows/build_aaa_texts.yml new file mode 100644 index 0000000..5d08ecb --- /dev/null +++ b/.github/workflows/build_aaa_texts.yml @@ -0,0 +1,14 @@ +name: aaa_texts + +on: + push: + branches: [ main, master ] + pull_request: + workflow_dispatch: + +jobs: + check: + uses: ./.github/workflows/build.yml + with: + crate: aaa_texts + build: false \ No newline at end of file diff --git a/.gitignore b/.gitignore index e2ad21b..b4a7555 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,3 @@ alire.lock bin lib obj -/obj/ -/lib/ -/alire/ diff --git a/README.md b/README.md index 71344dd..2b66eac 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,17 @@ [![Build](https://github.com/mosteo/aaa/workflows/Build/badge.svg)](https://github.com/mosteo/aaa/actions) [![Alire](https://img.shields.io/endpoint?url=https://alire.ada.dev/badges/aaa.json)](https://alire.ada.dev/crates/aaa.html) +Alex's Ada Assortment of Utilities. -Alex's Ada Assortment of Utilities +## aaa -- Text formatting (paragraphs, tables). - Indefinite containers. - Enumeration validity/conversions of string images. - On-demand stack backtraces. - String containers and utilities. - Simple subprocess spawning. - Write-through minimal cache for objects stored in files + +## aaa_texts + +- Unicode ANSI text formatting (paragraphs, tables). diff --git a/LICENSE b/aaa_base/LICENSE similarity index 100% rename from LICENSE rename to aaa_base/LICENSE diff --git a/aaa.gpr b/aaa_base/aaa.gpr similarity index 100% rename from aaa.gpr rename to aaa_base/aaa.gpr diff --git a/alire.toml b/aaa_base/alire.toml similarity index 82% rename from alire.toml rename to aaa_base/alire.toml index 45a821c..90940d3 100644 --- a/alire.toml +++ b/aaa_base/alire.toml @@ -1,5 +1,5 @@ name = "aaa" -version = "0.3.0-dev" +version = "0.3.0" description = "Alex's Ada Assortment (of miscellaneous utilities)" long-description = """ @@ -21,8 +21,10 @@ maintainers-logins = ["mosteo"] tags = ["miscellanea", "utility"] website = "https://github.com/mosteo/aaa" -[[depends-on]] -umwi = "~0.1.0" +[[actions]] +type = "test" +directory = "tests" +command = ["alr", "build"] -# [[pins]] -# umwi = { url="https://github.com/mosteo/umwi", branch="main" } +[test] +runner = "alire" diff --git a/config/aaa_config.ads b/aaa_base/config/aaa_config.ads similarity index 90% rename from config/aaa_config.ads rename to aaa_base/config/aaa_config.ads index 401243a..85e4d2e 100644 --- a/config/aaa_config.ads +++ b/aaa_base/config/aaa_config.ads @@ -5,7 +5,7 @@ pragma Style_Checks (Off); package Aaa_Config is pragma Pure; - Crate_Version : constant String := "0.3.0-dev"; + Crate_Version : constant String := "0.3.0"; Crate_Name : constant String := "aaa"; Alire_Host_OS : constant String := "linux"; diff --git a/config/aaa_config.gpr b/aaa_base/config/aaa_config.gpr similarity index 97% rename from config/aaa_config.gpr rename to aaa_base/config/aaa_config.gpr index 4829245..81c855c 100644 --- a/config/aaa_config.gpr +++ b/aaa_base/config/aaa_config.gpr @@ -1,7 +1,6 @@ -- Configuration for aaa generated by Alire -with "umwi.gpr"; abstract project Aaa_Config is - Crate_Version := "0.3.0-dev"; + Crate_Version := "0.3.0"; Crate_Name := "aaa"; Alire_Host_OS := "linux"; diff --git a/config/aaa_config.h b/aaa_base/config/aaa_config.h similarity index 91% rename from config/aaa_config.h rename to aaa_base/config/aaa_config.h index bf1815c..edcfdd4 100644 --- a/config/aaa_config.h +++ b/aaa_base/config/aaa_config.h @@ -2,7 +2,7 @@ #ifndef AAA_CONFIG_H #define AAA_CONFIG_H -#define CRATE_VERSION "0.3.0-dev" +#define CRATE_VERSION "0.3.0" #define CRATE_NAME "aaa" #define ALIRE_HOST_OS "linux" diff --git a/src/aaa-caches-files.adb b/aaa_base/src/aaa-caches-files.adb similarity index 100% rename from src/aaa-caches-files.adb rename to aaa_base/src/aaa-caches-files.adb diff --git a/src/aaa-caches-files.ads b/aaa_base/src/aaa-caches-files.ads similarity index 100% rename from src/aaa-caches-files.ads rename to aaa_base/src/aaa-caches-files.ads diff --git a/src/aaa-caches.ads b/aaa_base/src/aaa-caches.ads similarity index 100% rename from src/aaa-caches.ads rename to aaa_base/src/aaa-caches.ads diff --git a/src/aaa-containers-indefinite_holders.adb b/aaa_base/src/aaa-containers-indefinite_holders.adb similarity index 100% rename from src/aaa-containers-indefinite_holders.adb rename to aaa_base/src/aaa-containers-indefinite_holders.adb diff --git a/src/aaa-containers-indefinite_holders.ads b/aaa_base/src/aaa-containers-indefinite_holders.ads similarity index 100% rename from src/aaa-containers-indefinite_holders.ads rename to aaa_base/src/aaa-containers-indefinite_holders.ads diff --git a/aaa_base/src/aaa-containers-suite.ads b/aaa_base/src/aaa-containers-suite.ads new file mode 100644 index 0000000..f1f8ee3 --- /dev/null +++ b/aaa_base/src/aaa-containers-suite.ads @@ -0,0 +1,24 @@ +with Ada.Containers.Indefinite_Ordered_Maps; +with Ada.Containers.Indefinite_Ordered_Sets; +with Ada.Containers.Indefinite_Vectors; + +generic + type Keys (<>) is private; + type Stored (<>) is private; + with function "<" (L, R : Keys) return Boolean is <>; + with function "<" (L, R : Stored) return Boolean is <>; +package AAA.Containers.Suite with Preelaborate is + + -- A collection of ready-to-use containers with conversions among them + + package Maps is new Ada.Containers.Indefinite_Ordered_Maps (Keys, Stored); + package Sets is new Ada.Containers.Indefinite_Ordered_Sets (Stored); + package Vecs is new Ada.Containers.Indefinite_Vectors (Positive, Stored); + + type Vector is new Vecs.Vector with null record; + + ------------------- + -- Conversions -- + ------------------- + +end AAA.Containers.Suite; diff --git a/src/aaa-containers.ads b/aaa_base/src/aaa-containers.ads similarity index 100% rename from src/aaa-containers.ads rename to aaa_base/src/aaa-containers.ads diff --git a/src/aaa-debug.adb b/aaa_base/src/aaa-debug.adb similarity index 100% rename from src/aaa-debug.adb rename to aaa_base/src/aaa-debug.adb diff --git a/src/aaa-debug.ads b/aaa_base/src/aaa-debug.ads similarity index 100% rename from src/aaa-debug.ads rename to aaa_base/src/aaa-debug.ads diff --git a/src/aaa-directories.ads b/aaa_base/src/aaa-directories.ads similarity index 100% rename from src/aaa-directories.ads rename to aaa_base/src/aaa-directories.ads diff --git a/src/aaa-enum_tools.adb b/aaa_base/src/aaa-enum_tools.adb similarity index 100% rename from src/aaa-enum_tools.adb rename to aaa_base/src/aaa-enum_tools.adb diff --git a/src/aaa-enum_tools.ads b/aaa_base/src/aaa-enum_tools.ads similarity index 100% rename from src/aaa-enum_tools.ads rename to aaa_base/src/aaa-enum_tools.ads diff --git a/src/aaa-filesystem.adb b/aaa_base/src/aaa-filesystem.adb similarity index 97% rename from src/aaa-filesystem.adb rename to aaa_base/src/aaa-filesystem.adb index 257ff55..b08eec5 100644 --- a/src/aaa-filesystem.adb +++ b/aaa_base/src/aaa-filesystem.adb @@ -1,4 +1,5 @@ with AAA.Debug; +with AAA.Processes; with AAA.Strings; with Ada.Numerics.Discrete_Random; @@ -51,19 +52,18 @@ package body AAA.Filesystem is procedure Ensure_Deletable (Path : String) is use Ada.Directories; use GNAT; - OK : Boolean := False; - Args : OS_Lib.Argument_List_Access; + Args : Strings.Vector; + Result : Processes.Result; begin if Exists (Path) and then Kind (Path) = Directory and then OS_Lib.Directory_Separator = '\' then - Args := OS_Lib.Argument_String_To_List ("-R /D /S " & Path & "\*"); + Args := Strings.Split ("-R /D /S", ' ').Append (Path & "\*"); - OS_Lib.Spawn ("attrib", Args.all, OK); - OS_Lib.Free (Args); + Result := Processes.Run (Strings.To_Vector ("attrib").Append (Args)); - if not OK then + if Result.Exit_Code /= 0 then raise Program_Error with "failed to change attributes of " & Path; end if; end if; diff --git a/src/aaa-filesystem.ads b/aaa_base/src/aaa-filesystem.ads similarity index 100% rename from src/aaa-filesystem.ads rename to aaa_base/src/aaa-filesystem.ads diff --git a/src/aaa-processes.adb b/aaa_base/src/aaa-processes.adb similarity index 85% rename from src/aaa-processes.adb rename to aaa_base/src/aaa-processes.adb index 50505f6..dd011ef 100644 --- a/src/aaa-processes.adb +++ b/aaa_base/src/aaa-processes.adb @@ -79,11 +79,27 @@ package body AAA.Processes is -- & Command & " " & Arguments.Flatten -- & " > " & Name.all); - Spawn (Program_Name => Command, - Args => Arg_List, - Output_File_Descriptor => File, - Return_Code => Exit_Code, - Err_To_Out => Err_To_Out); + declare + Full_Path_Ptr : GNAT.OS_Lib.String_Access + := GNAT.OS_Lib.Locate_Exec_On_Path (Command); + Full_Path : constant String := + (if Full_Path_Ptr /= null + then Full_Path_Ptr.all + else ""); + begin + if Full_Path = "" then + raise Constraint_Error with + "Executable not found: " & Command; + else + GNAT.OS_Lib.Free (Full_Path_Ptr); + end if; + + Spawn (Program_Name => Full_Path, + Args => Arg_List, + Output_File_Descriptor => File, + Return_Code => Exit_Code, + Err_To_Out => Err_To_Out); + end; Close (File); -- Can't raise Read_Output; diff --git a/src/aaa-processes.ads b/aaa_base/src/aaa-processes.ads similarity index 100% rename from src/aaa-processes.ads rename to aaa_base/src/aaa-processes.ads diff --git a/src/aaa-strings.adb b/aaa_base/src/aaa-strings.adb similarity index 100% rename from src/aaa-strings.adb rename to aaa_base/src/aaa-strings.adb diff --git a/src/aaa-strings.ads b/aaa_base/src/aaa-strings.ads similarity index 100% rename from src/aaa-strings.ads rename to aaa_base/src/aaa-strings.ads diff --git a/src/aaa-traits-containers.ads b/aaa_base/src/aaa-traits-containers.ads similarity index 100% rename from src/aaa-traits-containers.ads rename to aaa_base/src/aaa-traits-containers.ads diff --git a/src/aaa-traits-types.ads b/aaa_base/src/aaa-traits-types.ads similarity index 100% rename from src/aaa-traits-types.ads rename to aaa_base/src/aaa-traits-types.ads diff --git a/src/aaa-traits.ads b/aaa_base/src/aaa-traits.ads similarity index 100% rename from src/aaa-traits.ads rename to aaa_base/src/aaa-traits.ads diff --git a/src/aaa.ads b/aaa_base/src/aaa.ads similarity index 100% rename from src/aaa.ads rename to aaa_base/src/aaa.ads diff --git a/aaa_base/tests/aaa_tests.gpr b/aaa_base/tests/aaa_tests.gpr new file mode 100644 index 0000000..9b2f670 --- /dev/null +++ b/aaa_base/tests/aaa_tests.gpr @@ -0,0 +1,18 @@ +with "config/aaa_tests_config.gpr"; +with "config/aaa_tests_list_config.gpr"; + +project Aaa_Tests is + for Source_Dirs use ("src/", "common/", "config/"); + for Object_Dir use "obj/" & Aaa_Tests_Config.Build_Profile; + for Create_Missing_Dirs use "True"; + for Exec_Dir use "bin"; + for Main use Aaa_Tests_List_Config.Test_Files; + + package Compiler is + for Default_Switches ("Ada") use Aaa_Tests_Config.Ada_Compiler_Switches; + end Compiler; + + package Binder is + for Switches ("Ada") use ("-Es"); -- Symbolic traceback + end Binder; +end Aaa_Tests; diff --git a/aaa_base/tests/alire.toml b/aaa_base/tests/alire.toml new file mode 100644 index 0000000..9b50984 --- /dev/null +++ b/aaa_base/tests/alire.toml @@ -0,0 +1,12 @@ +name = 'aaa_tests' +description = '' +version = '0.0.0-test' + +[[depends-on]] +aaa = '*' + +[[pins]] +aaa = { path = '..' } + +[build-profiles] +"*" = "validation" diff --git a/aaa_base/tests/common/aaa_tests-strings.ads b/aaa_base/tests/common/aaa_tests-strings.ads new file mode 100644 index 0000000..efa027b --- /dev/null +++ b/aaa_base/tests/common/aaa_tests-strings.ads @@ -0,0 +1,3 @@ +package Aaa_Tests.Strings is + +end Aaa_Tests.Strings; diff --git a/aaa_base/tests/common/aaa_tests.adb b/aaa_base/tests/common/aaa_tests.adb new file mode 100644 index 0000000..6b02e3f --- /dev/null +++ b/aaa_base/tests/common/aaa_tests.adb @@ -0,0 +1,12 @@ +package body Aaa_Tests is + + ------------ + -- Assert -- + ------------ + + procedure Assert (Cond : Boolean; Text : String) is + begin + pragma Assert (Cond, Text); + end Assert; + +end Aaa_Tests; diff --git a/aaa_base/tests/common/aaa_tests.ads b/aaa_base/tests/common/aaa_tests.ads new file mode 100644 index 0000000..0f01a8b --- /dev/null +++ b/aaa_base/tests/common/aaa_tests.ads @@ -0,0 +1,5 @@ +package Aaa_Tests is + + procedure Assert (Cond : Boolean; Text : String); + +end Aaa_Tests; diff --git a/aaa_base/tests/config/aaa_tests_config.ads b/aaa_base/tests/config/aaa_tests_config.ads new file mode 100644 index 0000000..f7d40d8 --- /dev/null +++ b/aaa_base/tests/config/aaa_tests_config.ads @@ -0,0 +1,20 @@ +-- Configuration for aaa_tests generated by Alire +pragma Restrictions (No_Elaboration_Code); +pragma Style_Checks (Off); + +package Aaa_Tests_Config is + pragma Pure; + + Crate_Version : constant String := "0.0.0-test"; + Crate_Name : constant String := "aaa_tests"; + + Alire_Host_OS : constant String := "linux"; + + Alire_Host_Arch : constant String := "x86_64"; + + Alire_Host_Distro : constant String := "ubuntu"; + + type Build_Profile_Kind is (release, validation, development); + Build_Profile : constant Build_Profile_Kind := validation; + +end Aaa_Tests_Config; diff --git a/aaa_base/tests/config/aaa_tests_config.gpr b/aaa_base/tests/config/aaa_tests_config.gpr new file mode 100644 index 0000000..e9bec49 --- /dev/null +++ b/aaa_base/tests/config/aaa_tests_config.gpr @@ -0,0 +1,55 @@ +-- Configuration for aaa_tests generated by Alire +with "aaa.gpr"; +abstract project Aaa_Tests_Config is + Crate_Version := "0.0.0-test"; + Crate_Name := "aaa_tests"; + + Alire_Host_OS := "linux"; + + Alire_Host_Arch := "x86_64"; + + Alire_Host_Distro := "ubuntu"; + Ada_Compiler_Switches := External_As_List ("ADAFLAGS", " "); + Ada_Compiler_Switches := Ada_Compiler_Switches & + ( + "-O3" -- Optimize for performance + ,"-gnatn" -- Enable inlining + ,"-ffunction-sections" -- Separate ELF section for each function + ,"-fdata-sections" -- Separate ELF section for each variable + ,"-g" -- Generate debug info + ,"-gnato" -- Enable numeric overflow checking + ,"-gnatwa" -- Enable all warnings + ,"-gnatw.X" -- Disable warnings for No_Exception_Propagation + ,"-gnatVa" -- All validity checks + ,"-gnatwe" -- Warnings as errors + ,"-gnata" -- Enable assertions and contracts + ,"-gnaty3" -- Specify indentation level of 3 + ,"-gnatya" -- Check attribute casing + ,"-gnatyA" -- Use of array index numbers in array attributes + ,"-gnatyB" -- Check Boolean operators + ,"-gnatyb" -- Blanks not allowed at statement end + ,"-gnatyc" -- Check comments + ,"-gnaty-d" -- Disable check no DOS line terminators present + ,"-gnatye" -- Check end/exit labels + ,"-gnatyf" -- No form feeds or vertical tabs + ,"-gnatyh" -- No horizontal tabs + ,"-gnatyi" -- Check if-then layout + ,"-gnatyI" -- check mode IN keywords + ,"-gnatyk" -- Check keyword casing + ,"-gnatyl" -- Check layout + ,"-gnatym" -- Check maximum line length + ,"-gnatyn" -- Check casing of entities in Standard + ,"-gnatyO" -- Check that overriding subprograms are explicitly marked as such + ,"-gnatyp" -- Check pragma casing + ,"-gnatyr" -- Check identifier references casing + ,"-gnatyS" -- Check no statements after THEN/ELSE + ,"-gnatyt" -- Check token spacing + ,"-gnatyu" -- Check unnecessary blank lines + ,"-gnatyx" -- Check extra parentheses + ,"-gnatW8" -- UTF-8 encoding for wide characters + ); + + type Build_Profile_Kind is ("release", "validation", "development"); + Build_Profile : Build_Profile_Kind := "validation"; + +end Aaa_Tests_Config; diff --git a/aaa_base/tests/config/aaa_tests_config.h b/aaa_base/tests/config/aaa_tests_config.h new file mode 100644 index 0000000..cab4378 --- /dev/null +++ b/aaa_base/tests/config/aaa_tests_config.h @@ -0,0 +1,20 @@ +/* Configuration for aaa_tests generated by Alire */ +#ifndef AAA_TESTS_CONFIG_H +#define AAA_TESTS_CONFIG_H + +#define CRATE_VERSION "0.0.0-test" +#define CRATE_NAME "aaa_tests" + +#define ALIRE_HOST_OS "linux" + +#define ALIRE_HOST_ARCH "x86_64" + +#define ALIRE_HOST_DISTRO "ubuntu" + +#define BUILD_PROFILE_RELEASE 1 +#define BUILD_PROFILE_VALIDATION 2 +#define BUILD_PROFILE_DEVELOPMENT 3 + +#define BUILD_PROFILE 2 + +#endif diff --git a/aaa_base/tests/config/aaa_tests_list_config.gpr b/aaa_base/tests/config/aaa_tests_list_config.gpr new file mode 100644 index 0000000..635793b --- /dev/null +++ b/aaa_base/tests/config/aaa_tests_list_config.gpr @@ -0,0 +1,6 @@ +abstract project Aaa_Tests_List_Config is + Test_Files := ( + "aaa_tests-strings-check_vector_equality.adb" + ,"aaa_tests-strings-vector_diffs.adb" + ); +end Aaa_Tests_List_Config; diff --git a/aaa_base/tests/src/aaa_tests-strings-check_vector_equality.adb b/aaa_base/tests/src/aaa_tests-strings-check_vector_equality.adb new file mode 100644 index 0000000..57c4dd1 --- /dev/null +++ b/aaa_base/tests/src/aaa_tests-strings-check_vector_equality.adb @@ -0,0 +1,40 @@ +pragma Style_Checks ("-gnatM120"); + +with AAA.Strings; use AAA.Strings; + +procedure Aaa_Tests.Strings.Check_Vector_Equality is + + procedure Check_Equality is + A : constant AAA.Strings.Vector := Empty_Vector.Append ("A").Append ("B").Append ("C"); + B : constant AAA.Strings.Vector := Empty_Vector.Append ("A").Append ("B").Append ("C").Append ("D"); + C : constant AAA.Strings.Vector := Empty_Vector.Append ("B").Append ("C"); + D : constant AAA.Strings.Vector := Empty_Vector.Append ("A").Append ("B").Append ("C"); + begin + + Assert (Empty_Vector = Empty_Vector, "Empty_Vector = Empty_Vector"); + + Assert (A /= Empty_Vector, "A /= Empty_Vector"); + Assert (B /= Empty_Vector, "B /= Empty_Vector"); + Assert (C /= Empty_Vector, "C /= Empty_Vector"); + Assert (D /= Empty_Vector, "D /= Empty_Vector"); + + Assert (A = A, "A = A"); + Assert (B = B, "B = B"); + Assert (C = C, "C = C"); + Assert (D = D, "D = D"); + + Assert (A /= B, "A /= B"); + Assert (B /= A, "B /= A"); + + Assert (A /= C, "A /= C"); + Assert (C /= A, "C /= A"); + + Assert (B /= C, "B /= C"); + Assert (C /= B, "C /= B"); + + Assert (A = D, "A = D"); + end Check_Equality; + +begin + Check_Equality; +end Aaa_Tests.Strings.Check_Vector_Equality; diff --git a/tests/src/test_cases-strings-vector.adb b/aaa_base/tests/src/aaa_tests-strings-vector_diffs.adb similarity index 55% rename from tests/src/test_cases-strings-vector.adb rename to aaa_base/tests/src/aaa_tests-strings-vector_diffs.adb index b5e66fe..de1ed03 100644 --- a/tests/src/test_cases-strings-vector.adb +++ b/aaa_base/tests/src/aaa_tests-strings-vector_diffs.adb @@ -1,56 +1,17 @@ -with AUnit.Assertions; use AUnit.Assertions; - with AAA.Strings; use AAA.Strings; -package body Test_Cases.Strings.Vector is - - -------------------- - -- Check_Equality -- - -------------------- - - procedure Check_Equality (Unused : in out Null_Fixture) is - A : constant AAA.Strings.Vector := Empty_Vector.Append ("A").Append("B").Append ("C"); - B : constant AAA.Strings.Vector := Empty_Vector.Append ("A").Append("B").Append ("C").Append ("D"); - C : constant AAA.Strings.Vector := Empty_Vector.Append ("B").Append ("C"); - D : constant AAA.Strings.Vector := Empty_Vector.Append ("A").Append("B").Append ("C"); - begin - - Assert (Empty_Vector = Empty_Vector, "Empty_Vector = Empty_Vector"); - - Assert (A /= Empty_Vector, "A /= Empty_Vector"); - Assert (B /= Empty_Vector, "B /= Empty_Vector"); - Assert (C /= Empty_Vector, "C /= Empty_Vector"); - Assert (D /= Empty_Vector, "D /= Empty_Vector"); - - Assert (A = A, "A = A"); - Assert (B = B, "B = B"); - Assert (C = C, "C = C"); - Assert (D = D, "D = D"); +pragma Style_Checks ("-gnatM120"); - Assert (A /= B, "A /= B"); - Assert (B /= A, "B /= A"); +procedure Aaa_Tests.Strings.Vector_Diffs is - Assert (A /= C, "A /= C"); - Assert (C /= A, "C /= A"); - - Assert (B /= C, "B /= C"); - Assert (C /= B, "C /= B"); - - Assert (A = D, "A = D"); - end Check_Equality; - - ---------------- - -- Check_Diff -- - ---------------- - - procedure Check_Diff (Unused : in out Null_Fixture) is + procedure Check_Diff is procedure Check (V1, V2, Expected : AAA.Strings.Vector; Skip_Header : Boolean := True) is Result : constant AAA.Strings.Vector := - Diff (V1, V2, - Skip_Header => Skip_Header); + Diff (V1, V2, + Skip_Header => Skip_Header); begin if Result /= Expected then Assert (False, "Diff (V1, V2): " & ASCII.LF & @@ -66,9 +27,9 @@ package body Test_Cases.Strings.Vector is end Check; A : constant AAA.Strings.Vector := Empty_Vector.Append ("1").Append ("2").Append ("3"); - B : constant AAA.Strings.Vector := Empty_Vector.Append ("1").Append("2").Append ("3").Append ("4"); + B : constant AAA.Strings.Vector := Empty_Vector.Append ("1").Append ("2").Append ("3").Append ("4"); C : constant AAA.Strings.Vector := Empty_Vector.Append ("2").Append ("3"); - D : constant AAA.Strings.Vector := Empty_Vector.Append ("5").Append("6").Append ("7"); + D : constant AAA.Strings.Vector := Empty_Vector.Append ("5").Append ("6").Append ("7"); begin Check (A, A, @@ -123,10 +84,5 @@ package body Test_Cases.Strings.Vector is end Check_Diff; begin - - Suite.Add_Test (Null_Caller.Create ("Strings.Vector.Equality", - Check_Equality'Access)); - Suite.Add_Test (Null_Caller.Create ("Strings.Vector.Diff", - Check_Diff'Access)); - -end Test_Cases.Strings.Vector; + Check_Diff; +end Aaa_Tests.Strings.Vector_Diffs; diff --git a/aaa_demos.gpr b/aaa_demos.gpr deleted file mode 100644 index 857bb52..0000000 --- a/aaa_demos.gpr +++ /dev/null @@ -1,20 +0,0 @@ -with "aaa"; - -project AAA_Demos is - - for Source_Dirs use ("src/demos"); - for Object_Dir use "obj"; - for Exec_Dir use "bin"; - for Main use ("aaa-demo-misc.adb"); - - package Builder renames AAA.Builder; - - package Compiler renames AAA.Compiler; - - package Binder renames AAA.Binder; - - package Linker is - for Switches ("ada") use ("-g"); - end Linker; - -end AAA_Demos; diff --git a/aaa_dev.gpr b/aaa_dev.gpr deleted file mode 100644 index d2f5068..0000000 --- a/aaa_dev.gpr +++ /dev/null @@ -1,6 +0,0 @@ -aggregate project AAA_Dev is - - for Project_Files use ("aaa.gpr", - "aaa_demos.gpr"); - -end AAA_Dev; diff --git a/aaa_texts/.gitignore b/aaa_texts/.gitignore new file mode 100644 index 0000000..0a2e2d8 --- /dev/null +++ b/aaa_texts/.gitignore @@ -0,0 +1,4 @@ +/obj/ +/lib/ +/alire/ +/config/ diff --git a/aaa_texts/aaa_texts.gpr b/aaa_texts/aaa_texts.gpr new file mode 100644 index 0000000..6cb867a --- /dev/null +++ b/aaa_texts/aaa_texts.gpr @@ -0,0 +1,31 @@ +with "config/aaa_texts_config.gpr"; +with "aaa.gpr"; +with "lml.gpr"; +project Aaa_Texts is + + for Library_Name use "Aaa_Texts"; + for Library_Version use Project'Library_Name & ".so." & Aaa_Texts_Config.Crate_Version; + + for Source_Dirs use ("src/", "config/"); + for Object_Dir use "obj/" & Aaa_Texts_Config.Build_Profile; + for Create_Missing_Dirs use "True"; + for Library_Dir use "lib"; + + type Library_Type_Type is ("relocatable", "static", "static-pic"); + Library_Type : Library_Type_Type := + external ("AAA_TEXTS_LIBRARY_TYPE", external ("LIBRARY_TYPE", "static")); + for Library_Kind use Library_Type; + + package Compiler is + for Default_Switches ("Ada") use Aaa_Texts_Config.Ada_Compiler_Switches; + end Compiler; + + package Binder is + for Switches ("Ada") use ("-Es"); -- Symbolic traceback + end Binder; + + package Install is + for Artifacts (".") use ("share"); + end Install; + +end Aaa_Texts; diff --git a/aaa_texts/alire.toml b/aaa_texts/alire.toml new file mode 100644 index 0000000..e44930a --- /dev/null +++ b/aaa_texts/alire.toml @@ -0,0 +1,19 @@ +name = "aaa_texts" +description = "Utilities to deal with enriched human texts (ANSI, Unicode)" +version = "0.3.0" + +authors = ["Alejandro R. Mosteo"] +maintainers = ["Alejandro R. Mosteo "] +maintainers-logins = ["mosteo"] +licenses = "LGPL-3.0-only" +website = "https://github.com/mosteo/aaa" +tags = ["unicode", "ansi", "console", "terminal", "tables"] + +[[depends-on]] +aaa = "~0.3.0" +ansiada = "^1.1.0" +lml = "~0.1.0" +umwi = "~0.1.0" + +[test] +runner = "alire" diff --git a/src/aaa-ansi.adb b/aaa_texts/src/aaa-ansi.adb similarity index 100% rename from src/aaa-ansi.adb rename to aaa_texts/src/aaa-ansi.adb diff --git a/src/aaa-ansi.ads b/aaa_texts/src/aaa-ansi.ads similarity index 100% rename from src/aaa-ansi.ads rename to aaa_texts/src/aaa-ansi.ads diff --git a/src/aaa-table_io.adb b/aaa_texts/src/aaa-table_io.adb similarity index 59% rename from src/aaa-table_io.adb rename to aaa_texts/src/aaa-table_io.adb index 6acf707..3cbc74c 100644 --- a/src/aaa-table_io.adb +++ b/aaa_texts/src/aaa-table_io.adb @@ -1,11 +1,16 @@ with AAA.ANSI; +with AAA.Strings; with Ada.Containers; with Ada.Strings.UTF_Encoding.Wide_Wide_Strings; with Ada.Strings.Wide_Wide_Unbounded; +with AnsiAda; + with GNAT.IO; +with LML.Output.Factory; + with Umwi; package body AAA.Table_IO is @@ -22,6 +27,12 @@ package body AAA.Table_IO is procedure Append (T : in out Table; Cell : String) is begin + if T.Section = Headers and then not T.Is_Header then + raise Constraint_Error with + "Adding data before completing headers (missing New_Row?)"; + end if; + T.Is_Header := False; + declare Cell : constant Wide_Wide_String := UTF.Wide_Wide_Strings.Decode (Append.Cell); @@ -53,12 +64,46 @@ package body AAA.Table_IO is return Reference'(Table => T'Access); end Append; + ------------ + -- Header -- + ------------ + + procedure Header (T : in out Table; Cell : String) is + begin + if T.Rows.Length > 1 then + raise Program_Error with "Headers must be added before any data rows"; + end if; + + T.Section := Headers; + T.Is_Header := True; + + T.Headers.Append (UTF.Wide_Wide_Strings.Decode (Cell)); + T.Append (Cell); + end Header; + + ------------ + -- Header -- + ------------ + + function Header (T : aliased in out Table; + Cell : String) + return Reference + is + begin + T.Header (Cell); + return Reference'(Table => T'Access); + end Header; + ------------- -- New_Row -- ------------- procedure New_Row (T : in out Table) is begin + if not T.Rows.Is_Empty then + T.Section := Data; + end if; + T.Next_Column := 1; T.Rows.Append (String_Vectors.Empty_Vector); end New_Row; @@ -135,6 +180,11 @@ package body AAA.Table_IO is Wide_Separator : constant Wide_Wide_String := UTF.Wide_Wide_Strings.Decode (Separator); begin + if T.Section = Headers then + raise Constraint_Error + with "Headers section not yet complete (missing New_Row?)"; + end if; + for Row of T.Rows loop declare Line : Unbounded_Wide_Wide_String; @@ -169,4 +219,77 @@ package body AAA.Table_IO is end loop; end Print; + ----------- + -- Print -- + ----------- + + procedure Print (T : Table; + Format : LML.Formats; + Put_Line : access procedure (Line : String) := null) + is + use AAA.Strings; + Builder : LML.Output.Builder'Class := LML.Output.Factory.Get (Format); + begin + + if T.Section = Headers then + raise Constraint_Error + with "Headers section not yet complete (missing New_Row?)"; + end if; + + -- Ada_TOML requires an anonymous top-level table, and as a consequence + -- the nested array must have a name. We could alternatively use a + -- map with indexes as keys, but as those would have to be strings in + -- the TOML case at least, we would lose the original ordering unless + -- padding were added, which would in turn difficult data extraction. + + if Format in LML.TOML then + Builder.Begin_Map; + Builder.Insert ("data"); + end if; + + Builder.Begin_Vec; + + for Row in 2 .. Natural (T.Rows.Length) loop + + -- Skip last empty line, which is naturally filtered out in the + -- non-structured alternative. Here we are creating the empty + -- record too soon (in between loops). + + if Row < Natural (T.Rows.Length) + or else Natural (T.Rows (Row).Length) > 0 + then + + Builder.Begin_Map; + + for Col in 1 .. Integer (T.Rows (Row).Length) loop + if Col > Integer (T.Headers.Length) then + raise Constraint_Error with + "Missing header for column" & Col'Image; + end if; + + Builder.Insert + (LML.Decode + (Trim (AnsiAda.Scrub (LML.Encode (T.Headers (Col)))))); + Builder.Append + (LML.Scalars.New_Text + (LML.Decode + (Trim + (AnsiAda.Scrub + (LML.Encode (T.Rows (Row) (Col))))))); + end loop; + + Builder.End_Map; + + end if; + end loop; + + Builder.End_Vec; + + if Format in LML.TOML then + Builder.End_Map; + end if; + + Put_Line (LML.Encode (Builder.To_Text)); + end Print; + end AAA.Table_IO; diff --git a/src/aaa-table_io.ads b/aaa_texts/src/aaa-table_io.ads similarity index 67% rename from src/aaa-table_io.ads rename to aaa_texts/src/aaa-table_io.ads index fe31f7e..e7eb2c0 100644 --- a/src/aaa-table_io.ads +++ b/aaa_texts/src/aaa-table_io.ads @@ -3,7 +3,9 @@ with Ada.Containers.Vectors; with Ada.Strings; -package AAA.Table_IO with Preelaborate is +with LML; + +package AAA.Table_IO is -- A type to format tables according to the max length of fields. The table -- is ANSI-aware, so it will work properly for text with embedded ANSI @@ -16,13 +18,21 @@ package AAA.Table_IO with Preelaborate is type Table is tagged private; - type Reference (Table : access Table_IO.Table) is limited null record + type Reference (Table : access Table_IO.Table'Class) is limited null record with Implicit_Dereference => Table; procedure Append (T : in out Table; Cell : String); function Append (T : aliased in out Table; Cell : String) return Reference; + procedure Header (T : in out Table; Cell : String); + -- Headers are printed as given, but are keep internally for the structured + -- output as field names. There should be as many headers as columns. + + function Header (T : aliased in out Table; + Cell : String) + return Reference; + procedure New_Row (T : in out Table); type Alignments is array (Positive range <>) of Ada.Strings.Alignment; @@ -34,6 +44,10 @@ package AAA.Table_IO with Preelaborate is -- Will print the table using GNAT.IO, unless Put_Line is supplied -- FIXME: Align is currently ignored + procedure Print (T : Table; + Format : LML.Formats; + Put_Line : access procedure (Line : String) := null); + private package Natural_Vectors is new Ada.Containers.Vectors (Positive, Natural); @@ -46,10 +60,16 @@ private package Row_Vectors is new Ada.Containers.Vectors (Positive, Row); + type Sections is (Nothing, Headers, Data); + type Table is tagged record Next_Column : Positive := 1; + Headers : Row; Rows : Row_Vectors.Vector; Max_Widths : Natural_Vectors.Vector; + Section : Sections := Nothing; + Is_Header : Boolean := False; + -- Internal state to discriminate in Append when a header is being added end record; end AAA.Table_IO; diff --git a/src/aaa-text_io.adb b/aaa_texts/src/aaa-text_io.adb similarity index 100% rename from src/aaa-text_io.adb rename to aaa_texts/src/aaa-text_io.adb diff --git a/src/aaa-text_io.ads b/aaa_texts/src/aaa-text_io.ads similarity index 100% rename from src/aaa-text_io.ads rename to aaa_texts/src/aaa-text_io.ads diff --git a/aaa_texts/tests/aaa_texts_tests.gpr b/aaa_texts/tests/aaa_texts_tests.gpr new file mode 100644 index 0000000..0a35ba8 --- /dev/null +++ b/aaa_texts/tests/aaa_texts_tests.gpr @@ -0,0 +1,20 @@ +with "config/aaa_texts_tests_config.gpr"; +with "config/aaa_texts_tests_list_config.gpr"; + +with "lml.gpr"; + +project Aaa_Texts_Tests is + for Source_Dirs use ("src/", "common/", "config/"); + for Object_Dir use "obj/" & Aaa_Texts_Tests_Config.Build_Profile; + for Create_Missing_Dirs use "True"; + for Exec_Dir use "bin"; + for Main use Aaa_Texts_Tests_List_Config.Test_Files; + + package Compiler is + for Default_Switches ("Ada") use Aaa_Texts_Tests_Config.Ada_Compiler_Switches; + end Compiler; + + package Binder is + for Switches ("Ada") use ("-Es"); -- Symbolic traceback + end Binder; +end Aaa_Texts_Tests; diff --git a/aaa_texts/tests/alire.toml b/aaa_texts/tests/alire.toml new file mode 100644 index 0000000..3cf21ea --- /dev/null +++ b/aaa_texts/tests/alire.toml @@ -0,0 +1,13 @@ +name = 'aaa_texts_tests' +description = '' +version = '0.0.0-test' + +[[depends-on]] +aaa_texts = '*' + +[[pins]] +aaa = { path = '../../aaa_base' } +aaa_texts = { path = ".." } + +[build-profiles] +"*" = "validation" diff --git a/aaa_texts/tests/common/aaa_texts_tests.ads b/aaa_texts/tests/common/aaa_texts_tests.ads new file mode 100644 index 0000000..8b5d41c --- /dev/null +++ b/aaa_texts/tests/common/aaa_texts_tests.ads @@ -0,0 +1,2 @@ +package Aaa_Texts_Tests is +end Aaa_Texts_Tests; diff --git a/aaa_texts/tests/config/aaa_texts_tests_config.ads b/aaa_texts/tests/config/aaa_texts_tests_config.ads new file mode 100644 index 0000000..2d3060e --- /dev/null +++ b/aaa_texts/tests/config/aaa_texts_tests_config.ads @@ -0,0 +1,20 @@ +-- Configuration for aaa_texts_tests generated by Alire +pragma Restrictions (No_Elaboration_Code); +pragma Style_Checks (Off); + +package Aaa_Texts_Tests_Config is + pragma Pure; + + Crate_Version : constant String := "0.0.0-test"; + Crate_Name : constant String := "aaa_texts_tests"; + + Alire_Host_OS : constant String := "linux"; + + Alire_Host_Arch : constant String := "x86_64"; + + Alire_Host_Distro : constant String := "ubuntu"; + + type Build_Profile_Kind is (release, validation, development); + Build_Profile : constant Build_Profile_Kind := validation; + +end Aaa_Texts_Tests_Config; diff --git a/aaa_texts/tests/config/aaa_texts_tests_config.gpr b/aaa_texts/tests/config/aaa_texts_tests_config.gpr new file mode 100644 index 0000000..c06f18e --- /dev/null +++ b/aaa_texts/tests/config/aaa_texts_tests_config.gpr @@ -0,0 +1,55 @@ +-- Configuration for aaa_texts_tests generated by Alire +with "aaa_texts.gpr"; +abstract project Aaa_Texts_Tests_Config is + Crate_Version := "0.0.0-test"; + Crate_Name := "aaa_texts_tests"; + + Alire_Host_OS := "linux"; + + Alire_Host_Arch := "x86_64"; + + Alire_Host_Distro := "ubuntu"; + Ada_Compiler_Switches := External_As_List ("ADAFLAGS", " "); + Ada_Compiler_Switches := Ada_Compiler_Switches & + ( + "-O3" -- Optimize for performance + ,"-gnatn" -- Enable inlining + ,"-ffunction-sections" -- Separate ELF section for each function + ,"-fdata-sections" -- Separate ELF section for each variable + ,"-g" -- Generate debug info + ,"-gnato" -- Enable numeric overflow checking + ,"-gnatwa" -- Enable all warnings + ,"-gnatw.X" -- Disable warnings for No_Exception_Propagation + ,"-gnatVa" -- All validity checks + ,"-gnatwe" -- Warnings as errors + ,"-gnata" -- Enable assertions and contracts + ,"-gnaty3" -- Specify indentation level of 3 + ,"-gnatya" -- Check attribute casing + ,"-gnatyA" -- Use of array index numbers in array attributes + ,"-gnatyB" -- Check Boolean operators + ,"-gnatyb" -- Blanks not allowed at statement end + ,"-gnatyc" -- Check comments + ,"-gnaty-d" -- Disable check no DOS line terminators present + ,"-gnatye" -- Check end/exit labels + ,"-gnatyf" -- No form feeds or vertical tabs + ,"-gnatyh" -- No horizontal tabs + ,"-gnatyi" -- Check if-then layout + ,"-gnatyI" -- check mode IN keywords + ,"-gnatyk" -- Check keyword casing + ,"-gnatyl" -- Check layout + ,"-gnatym" -- Check maximum line length + ,"-gnatyn" -- Check casing of entities in Standard + ,"-gnatyO" -- Check that overriding subprograms are explicitly marked as such + ,"-gnatyp" -- Check pragma casing + ,"-gnatyr" -- Check identifier references casing + ,"-gnatyS" -- Check no statements after THEN/ELSE + ,"-gnatyt" -- Check token spacing + ,"-gnatyu" -- Check unnecessary blank lines + ,"-gnatyx" -- Check extra parentheses + ,"-gnatW8" -- UTF-8 encoding for wide characters + ); + + type Build_Profile_Kind is ("release", "validation", "development"); + Build_Profile : Build_Profile_Kind := "validation"; + +end Aaa_Texts_Tests_Config; diff --git a/aaa_texts/tests/config/aaa_texts_tests_config.h b/aaa_texts/tests/config/aaa_texts_tests_config.h new file mode 100644 index 0000000..64b4677 --- /dev/null +++ b/aaa_texts/tests/config/aaa_texts_tests_config.h @@ -0,0 +1,20 @@ +/* Configuration for aaa_texts_tests generated by Alire */ +#ifndef AAA_TEXTS_TESTS_CONFIG_H +#define AAA_TEXTS_TESTS_CONFIG_H + +#define CRATE_VERSION "0.0.0-test" +#define CRATE_NAME "aaa_texts_tests" + +#define ALIRE_HOST_OS "linux" + +#define ALIRE_HOST_ARCH "x86_64" + +#define ALIRE_HOST_DISTRO "ubuntu" + +#define BUILD_PROFILE_RELEASE 1 +#define BUILD_PROFILE_VALIDATION 2 +#define BUILD_PROFILE_DEVELOPMENT 3 + +#define BUILD_PROFILE 2 + +#endif diff --git a/aaa_texts/tests/config/aaa_texts_tests_list_config.gpr b/aaa_texts/tests/config/aaa_texts_tests_list_config.gpr new file mode 100644 index 0000000..e0536a6 --- /dev/null +++ b/aaa_texts/tests/config/aaa_texts_tests_list_config.gpr @@ -0,0 +1,5 @@ +abstract project Aaa_Texts_Tests_List_Config is + Test_Files := ( + "aaa_texts_tests-example_test.adb" + ); +end Aaa_Texts_Tests_List_Config; diff --git a/aaa_texts/tests/src/aaa_texts_tests-example_test.adb b/aaa_texts/tests/src/aaa_texts_tests-example_test.adb new file mode 100644 index 0000000..344cf7b --- /dev/null +++ b/aaa_texts/tests/src/aaa_texts_tests-example_test.adb @@ -0,0 +1,6 @@ +with Ada.Assertions; + +procedure Aaa_Texts_Tests.Example_Test is +begin + Ada.Assertions.Assert (True); +end Aaa_Texts_Tests.Example_Test; diff --git a/tests/.gitignore b/dev/.gitignore similarity index 100% rename from tests/.gitignore rename to dev/.gitignore diff --git a/dev/alire.toml b/dev/alire.toml new file mode 100644 index 0000000..95188f5 --- /dev/null +++ b/dev/alire.toml @@ -0,0 +1,31 @@ +name = "dev" +description = "" +version = "0.1.0-dev" + +authors = ["Alejandro R. Mosteo"] +maintainers = ["Alejandro R. Mosteo "] +maintainers-logins = ["mosteo"] +licenses = "MIT OR Apache-2.0 WITH LLVM-exception" +website = "" +tags = [] + +executables = ["dev"] + +[build-profiles] +"*" = "validation" + +[[test]] +runner = "alire" +directory = "../aaa_base/tests" + +[[test]] +runner = "alire" +directory = "../aaa_texts/tests" + +[[depends-on]] +aaa_tests = "*" +aaa_texts_tests = "*" + +[[pins]] +aaa_tests = { path = "../aaa_base/tests" } +aaa_texts_tests = { path = "../aaa_texts/tests" } diff --git a/dev/dev.gpr b/dev/dev.gpr new file mode 100644 index 0000000..719f9ac --- /dev/null +++ b/dev/dev.gpr @@ -0,0 +1,22 @@ +with "config/dev_config.gpr"; +project Dev is + + for Source_Dirs use ("src/", "config/"); + for Object_Dir use "obj/" & Dev_Config.Build_Profile; + for Create_Missing_Dirs use "True"; + for Exec_Dir use "bin"; + for Main use ("dev.adb"); + + package Compiler is + for Default_Switches ("Ada") use Dev_Config.Ada_Compiler_Switches; + end Compiler; + + package Binder is + for Switches ("Ada") use ("-Es"); -- Symbolic traceback + end Binder; + + package Install is + for Artifacts (".") use ("share"); + end Install; + +end Dev; diff --git a/dev/src/dev.adb b/dev/src/dev.adb new file mode 100644 index 0000000..0f7f63a --- /dev/null +++ b/dev/src/dev.adb @@ -0,0 +1,4 @@ +procedure Dev is +begin + null; +end Dev; diff --git a/dev/tests/alire.toml b/dev/tests/alire.toml new file mode 100644 index 0000000..cfb2150 --- /dev/null +++ b/dev/tests/alire.toml @@ -0,0 +1,12 @@ +name = 'dev_tests' +description = '' +version = '0.0.0-test' + +[[depends-on]] +dev = '*' + +[[pins]] +dev = { path = '..' } + +[build-profiles] +dev = 'validation' diff --git a/dev/tests/common/dev_tests.ads b/dev/tests/common/dev_tests.ads new file mode 100644 index 0000000..8e02779 --- /dev/null +++ b/dev/tests/common/dev_tests.ads @@ -0,0 +1,2 @@ +package Dev_Tests is +end Dev_Tests; diff --git a/dev/tests/dev_tests.gpr b/dev/tests/dev_tests.gpr new file mode 100644 index 0000000..ccdbf63 --- /dev/null +++ b/dev/tests/dev_tests.gpr @@ -0,0 +1,18 @@ +with "config/dev_tests_config.gpr"; +with "config/dev_tests_list_config.gpr"; + +project Dev_Tests is + for Source_Dirs use ("src/", "common/", "config/"); + for Object_Dir use "obj/" & Dev_Tests_Config.Build_Profile; + for Create_Missing_Dirs use "True"; + for Exec_Dir use "bin"; + for Main use Dev_Tests_List_Config.Test_Files; + + package Compiler is + for Default_Switches ("Ada") use Dev_Tests_Config.Ada_Compiler_Switches; + end Compiler; + + package Binder is + for Switches ("Ada") use ("-Es"); -- Symbolic traceback + end Binder; +end Dev_Tests; diff --git a/dev/tests/src/dev_tests-example_test.adb b/dev/tests/src/dev_tests-example_test.adb new file mode 100644 index 0000000..0df6ff4 --- /dev/null +++ b/dev/tests/src/dev_tests-example_test.adb @@ -0,0 +1,6 @@ +with Ada.Assertions; + +procedure Dev_Tests.Example_Test is +begin + Ada.Assertions.Assert (True); +end Dev_Tests.Example_Test; diff --git a/src/aaa-tests.ads b/src/aaa-tests.ads deleted file mode 100644 index 5716012..0000000 --- a/src/aaa-tests.ads +++ /dev/null @@ -1,3 +0,0 @@ -package AAA.Tests is - -end AAA.Tests; diff --git a/src/demos/aaa-demo-misc.adb b/src/demos/aaa-demo-misc.adb deleted file mode 100644 index 4f09e00..0000000 --- a/src/demos/aaa-demo-misc.adb +++ /dev/null @@ -1,4 +0,0 @@ -procedure AAA.Demo.Misc is -begin - null; -end AAA.Demo.Misc; diff --git a/src/demos/aaa-demo.ads b/src/demos/aaa-demo.ads deleted file mode 100644 index 8e19b2e..0000000 --- a/src/demos/aaa-demo.ads +++ /dev/null @@ -1,2 +0,0 @@ -package AAA.Demo with Preelaborate is -end AAA.Demo; diff --git a/tests/alire.toml b/tests/alire.toml deleted file mode 100644 index 82ed74b..0000000 --- a/tests/alire.toml +++ /dev/null @@ -1,15 +0,0 @@ -name = "tests" -description = "" -version = "0.0.0" - -executables = ["tests"] - -[configuration] -disabled = false - -[[depends-on]] -aaa = "*" -aunit = "^21" - -[[pins]] -aaa = { path='../../aaa' } diff --git a/tests/src/test_cases-strings-vector.ads b/tests/src/test_cases-strings-vector.ads deleted file mode 100644 index 18ed88b..0000000 --- a/tests/src/test_cases-strings-vector.ads +++ /dev/null @@ -1,4 +0,0 @@ -package Test_Cases.Strings.Vector is - pragma Elaborate_Body; - -end Test_Cases.Strings.Vector; diff --git a/tests/src/test_cases-strings.ads b/tests/src/test_cases-strings.ads deleted file mode 100644 index 3f9edbd..0000000 --- a/tests/src/test_cases-strings.ads +++ /dev/null @@ -1,2 +0,0 @@ -package Test_Cases.Strings is -end Test_Cases.Strings; diff --git a/tests/src/test_cases.adb b/tests/src/test_cases.adb deleted file mode 100644 index d9b1e8e..0000000 --- a/tests/src/test_cases.adb +++ /dev/null @@ -1,10 +0,0 @@ -package body Test_Cases is - - --------------- - -- Get_Suite -- - --------------- - - function Get_Suite return AUnit.Test_Suites.Access_Test_Suite - is (Suite'Access); - -end Test_Cases; diff --git a/tests/src/test_cases.ads b/tests/src/test_cases.ads deleted file mode 100644 index 793ed88..0000000 --- a/tests/src/test_cases.ads +++ /dev/null @@ -1,18 +0,0 @@ -with AUnit.Test_Suites; - -private with AUnit.Test_Fixtures; -private with AUnit.Test_Caller; - -package Test_Cases is - - function Get_Suite return AUnit.Test_Suites.Access_Test_Suite; - -private - - type Null_Fixture is new AUnit.Test_Fixtures.Test_Fixture with null record; - - package Null_Caller is new AUnit.Test_Caller (Null_Fixture); - - Suite : aliased AUnit.Test_Suites.Test_Suite; - -end Test_Cases; diff --git a/tests/src/tests.adb b/tests/src/tests.adb deleted file mode 100644 index 4bd1922..0000000 --- a/tests/src/tests.adb +++ /dev/null @@ -1,30 +0,0 @@ -with AUnit; use AUnit; -with AUnit.Run; -with AUnit.Reporter.Text; - -with GNAT.OS_Lib; - -with Test_Cases; -with Test_Cases.Strings; -with Test_Cases.Strings.Vector; - -procedure Tests is - function Runner is new AUnit.Run.Test_Runner_With_Status (Test_Cases.Get_Suite); - - Reporter : AUnit.Reporter.Text.Text_Reporter; - -begin - Reporter.Set_Use_ANSI_Colors (True); - - if Runner (Reporter, - (Global_Timer => True, - Test_Case_Timer => True, - Report_Successes => True, - others => <>)) - /= AUnit.Success - then - GNAT.OS_Lib.OS_Exit (1); - end if; - - -end Tests; diff --git a/tests/tests.gpr b/tests/tests.gpr deleted file mode 100644 index 4d2c849..0000000 --- a/tests/tests.gpr +++ /dev/null @@ -1,81 +0,0 @@ -with "config/tests_config.gpr"; -project Tests is - - for Source_Dirs use ("src"); - for Object_Dir use "obj"; - for Create_Missing_Dirs use "True"; - for Exec_Dir use "bin"; - for Main use ("tests.adb"); - - type Enabled_Kind is ("enabled", "disabled"); - Compile_Checks : Enabled_Kind := External ("TESTS_COMPILE_CHECKS", "disabled"); - Runtime_Checks : Enabled_Kind := External ("TESTS_RUNTIME_CHECKS", "disabled"); - Style_Checks : Enabled_Kind := External ("TESTS_STYLE_CHECKS", "disabled"); - Contracts_Checks : Enabled_Kind := External ("TESTS_CONTRACTS", "disabled"); - - type Build_Kind is ("debug", "optimize"); - Build_Mode : Build_Kind := External ("TESTS_BUILD_MODE", "optimize"); - - Compile_Checks_Switches := (); - case Compile_Checks is - when "enabled" => - Compile_Checks_Switches := - ("-gnatwa", -- All warnings - "-gnatVa", -- All validity checks - "-gnatwe"); -- Warnings as errors - when others => null; - end case; - - Runtime_Checks_Switches := (); - case Runtime_Checks is - when "enabled" => null; - when others => - Runtime_Checks_Switches := - ("-gnatp"); -- Suppress checks - end case; - - Style_Checks_Switches := (); - case Style_Checks is - when "enabled" => - Style_Checks_Switches := - ("-gnatyg", -- GNAT Style checks - "-gnaty-d", -- Disable no DOS line terminators - "-gnatyM80", -- Maximum line length - "-gnatyO"); -- Overriding subprograms explicitly marked as such - when others => null; - end case; - - Contracts_Switches := (); - case Contracts_Checks is - when "enabled" => - Contracts_Switches := - ("-gnata"); -- Enable assertions and contracts - when others => null; - end case; - - Build_Switches := (); - case Build_Mode is - when "optimize" => - Build_Switches := ("-O3", -- Optimization - "-gnatn"); -- Enable inlining - when "debug" => - Build_Switches := ("-g", -- Debug info - "-Og"); -- No optimization - end case; - - package Compiler is - for Default_Switches ("Ada") use - Compile_Checks_Switches & - Build_Switches & - Runtime_Checks_Switches & - Style_Checks_Switches & - Contracts_Switches & - ("-gnatw.X", -- Disable warnings for No_Exception_Propagation - "-gnatQ"); -- Don't quit. Generate ALI and tree files even if illegalities - end Compiler; - - package Binder is - for Switches ("Ada") use ("-Es"); -- Symbolic traceback - end Binder; - -end Tests;