summaryrefslogtreecommitdiffstats
path: root/Tests/FindRuby/CMakeLists.txt
blob: ee589234de645c9f806d696be4fdedd1c5430947 (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
if(CMake_TEST_FindRuby)

  # Looks for ruby >=1.9.9, which is true on any Ubuntu (that installs it) or macOS (> 10.9)
  add_test(NAME FindRuby.Test COMMAND
    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/FindRuby/Test"
    "${CMake_BINARY_DIR}/Tests/FindRuby/Test"
    ${build_generator_args}
    --build-project TestRuby
    --build-options ${build_options}
    --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
    )

  # Looks for ruby >= 50.1.0, which should logically fail
  add_test(NAME FindRuby.Fail COMMAND
    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/FindRuby/Fail"
    "${CMake_BINARY_DIR}/Tests/FindRuby/Fail"
    ${build_generator_args}
    --build-project TestRubyFail
    --build-options ${build_options}
    --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
    )
  set_tests_properties(FindRuby.Fail PROPERTIES
    PASS_REGULAR_EXPRESSION "Could NOT find Ruby.*(Required[ \n]+is[ \n]+at[ \n]+least[ \n]+version[ \n]*\"[0-9]+\\.[0-9]+\\.[0-9]+\")")

  # Looks for 1.9.9 EXACTLY, which unlike the "FindRuby" test above will fail on every machine
  # since this version doesn't exist (ruby goes from 1.9.3 to 2.0.0)
  add_test(NAME FindRuby.FailExact COMMAND
    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/FindRuby/FailExact"
    "${CMake_BINARY_DIR}/Tests/FindRuby/FailExact"
    ${build_generator_args}
    --build-project TestRubyFailExact
    --build-options ${build_options}
    --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
    )
  set_tests_properties(FindRuby.FailExact PROPERTIES
    PASS_REGULAR_EXPRESSION "Could NOT find Ruby: Found unsuitable version \".*\", but required is.*exact version \"[0-9]+\\.[0-9]+\\.[0-9]+\" \\(found .*\\)")

  # RVM specific test
  if(CMake_TEST_FindRuby_RVM)
    add_test(NAME FindRuby.Rvm COMMAND
      ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
      --build-and-test
      "${CMake_SOURCE_DIR}/Tests/FindRuby/Rvm"
      "${CMake_BINARY_DIR}/Tests/FindRuby/Rvm"
      ${build_generator_args}
      --build-project TestRVM
      --build-options ${build_options}
      --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
      )
  endif()
endif()