Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,14 @@ jobs:
fail-fast: false
matrix:
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-24.04-arm
gnat: # latest
- os: ubuntu-latest
gnat: 12
# Waiting for indexed compiler
# - os: ubuntu-24.04-arm
# gnat: 14
gnat: # latest
- os: macos-latest
gnat: # latest
- os: windows-latest
gnat: 11
gnat: # latest

runs-on: ${{ matrix.combo.os }}

Expand All @@ -47,10 +42,10 @@ jobs:
uses: actions/checkout@v2

- name: Set up Alire and toolchain
uses: alire-project/setup-alire@v4
uses: alire-project/setup-alire@v6
with:
version: nightly # for [test]
toolchain: gnat_native^${{ matrix.combo.gnat }} gprbuild
toolchain: gnat_native${{ matrix.combo.gnat }} gprbuild

- name: Build
if: ${{inputs.build}}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/build_aaa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
uses: ./.github/workflows/build.yml
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/build_aaa_texts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
uses: ./.github/workflows/build.yml
Expand Down
5 changes: 0 additions & 5 deletions aaa_base/alire.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,5 @@ maintainers-logins = ["mosteo"]
tags = ["miscellanea", "utility"]
website = "https://github.com/mosteo/aaa"

[[actions]]
type = "test"
directory = "tests"
command = ["alr", "build"]

[test]
runner = "alire"
2 changes: 1 addition & 1 deletion aaa_base/config/aaa_config.ads
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package Aaa_Config is

Alire_Host_Arch : constant String := "x86_64";

Alire_Host_Distro : constant String := "ubuntu";
Alire_Host_Distro : constant String := "suse";

type Build_Profile_Kind is (release, validation, development);
Build_Profile : constant Build_Profile_Kind := validation;
Expand Down
25 changes: 1 addition & 24 deletions aaa_base/config/aaa_config.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ abstract project Aaa_Config is

Alire_Host_Arch := "x86_64";

Alire_Host_Distro := "ubuntu";
Alire_Host_Distro := "suse";
Ada_Compiler_Switches := External_As_List ("ADAFLAGS", " ");
Ada_Compiler_Switches := Ada_Compiler_Switches &
(
Expand All @@ -22,29 +22,6 @@ abstract project Aaa_Config is
,"-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
);

Expand Down
2 changes: 1 addition & 1 deletion aaa_base/config/aaa_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#define ALIRE_HOST_ARCH "x86_64"

#define ALIRE_HOST_DISTRO "ubuntu"
#define ALIRE_HOST_DISTRO "suse"

#define BUILD_PROFILE_RELEASE 1
#define BUILD_PROFILE_VALIDATION 2
Expand Down
41 changes: 27 additions & 14 deletions aaa_base/src/aaa-strings.adb
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,37 @@ package body AAA.Strings is
Separator : String := " ")
return String
is
Length : Natural := 0;
Pos : Positive := 1;
begin
-- Compute result length

function Flatten (Pos : Positive; V : Vector) return String;

-------------
-- Flatten --
-------------
for Line of V loop
Length := Length + Line'Length;
end loop;

function Flatten (Pos : Positive; V : Vector) return String is
(if Pos = V.Count
then V (Pos)
else V (Pos) & Separator & Flatten (Pos + 1, V));
-- Add length of separators

begin
if V.Is_Empty then
return "";
else
return Flatten (1, V);
if not V.Is_Empty then
Length := Length + (V.Count - 1) * Separator'Length;
end if;

-- Length might be zero if V is empty

return S : string (1 .. Length) do
for Line of V loop
S (Pos .. Pos + Line'Length - 1) := Line;
Pos := Pos + Line'Length;

if Pos + Separator'Length - 1 <= Length then
S (Pos .. Pos + Separator'Length - 1) := Separator;
Pos := Pos + Separator'Length;
end if;
end loop;

pragma Assert (Pos - 1 = Length,
"Erroneous length computation in Flatten");
end return;
end Flatten;

-------------
Expand Down
2 changes: 2 additions & 0 deletions aaa_base/tests/common/aaa_tests.ads
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pragma Ignore_Pragma (Alire_Test);

package Aaa_Tests is

procedure Assert (Cond : Boolean; Text : String);
Expand Down
2 changes: 1 addition & 1 deletion aaa_base/tests/config/aaa_tests_config.ads
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package Aaa_Tests_Config is

Alire_Host_Arch : constant String := "x86_64";

Alire_Host_Distro : constant String := "ubuntu";
Alire_Host_Distro : constant String := "suse";

type Build_Profile_Kind is (release, validation, development);
Build_Profile : constant Build_Profile_Kind := validation;
Expand Down
25 changes: 1 addition & 24 deletions aaa_base/tests/config/aaa_tests_config.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ abstract project Aaa_Tests_Config is

Alire_Host_Arch := "x86_64";

Alire_Host_Distro := "ubuntu";
Alire_Host_Distro := "suse";
Ada_Compiler_Switches := External_As_List ("ADAFLAGS", " ");
Ada_Compiler_Switches := Ada_Compiler_Switches &
(
Expand All @@ -23,29 +23,6 @@ abstract project Aaa_Tests_Config is
,"-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
);

Expand Down
2 changes: 1 addition & 1 deletion aaa_base/tests/config/aaa_tests_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#define ALIRE_HOST_ARCH "x86_64"

#define ALIRE_HOST_DISTRO "ubuntu"
#define ALIRE_HOST_DISTRO "suse"

#define BUILD_PROFILE_RELEASE 1
#define BUILD_PROFILE_VALIDATION 2
Expand Down
1 change: 1 addition & 0 deletions aaa_base/tests/config/aaa_tests_list_config.gpr
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
abstract project Aaa_Tests_List_Config is
Test_Files := (
"aaa_tests-strings-check_vector_equality.adb"
,"aaa_tests-strings-flatten.adb"
,"aaa_tests-strings-vector_diffs.adb"
);
end Aaa_Tests_List_Config;
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
pragma Style_Checks ("-gnatM120");

pragma Alire_Test (Should_Fail, False);

with AAA.Strings; use AAA.Strings;

procedure Aaa_Tests.Strings.Check_Vector_Equality is
Expand Down
87 changes: 87 additions & 0 deletions aaa_base/tests/src/aaa_tests-strings-flatten.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
with AAA.Strings; use AAA.Strings;

pragma Alire_Test (Should_Fail, False);

pragma Style_Checks ("-gnatM120");

procedure Aaa_Tests.Strings.Flatten is

procedure Check (V : AAA.Strings.Vector;
Expected : String;
Sep : String := " ")
is
Result : constant String := V.Flatten (Sep);
begin
Assert (Result = Expected,
"Flatten (Sep => """ & Sep & """): expected """ &
Expected & """ but got """ & Result & """");
end Check;

procedure Check (V : AAA.Strings.Vector;
Expected : String;
Sep : Character)
is
Result : constant String := V.Flatten (Sep);
begin
Assert (Result = Expected,
"Flatten (Sep => '" & Sep & "'): expected """ &
Expected & """ but got """ & Result & """");
end Check;

One : constant AAA.Strings.Vector := Empty_Vector.Append ("A");
Three : constant AAA.Strings.Vector :=
Empty_Vector.Append ("A").Append ("B").Append ("C");

begin

-- Empty vector: default separator

Check (Empty_Vector, "");

-- Empty vector: explicit multi-char separator

Check (Empty_Vector, "", Sep => ", ");

-- Empty vector: character separator

Check (Empty_Vector, "", Sep => ASCII.LF);

-- Single element: separator is never inserted

Check (One, "A");
Check (One, "A", Sep => ", ");
Check (One, "A", Sep => ASCII.LF);

-- Several elements: default separator (single space)

Check (Three, "A B C");

-- Several elements: explicit multi-char string separator

Check (Three, "A, B, C", Sep => ", ");

-- Several elements: empty separator simply concatenates

Check (Three, "ABC", Sep => "");

-- Several elements: character separator

Check (Three, "A" & ASCII.LF & "B" & ASCII.LF & "C", Sep => ASCII.LF);

-- Elements that are themselves empty strings

Check (Empty_Vector.Append ("").Append ("").Append (""),
" ", -- two single-space separators, no other content
Sep => " ");

Check (Empty_Vector.Append ("A").Append ("").Append ("B"),
"A--B",
Sep => "-");

-- Elements containing the separator itself are not treated specially

Check (Empty_Vector.Append ("A,B").Append ("C"),
"A,B,C",
Sep => ",");

end Aaa_Tests.Strings.Flatten;
2 changes: 2 additions & 0 deletions aaa_base/tests/src/aaa_tests-strings-vector_diffs.adb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
with AAA.Strings; use AAA.Strings;

pragma Alire_Test (Should_Fail, False);

pragma Style_Checks ("-gnatM120");

procedure Aaa_Tests.Strings.Vector_Diffs is
Expand Down
4 changes: 2 additions & 2 deletions aaa_texts/alire.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ ansiada = "^1.1.0"
lml = "~0.1.0"
umwi = "~0.1.0"

[test]
runner = "alire"
# [test]
# runner = "alire"
Loading