Skip to content

Commit 625d785

Browse files
committed
Add testing workflow and adjust construction of error message
- also adjust tagline
1 parent 92ef1e9 commit 625d785

File tree

6 files changed

+230
-19
lines changed

6 files changed

+230
-19
lines changed

.github/workflows/build.yml

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
M_BUILD_DIR: _build_meson
7+
C_BUILD_DIR: _build_cmake
8+
PIP_PACKAGES: >-
9+
meson
10+
cmake
11+
ninja
12+
gcovr
13+
14+
jobs:
15+
gcc-build:
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: [ubuntu-latest, macos-latest]
21+
22+
env:
23+
FC: gfortran
24+
GCC_V: 9
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v2
29+
30+
- uses: actions/setup-python@v1
31+
with:
32+
python-version: '3.x'
33+
34+
- name: Install GCC (OSX)
35+
if: contains(matrix.os, 'macos')
36+
run: |
37+
ln -s /usr/local/bin/gfortran-${GCC_V} /usr/local/bin/gfortran
38+
which gfortran-${GCC_V}
39+
which gfortran
40+
41+
- name: Install GCC (Linux)
42+
if: contains(matrix.os, 'ubuntu')
43+
run: |
44+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \
45+
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
46+
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V}
47+
48+
- name: Install meson/cmake
49+
run: pip3 install ${{ env.PIP_PACKAGES }}
50+
51+
- name: Configure meson build
52+
run: >-
53+
meson setup ${{ env.M_BUILD_DIR }}
54+
--buildtype=debug
55+
--prefix=$PWD/_mdist
56+
--libdir=lib
57+
-Db_coverage=true
58+
59+
- name: Build project (meson)
60+
run: meson compile -C ${{ env.M_BUILD_DIR }}
61+
62+
- name: Run unit tests (meson)
63+
run: meson test -C ${{ env.M_BUILD_DIR }} --print-errorlogs --no-rebuild
64+
65+
- name: Install project (meson)
66+
run: meson install -C ${{ env.M_BUILD_DIR }} --no-rebuild
67+
68+
- name: Create coverage report (meson)
69+
run: ninja -C ${{ env.M_BUILD_DIR }} coverage
70+
71+
- name: Upload coverage report
72+
uses: codecov/codecov-action@v1
73+
74+
- name: Configure CMake build
75+
run: >-
76+
cmake
77+
-B ${{ env.C_BUILD_DIR }}
78+
-G Ninja
79+
-DCMAKE_INSTALL_PREFIX=$PWD/_cdist
80+
81+
- name: Build project (CMake)
82+
run: cmake --build ${{ env.C_BUILD_DIR }}
83+
84+
- name: Run unit tests (CTest)
85+
run: ctest
86+
working-directory: ${{ env.C_BUILD_DIR }}
87+
88+
- name: Install project (CMake)
89+
run: cmake --install ${{ env.C_BUILD_DIR }}
90+
91+
92+
# Test native MinGW Windows build
93+
mingw-build:
94+
runs-on: windows-latest
95+
strategy:
96+
fail-fast: false
97+
matrix:
98+
include: [
99+
{ msystem: MINGW64, arch: x86_64 },
100+
# { msystem: MINGW32, arch: i686 }
101+
]
102+
defaults:
103+
run:
104+
shell: msys2 {0}
105+
steps:
106+
- name: Checkout code
107+
uses: actions/checkout@v2
108+
109+
- name: Setup MSYS2 toolchain
110+
uses: msys2/setup-msys2@v2
111+
with:
112+
msystem: ${{ matrix.msystem }}
113+
update: false
114+
install: >-
115+
git
116+
mingw-w64-${{ matrix.arch }}-gcc-fortran
117+
mingw-w64-${{ matrix.arch }}-cmake
118+
mingw-w64-${{ matrix.arch }}-python
119+
mingw-w64-${{ matrix.arch }}-python-pip
120+
mingw-w64-${{ matrix.arch }}-ninja
121+
122+
- name: Install meson/cmake
123+
run: pip3 install meson==0.56.2
124+
125+
- name: Configure meson build
126+
run: meson setup ${{ env.M_BUILD_DIR }}
127+
env:
128+
FC: gfortran
129+
CC: gcc
130+
131+
- name: Build project (meson)
132+
run: meson compile -C ${{ env.M_BUILD_DIR }}
133+
134+
- name: Run unit tests (meson)
135+
run: meson test -C ${{ env.M_BUILD_DIR }} --print-errorlogs --no-rebuild
136+
env:
137+
OMP_NUM_THREADS: 2,1
138+
139+
- name: Configure cmake build
140+
run: cmake -B ${{ env.C_BUILD_DIR }} -G Ninja
141+
142+
- name: Build project (CMake)
143+
run: cmake --build ${{ env.C_BUILD_DIR }}
144+
145+
- name: Run unit tests (CTest)
146+
run: ctest
147+
working-directory: ${{ env.C_BUILD_DIR }}
148+
env:
149+
OMP_NUM_THREADS: 2,1
150+
151+
152+
intel-build:
153+
runs-on: ${{ matrix.os }}
154+
strategy:
155+
fail-fast: false
156+
matrix:
157+
os: [ubuntu-20.04]
158+
159+
env:
160+
FC: ifort
161+
OMP_NUM_THREADS: 2,1
162+
163+
steps:
164+
- name: Checkout code
165+
uses: actions/checkout@v2
166+
167+
- uses: actions/setup-python@v1
168+
with:
169+
python-version: '3.x'
170+
171+
- name: Add Intel repository
172+
run: |
173+
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
174+
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
175+
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
176+
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
177+
sudo apt-get update
178+
179+
- name: Install Intel oneAPI compiler
180+
run: |
181+
sudo apt-get install intel-oneapi-compiler-fortran
182+
source /opt/intel/oneapi/setvars.sh
183+
printenv >> $GITHUB_ENV
184+
185+
- name: Install meson/cmake
186+
run: pip3 install ${{ env.PIP_PACKAGES }}
187+
188+
- name: Configure meson build
189+
run: meson setup ${{ env.M_BUILD_DIR }}
190+
191+
- name: Build library (meson)
192+
run: meson compile -C ${{ env.M_BUILD_DIR }}
193+
194+
- name: Run unit tests (meson)
195+
run: meson test -C ${{ env.M_BUILD_DIR }} --print-errorlogs --no-rebuild
196+
197+
- name: Configure cmake build
198+
run: cmake -B ${{ env.C_BUILD_DIR }} -G Ninja
199+
200+
- name: Build library (CMake)
201+
run: cmake --build ${{ env.C_BUILD_DIR }}
202+
203+
- name: Run unit tests (CTest)
204+
run: ctest
205+
working-directory: ${{ env.C_BUILD_DIR }}

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ project(
2020
"test-drive"
2121
LANGUAGES "Fortran"
2222
VERSION "0.3.0"
23-
DESCRIPTION "The non-fancy testing framework"
23+
DESCRIPTION "The simple testing framework"
2424
)
2525

2626
# Follow GNU conventions for installing directories

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# The non-fancy testing framework
1+
# The simple testing framework
22

33
This project offers a lightweight, procedural unit testing framework
44
based on nothing but standard Fortran.

fpm.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ license = "Apache-2.0"
44
maintainer = ["@awvwgk"]
55
author = ["Sebastian Ehlert"]
66
copyright = "2020-2021 Sebastian Ehlert"
7-
description = "The non-fancy testing framework"
7+
description = "The simple testing framework"
88
keywords = ["testing-framework", "unit-testing"]

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if install
6666
pkg = import('pkgconfig')
6767
pkg.generate(
6868
testdrive_lib,
69-
description: 'The non-fancy testing framework',
69+
description: 'The simple testing framework',
7070
)
7171
endif
7272

src/testdrive.f90

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ end subroutine collect_interface
227227

228228
character(len=*), parameter :: fmt = '(1x, *(1x, a))'
229229
character(len=*), parameter :: indent = repeat(" ", 5) // repeat(".", 3)
230-
character(len=*), parameter :: skip = repeat(" ", 11)
231230

232231

233232
contains
@@ -526,13 +525,13 @@ subroutine check_float_dp(error, actual, expected, message, more, thr, rel)
526525
else
527526
if (relative) then
528527
call test_failed(error, &
529-
"Floating point value missmatch"//new_line("a")//skip//&
528+
"Floating point value missmatch", &
530529
"expected "//ch(expected)//" but got "//ch(actual)//" "//&
531530
"(difference: "//ch(int(diff*100))//"%)", &
532531
more)
533532
else
534533
call test_failed(error, &
535-
"Floating point value missmatch"//new_line("a")//skip//&
534+
"Floating point value missmatch", &
536535
"expected "//ch(expected)//" but got "//ch(actual)//" "//&
537536
"(difference: "//ch(diff)//")", &
538537
more)
@@ -593,13 +592,13 @@ subroutine check_float_sp(error, actual, expected, message, more, thr, rel)
593592
else
594593
if (relative) then
595594
call test_failed(error, &
596-
"Floating point value missmatch"//new_line("a")//skip//&
595+
"Floating point value missmatch", &
597596
"expected "//ch(expected)//" but got "//ch(actual)//" "//&
598597
"(difference: "//ch(int(diff*100))//"%)", &
599598
more)
600599
else
601600
call test_failed(error, &
602-
"Floating point value missmatch"//new_line("a")//skip//&
601+
"Floating point value missmatch", &
603602
"expected "//ch(expected)//" but got "//ch(actual)//" "//&
604603
"(difference: "//ch(diff)//")", &
605604
more)
@@ -632,7 +631,7 @@ subroutine check_int_i1(error, actual, expected, message, more)
632631
call test_failed(error, message, more)
633632
else
634633
call test_failed(error, &
635-
"Integer value missmatch"//new_line("a")//skip//&
634+
"Integer value missmatch", &
636635
"expected "//ch(expected)//" but got "//ch(actual), &
637636
more)
638637
end if
@@ -663,7 +662,7 @@ subroutine check_int_i2(error, actual, expected, message, more)
663662
call test_failed(error, message, more)
664663
else
665664
call test_failed(error, &
666-
"Integer value missmatch"//new_line("a")//skip//&
665+
"Integer value missmatch", &
667666
"expected "//ch(expected)//" but got "//ch(actual), &
668667
more)
669668
end if
@@ -694,7 +693,7 @@ subroutine check_int_i4(error, actual, expected, message, more)
694693
call test_failed(error, message, more)
695694
else
696695
call test_failed(error, &
697-
"Integer value missmatch"//new_line("a")//skip//&
696+
"Integer value missmatch", &
698697
"expected "//ch(expected)//" but got "//ch(actual), &
699698
more)
700699
end if
@@ -725,7 +724,7 @@ subroutine check_int_i8(error, actual, expected, message, more)
725724
call test_failed(error, message, more)
726725
else
727726
call test_failed(error, &
728-
"Integer value missmatch"//new_line("a")//skip//&
727+
"Integer value missmatch", &
729728
"expected "//ch(expected)//" but got "//ch(actual), &
730729
more)
731730
end if
@@ -756,7 +755,7 @@ subroutine check_bool(error, actual, expected, message, more)
756755
call test_failed(error, message, more)
757756
else
758757
call test_failed(error, &
759-
"Logical value missmatch"//new_line("a")//skip//&
758+
"Logical value missmatch", &
760759
"expected "//merge("T", "F", expected)//" but got "//merge("T", "F", actual), &
761760
more)
762761
end if
@@ -787,7 +786,7 @@ subroutine check_string(error, actual, expected, message, more)
787786
call test_failed(error, message, more)
788787
else
789788
call test_failed(error, &
790-
"Character value missmatch"//new_line("a")//skip//&
789+
"Character value missmatch", &
791790
"expected '"//expected//"' but got '"//actual//"'", &
792791
more)
793792
end if
@@ -796,7 +795,7 @@ subroutine check_string(error, actual, expected, message, more)
796795
end subroutine check_string
797796

798797

799-
subroutine test_failed(error, message, more)
798+
subroutine test_failed(error, message, more, and_more)
800799

801800
!> Error handling
802801
type(error_type), allocatable, intent(out) :: error
@@ -807,13 +806,20 @@ subroutine test_failed(error, message, more)
807806
!> Another line of error message
808807
character(len=*), intent(in), optional :: more
809808

809+
!> Another line of error message
810+
character(len=*), intent(in), optional :: and_more
811+
812+
character(len=*), parameter :: skip = new_line("a") // repeat(" ", 11)
813+
810814
allocate(error)
811815
error%stat = fatal
812816

817+
error%message = message
813818
if (present(more)) then
814-
error%message = message // new_line("a") // skip // more
815-
else
816-
error%message = message
819+
error%message = error%message // skip // more
820+
end if
821+
if (present(and_more)) then
822+
error%message = error%message // skip // and_more
817823
end if
818824

819825
end subroutine test_failed

0 commit comments

Comments
 (0)