summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfileAsOutput-check.cmake
blob: d4a87ba316b526bbbde400e842232d41c15e8ed1 (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
set(log "${RunCMake_BINARY_DIR}/CustomCommandDepfileAsOutput-build/CMakeFiles/impl-Debug.ninja")
file(READ "${log}" build_file)

set(RunCMake_TEST_FAILED)
if(NOT "${build_file}" MATCHES "depfile = test\\.d")
  string(CONCAT no_test_d "Log file:\n ${log}\n" "does not have expected line: depfile = test.d")
  list(APPEND RunCMake_TEST_FAILED "${no_test_d}")
endif()
if(NOT "${build_file}" MATCHES "depfile = test_Debug\\.d")
  string(CONCAT no_test_Debug_d "\nLog file:\n ${log}\n" "does not have expected line: depfile = test_Debug.d")
  list(APPEND RunCMake_TEST_FAILED "${no_test_Debug_d}")
endif()

function(_run_ninja dir)
  execute_process(
    COMMAND "${RunCMake_MAKE_PROGRAM}" ${ARGN}
    WORKING_DIRECTORY "${dir}"
    OUTPUT_VARIABLE ninja_stdout
    ERROR_VARIABLE ninja_stderr
    RESULT_VARIABLE ninja_result
    )
  if(NOT ninja_result EQUAL 0)
    message(STATUS "
============ beginning of ninja's stdout ============
${ninja_stdout}
=============== end of ninja's stdout ===============
")
    message(STATUS "
============ beginning of ninja's stderr ============
${ninja_stderr}
=============== end of ninja's stderr ===============
")
    message(FATAL_ERROR
      "top ninja build failed exited with status ${ninja_result}")
  endif()
  set(ninja_stdout "${ninja_stdout}" PARENT_SCOPE)
endfunction()

_run_ninja("${RunCMake_BINARY_DIR}/CustomCommandDepfileAsOutput-build")
_run_ninja("${RunCMake_BINARY_DIR}/CustomCommandDepfileAsOutput-build" -t deps main.copy.c)
if (NOT ninja_stdout MATCHES "deps not found")
  list(APPEND RunCMake_TEST_FAILED "Ninja tracked the deps of main.copy.c in the database")
endif ()
_run_ninja("${RunCMake_BINARY_DIR}/CustomCommandDepfileAsOutput-build" -t deps main.copy2.c)
if (NOT ninja_stdout MATCHES "deps not found")
  list(APPEND RunCMake_TEST_FAILED "Ninja tracked the deps of main.copy2.c in the database")
endif ()