-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
TEST_REQUIRES
keyword in ecbuild_add_test
- Loading branch information
1 parent
83b5038
commit 8ef56c6
Showing
8 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
ecbuild_add_test( | ||
TARGET test_ecbuild_test_requires_complex | ||
TYPE SCRIPT | ||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build-and-run.sh | ||
ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} | ||
SOURCE=${CMAKE_CURRENT_SOURCE_DIR:-$HERE} | ||
|
||
# Add ecbuild to path | ||
export PATH=$SOURCE/../../bin:$PATH | ||
echo $PATH | ||
echo $SOURCE | ||
|
||
# Build the project | ||
ecbuild $SOURCE/test_project -B $HERE/build | ||
|
||
# Run only one specific test (which should invoke the dependency) | ||
(cd $HERE/build; ctest -R write_world) # Avoid using --test-dir option in ctest | ||
|
||
# Check if the output is as expected | ||
echo -n "World!" | diff - $HERE/build/world.txt | ||
|
||
# Run only one specific test (which should invoke the dependencies) | ||
(cd $HERE/build; ctest -R combine_hello_world) # Avoid using --test-dir option in ctest | ||
|
||
# Check if the output is as expected | ||
echo -n "Hello, World!" | diff - $HERE/build/helloworld.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
cmake_minimum_required(VERSION 3.7 FATAL_ERROR) | ||
|
||
find_package( ecbuild REQUIRED ) | ||
project( test_test_requires_complex VERSION 0.1.0 LANGUAGES NONE ) | ||
|
||
ecbuild_add_test( | ||
TARGET clean_output | ||
COMMAND ${CMAKE_COMMAND} | ||
ARGS -E remove ${CMAKE_CURRENT_BINARY_DIR}/hello.txt ${CMAKE_CURRENT_BINARY_DIR}/world.txt ${CMAKE_CURRENT_BINARY_DIR}/helloworld.txt | ||
) | ||
|
||
ecbuild_add_test( | ||
TARGET write_hello | ||
TEST_REQUIRES clean_output | ||
COMMAND bash | ||
ARGS -c "echo -n 'Hello, ' >> ${CMAKE_CURRENT_BINARY_DIR}/hello.txt" | ||
) | ||
|
||
ecbuild_add_test( | ||
TARGET write_world | ||
TEST_REQUIRES clean_output | ||
COMMAND bash | ||
ARGS -c "echo -n 'World!' >> ${CMAKE_CURRENT_BINARY_DIR}/world.txt" | ||
) | ||
|
||
ecbuild_add_test( | ||
TARGET combine_hello_world | ||
TEST_REQUIRES write_hello write_world | ||
COMMAND bash | ||
ARGS -c "cat ${CMAKE_CURRENT_BINARY_DIR}/hello.txt ${CMAKE_CURRENT_BINARY_DIR}/world.txt >> ${CMAKE_CURRENT_BINARY_DIR}/helloworld.txt" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
ecbuild_add_test( | ||
TARGET test_ecbuild_test_requires_simple | ||
TYPE SCRIPT | ||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build-and-run.sh | ||
ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} | ||
SOURCE=${CMAKE_CURRENT_SOURCE_DIR:-$HERE} | ||
|
||
# Add ecbuild to path | ||
export PATH=$SOURCE/../../bin:$PATH | ||
echo $PATH | ||
echo $SOURCE | ||
|
||
# Build the project | ||
ecbuild $SOURCE/test_project -B $HERE/build | ||
|
||
# Run only one specific test (which should invoke the dependencies) | ||
(cd $HERE/build; ctest -R write_world_after_hello) # Avoid using --test-dir option in ctest | ||
|
||
# Check if the output is as expected | ||
echo -n "Hello, World!" | diff - $HERE/build/output.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
cmake_minimum_required(VERSION 3.7 FATAL_ERROR) | ||
|
||
find_package( ecbuild REQUIRED ) | ||
project( test_test_requires_simple VERSION 0.1.0 LANGUAGES NONE ) | ||
|
||
ecbuild_add_test( | ||
TARGET clean_output | ||
COMMAND ${CMAKE_COMMAND} | ||
ARGS -E remove ${CMAKE_CURRENT_BINARY_DIR}/output.txt | ||
) | ||
|
||
ecbuild_add_test( | ||
TARGET write_hello | ||
TEST_REQUIRES clean_output | ||
COMMAND bash | ||
ARGS -c "echo -n 'Hello, ' >> ${CMAKE_CURRENT_BINARY_DIR}/output.txt" | ||
) | ||
|
||
ecbuild_add_test( | ||
TARGET write_world_after_hello | ||
TEST_REQUIRES write_hello | ||
COMMAND bash | ||
ARGS -c "echo -n 'World!' >> ${CMAKE_CURRENT_BINARY_DIR}/output.txt" | ||
) |