Skip to content

Commit

Permalink
add ctest
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Apr 1, 2020
1 parent 8361fcd commit 4fd5032
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 58 deletions.
37 changes: 5 additions & 32 deletions .github/workflows/ci_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,24 @@ on:
- "**.txt"
- ".github/workflows/ci_cmake.yml"
pull_request:
release:

jobs:

linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.7
- run: |
pip install cmake
sudo apt -yq update
sudo apt install -yq --no-install-recommends gfortran
- run: cmake -B build
env:
FC: gfortran

- run: cmake --build build --parallel
- uses: actions/upload-artifact@v1
if: failure()
with:
name: Linux_CMake_Testlog
path: build/CMakeFiles/CMakeError.log
- run: ctest -S setup.cmake -VV
env:
FC: gfortran-9

- run: ctest -V
working-directory: build

windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2

- run: cmake -B build -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND"
env:
FC: gfortran

- run: cmake --build build
- uses: actions/upload-artifact@v1
if: failure()
with:
name: Windows_CMake_Testlog
path: build/CMakeFiles/CMakeError.log
- run: cinst -y ninja

- run: ctest -V
working-directory: build
- run: ctest -S setup.cmake -VV
17 changes: 7 additions & 10 deletions .github/workflows/ci_meson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
- "**.build"
- ".github/workflows/ci_meson.yml"
pull_request:
release:

jobs:

Expand All @@ -18,15 +17,13 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.7
- run: |
pip install meson
sudo apt -yq update
sudo apt install -yq --no-install-recommends ninja-build gfortran
python-version: '3.x'

- run: pip install meson ninja

- run: meson setup build
env:
FC: gfortran
FC: gfortran-9

- run: meson test -C build -v
- uses: actions/upload-artifact@v1
Expand All @@ -41,9 +38,9 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.7
python-version: '3.x'
- run: |
brew install gcc ninja
brew install ninja
pip install meson
- run: meson setup build
Expand All @@ -63,7 +60,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.7
python-version: '3.8'

- run: |
cinst -y ninja
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
project(RPNcalc
LANGUAGES Fortran
VERSION 1.2.0
VERSION 1.2.1
HOMEPAGE_URL https://github.com/scivision/rpn-calc-fortran)
enable_testing()

Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,28 @@ Default size is 4.

## Build

Use Meson or CMake.
Do NOT use sudo.
### CMake

### Meson
One-step CMake build and test:

```sh
meson build

meson test -C build
ctest -S setup.cmake -VV
```

### CMake
OR manually:

```sh
cmake -B build

cmake --build build --parallel
```

cd build
### Meson

```sh
meson build

ctest -V
meson test -C build
```

## Usage
Expand Down Expand Up @@ -161,15 +162,14 @@ Other display modes:

ALL ALL digits display mode


### Common Functions

+ Addition
- Subtraction
* Multiplication
/ Division
^ Exponentiation
\ Reciprocal
RECIP Reciprocal


2X 2^x
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project('RPNcalc', 'fortran',
default_options : ['default_library=static', 'warning_level=1', 'buildtype=release'],
meson_version: '>=0.51',
version: '1.2.0')
version: '1.2.1')

fc = meson.get_compiler('fortran')
if fc.get_id() == 'gcc'
Expand Down
66 changes: 66 additions & 0 deletions setup.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# run by:
# ctest -S setup.cmake

# --- Project-specific -Doptions
# these will be used if the project isn't already configured.

# --- boilerplate follows
# site is OS name
if(NOT DEFINED CTEST_SITE)
set(CTEST_SITE ${CMAKE_SYSTEM_NAME})
endif()

# if compiler specified, deduce its ID
if(DEFINED ENV{FC})
set(FC $ENV{FC})
endif()
if(DEFINED CMAKE_Fortran_COMPILER)
set(FC ${CMAKE_Fortran_COMPILER})
endif()
if(DEFINED FC)
foreach(c gfortran ifort flang pgfortran nagfor xlf ftn)
string(FIND ${FC} ${c} i)
if(i GREATER_EQUAL 0)
if(c STREQUAL gfortran)
execute_process(COMMAND gfortran -dumpversion
RESULT_VARIABLE _ret
OUTPUT_VARIABLE _vers OUTPUT_STRIP_TRAILING_WHITESPACE)
if(_ret EQUAL 0)
string(APPEND c "-${_vers}")
endif()
endif()
set(CTEST_BUILD_NAME ${c})
break()
endif()
endforeach()
endif()

if(NOT DEFINED CTEST_BUILD_CONFIGURATION)
set(CTEST_BUILD_CONFIGURATION "Release")
endif()

set(CTEST_SOURCE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
if(NOT DEFINED CTEST_BINARY_DIRECTORY)
set(CTEST_BINARY_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/build)
endif()

if(NOT DEFINED CTEST_CMAKE_GENERATOR)
find_program(_gen NAMES ninja ninja-build samu)
if(_gen)
set(CTEST_CMAKE_GENERATOR "Ninja")
elseif(WIN32)
set(CTEST_CMAKE_GENERATOR "MinGW Makefiles")
set(CTEST_BUILD_FLAGS -j)
else()
set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
set(CTEST_BUILD_FLAGS -j)
endif()
endif()

ctest_start("Experimental" ${CTEST_SOURCE_DIRECTORY} ${CTEST_BINARY_DIRECTORY})
if(NOT EXISTS ${CTEST_BINARY_DIRECTORY}/CMakeCache.txt)
ctest_configure(BUILD ${CTEST_BINARY_DIRECTORY} SOURCE ${CTEST_SOURCE_DIRECTORY} OPTIONS "${_opts}")
endif()
ctest_build(BUILD ${CTEST_BINARY_DIRECTORY} CONFIGURATION ${CTEST_BUILD_CONFIGURATION})
ctest_test(BUILD ${CTEST_BINARY_DIRECTORY})
# ctest_submit()
6 changes: 3 additions & 3 deletions src/eval.f90
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ recursive SUBROUTINE EVAL (STR)

IF (LEN_TRIM(STR) == 0) return

select case(str)
parse_cmd: select case(str)

case('HELP')
call eval('VER')
Expand All @@ -88,7 +88,7 @@ recursive SUBROUTINE EVAL (STR)
call divide(domain_mode)
case('^') ! ^
call power(domain_mode)
case(achar(92)) ! for PGI/Flang !('\') ! \
case('RECIP')
SELECT CASE (DOMAIN_MODE)
CASE (1)
IF (isclose(stack(1), 0._wp)) THEN
Expand Down Expand Up @@ -3784,7 +3784,7 @@ recursive SUBROUTINE EVAL (STR)

case default
call regops(str)
END select
end select parse_cmd

END SUBROUTINE EVAL

Expand Down

0 comments on commit 4fd5032

Please sign in to comment.