Skip to content

Commit

Permalink
adding first test (#99)
Browse files Browse the repository at this point in the history
* adding first test

* adding files

* adding files

* fixed test

* fixed first test
  • Loading branch information
edwardhartnett authored Mar 27, 2024
1 parent 66cbd68 commit e3faa1c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/developer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ jobs:
cd b
cmake ..
make VERBOSE=1
make test
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,9 @@ if(BUILD_LIB)
DESTINATION ${CONFIG_INSTALL_DESTINATION})
endif()

# Turn on unit testing.
include(CTest)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()

17 changes: 17 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This is the CMake file for the test directory in the wgrib2
# project.
#
# Ed Hartnett 3/27/24

# Run each shell test.
function(shell_test name)
# Copy the test scripts.
file(COPY "${CMAKE_SOURCE_DIR}/tests/${name}.sh"
DESTINATION ${CMAKE_BINARY_DIR}/tests
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
# Add the shell script as a test.
add_test(NAME ${name}.sh COMMAND bash ${name}.sh)
endfunction()

# Run these shell tests.
shell_test(run_wgrib2_tests)
16 changes: 16 additions & 0 deletions tests/run_wgrib2_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
# This is a test script for the wgrib2 project.
#
# Ed Hartnett, 3/27/24

set -e
echo ""
echo "*** Running wgrib2 test"

# Just run executable. For some reason it returns 8.
ls -l ../wgrib2
../wgrib2/wgrib2 > out.txt && exit 1
[ $? -ne 8 ] && exit 2

echo "*** SUCCESS!"
exit 0

0 comments on commit e3faa1c

Please sign in to comment.