[osmium-tool] 29/44: Extend test helper functions to allow two commands to be called.

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Tue Jul 21 20:15:56 UTC 2015


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to tag v1.1.0
in repository osmium-tool.

commit 8e63cb6e0b9e216632393544046ad9fa213be7bb
Author: Jochen Topf <jochen at topf.org>
Date:   Thu Jul 2 18:40:20 2015 +0200

    Extend test helper functions to allow two commands to be called.
---
 cmake/run_test_compare_output.cmake | 24 +++++++++++++++++++++++-
 test/CMakeLists.txt                 | 14 ++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/cmake/run_test_compare_output.cmake b/cmake/run_test_compare_output.cmake
index 2f1f8ff..d251c35 100644
--- a/cmake/run_test_compare_output.cmake
+++ b/cmake/run_test_compare_output.cmake
@@ -17,6 +17,7 @@ if(NOT reference)
     message(FATAL_ERROR "Variable 'reference' not defined")
 endif()
 
+message("Executing: ${cmd}")
 separate_arguments(cmd)
 
 execute_process(
@@ -32,7 +33,28 @@ if(result)
 endif()
 
 if(NOT (stderr STREQUAL ""))
-    message(SEND_ERROR "Command tested wrote to stderr: ${_stderr}")
+    message(SEND_ERROR "Command tested wrote to stderr: ${stderr}")
+endif()
+
+if(cmd2)
+    message("Executing: ${cmd2}")
+    separate_arguments(cmd2)
+
+    execute_process(
+        COMMAND ${cmd2}
+        WORKING_DIRECTORY ${dir}
+        RESULT_VARIABLE result
+        OUTPUT_VARIABLE stdout
+        ERROR_VARIABLE stderr
+    )
+
+    if(result)
+        message(SEND_ERROR "Error when calling '${cmd}': ${result}")
+    endif()
+
+    if(NOT (stderr STREQUAL ""))
+        message(SEND_ERROR "Command tested wrote to stderr: ${stderr}")
+    endif()
 endif()
 
 file(READ ${dir}/${reference} ref)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index ce34004..1c3b531 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -29,6 +29,20 @@ function(check_output _name _command _output)
     )
 endfunction()
 
+function(check_output2 _name _command1 _command2 _output)
+    set(_cmd1 "${PROJECT_BINARY_DIR}/src/osmium ${_command1}")
+    set(_cmd2 "${PROJECT_BINARY_DIR}/src/osmium ${_command2}")
+    add_test(
+        NAME ${_name}
+        COMMAND ${CMAKE_COMMAND}
+        -Dcmd=${_cmd1}
+        -Dcmd2=${_cmd2}
+        -Ddir=${PROJECT_SOURCE_DIR}/test
+        -Dreference=${_output}
+        -P ${CMAKE_SOURCE_DIR}/cmake/run_test_compare_output.cmake
+    )
+endfunction()
+
 #-----------------------------------------------------------------------------
 
 add_subdirectory(cat)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/osmium-tool.git



More information about the Pkg-grass-devel mailing list