File: test_program_output.cmake

package info (click to toggle)
fiat-ecmwf 1.6.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,672 kB
  • sloc: f90: 19,885; ansic: 12,076; perl: 480; sh: 309; fortran: 289; makefile: 41; cpp: 36
file content (33 lines) | stat: -rw-r--r-- 1,186 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# (C) Copyright 2019 ECMWF.
#
# This file is covered by the LICENSING file in the root of this project.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.

function( run_command COMMAND )
  set( COMMAND ${ARGV} )
  string(REPLACE ";" " " PRINT_COMMAND "${COMMAND}" )
  message( "${PRINT_COMMAND}" )
  execute_process(
      COMMAND ${COMMAND}
      RESULT_VARIABLE res
      OUTPUT_VARIABLE stdout
      ERROR_VARIABLE  stderr
  )
  message("${stdout}")
  message("${stderr}")

  string(REGEX MATCH "${PASS_REGULAR_EXPRESSION}" stdout_match "${stdout}" )
  string(REGEX MATCH "${PASS_REGULAR_EXPRESSION}" stderr_match "${stderr}" )

  if( stdout_match OR stderr_match )
    message( "Test succeeded: Regex [${PASS_REGULAR_EXPRESSION}] was found in program output")
  else()
    message( FATAL_ERROR "Test failed: Could not find regex [${PASS_REGULAR_EXPRESSION}] in program output")
  endif()
endfunction()

message( "Running test ${EXECUTABLE} ... ")
run_command( ${LAUNCH} ${EXECUTABLE} )
message( "Running test ${EXECUTABLE} ... done")