summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/ctest_fixtures/CMakeLists.txt.in
blob: ba1c77afbb70f273adc8a426670c51288e5516c8 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
cmake_minimum_required (VERSION 3.6.2)
project(ctest_fixtures LANGUAGES NONE)
include(CTest)

macro(passTest testName)
  set(someFile "${CMAKE_CURRENT_SOURCE_DIR}/test.cmake")
  add_test(NAME ${testName}
           COMMAND ${CMAKE_COMMAND} -E compare_files "${someFile}" "${someFile}")
endmacro()

macro(failTest testName)
  set(someFile "${CMAKE_CURRENT_SOURCE_DIR}/test.cmake")
  add_test(NAME ${testName}
           COMMAND ${CMAKE_COMMAND} -E compare_files "${someFile}" "${someFile}xxx")
endmacro()

# Intersperse actual tests among setup/cleanup tests so that we don't
# define them in the same order as they need to be executed. Numbers
# at the end of each line correspond to the test numbers ctest will
# use for each test.
passTest(one)           # 1
passTest(setupBoth)     # 2
passTest(setupFoo)      # 3
passTest(setupMeta)     # 4
passTest(cleanupFoo)    # 5
passTest(two)           # 6
passTest(cleanupBar)    # 7
passTest(three)         # 8
failTest(setupFails)    # 9
passTest(wontRun)       # 10
passTest(cyclicSetup)   # 11
passTest(cyclicCleanup) # 12

# Define fixture dependencies and ordering
set_tests_properties(setupFoo   PROPERTIES FIXTURES_SETUP    "Foo")
set_tests_properties(cleanupFoo PROPERTIES FIXTURES_CLEANUP  "Foo")

set_tests_properties(setupBoth  PROPERTIES FIXTURES_SETUP    "Foo;Bar")
set_tests_properties(cleanupBar PROPERTIES FIXTURES_CLEANUP  "Bar")

set_tests_properties(setupMeta  PROPERTIES FIXTURES_SETUP    "Meta"
                                           FIXTURES_REQUIRED "Foo;Bar")

set_tests_properties(setupBoth  PROPERTIES DEPENDS           setupFoo)

set_tests_properties(setupFails PROPERTIES FIXTURES_SETUP    "Fails")

set_tests_properties(one        PROPERTIES FIXTURES_REQUIRED "Other;Foo")
set_tests_properties(two        PROPERTIES FIXTURES_REQUIRED "Bar")
set_tests_properties(three      PROPERTIES FIXTURES_REQUIRED "Meta;Bar")
set_tests_properties(wontRun    PROPERTIES FIXTURES_REQUIRED "Fails")

@CASE_CMAKELISTS_CYCLIC_CODE@

# These are the cases verified by the main cmake build
#
#   Regex:         Test case list (in order)
#    one            3, 2, 1, 5
#    two            2, 6, 7
#    three          3, 2, 4, 5, 8, 7
#    setupFoo       3
#    wontRun        9, 10
#    cyclicSetup    -NA- (configure fails)
#    cyclicCleanup  -NA- (configure fails)
#
# In the case of asking for just setupFoo, since there are
# no tests using the Foo fixture, we do NOT expect cleanupFoo
# to be executed. It is important not to pull in cleanupFoo
# if setupFoo is explicitly requested and no other test requires
# the Foo fixture, otherwise it would not be possible to run
# just a setup or cleanup test in isolation (likely to be
# needed during initial creation of such test cases).
#
# For the wontRun case, test 9 fails and test 10 should not run.
# The result of the set of tests should be failure, which is
# verified by the main cmake build's tests.
#
# For the two cyclic test cases invoked by the main cmake build,
# FIXTURES_... properties are added to the relevant test at the
# location marked with CASE_CMAKELISTS_CYCLIC_CODE. This creates
# a self-dependency which causes the configure step to fail.