~ubuntu-branches/ubuntu/trusty/mysql-5.6/trusty

« back to all changes in this revision

Viewing changes to mysql-test/CMakeLists.txt

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-12 11:54:27 UTC
  • Revision ID: package-import@ubuntu.com-20140212115427-oq6tfsqxl1wuwehi
Tags: upstream-5.6.15
ImportĀ upstreamĀ versionĀ 5.6.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
 
2
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; version 2 of the License.
 
6
 
7
# This program is distributed in the hope that it will be useful,
 
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
# GNU General Public License for more details.
 
11
 
12
# You should have received a copy of the GNU General Public License
 
13
# along with this program; if not, write to the Free Software
 
14
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
15
 
 
16
IF(INSTALL_MYSQLTESTDIR)
 
17
INSTALL(
 
18
  DIRECTORY .
 
19
  DESTINATION ${INSTALL_MYSQLTESTDIR}
 
20
  USE_SOURCE_PERMISSIONS
 
21
  COMPONENT Test
 
22
  PATTERN "var/" EXCLUDE
 
23
  PATTERN "lib/My/SafeProcess" EXCLUDE
 
24
  PATTERN "lib/t*" EXCLUDE
 
25
  PATTERN "CPack" EXCLUDE
 
26
  PATTERN "CMake*" EXCLUDE
 
27
  PATTERN "mtr.out*" EXCLUDE
 
28
  PATTERN ".cvsignore" EXCLUDE
 
29
  PATTERN "*.am" EXCLUDE
 
30
  PATTERN "*.in" EXCLUDE
 
31
)
 
32
ENDIF()
 
33
 
 
34
 
 
35
 
 
36
IF(NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
 
37
  # Enable running mtr from build directory
 
38
  CONFIGURE_FILE(
 
39
    ${CMAKE_CURRENT_SOURCE_DIR}/mtr.out-of-source 
 
40
    ${CMAKE_CURRENT_BINARY_DIR}/mysql-test-run.pl
 
41
    @ONLY
 
42
  )
 
43
ENDIF()
 
44
IF(UNIX)
 
45
  EXECUTE_PROCESS(
 
46
    COMMAND chmod +x  mysql-test-run.pl
 
47
    COMMAND ${CMAKE_COMMAND} -E create_symlink 
 
48
     ./mysql-test-run.pl mtr
 
49
    COMMAND ${CMAKE_COMMAND} -E create_symlink 
 
50
     ./mysql-test-run.pl mysql-test-run
 
51
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 
52
  ) 
 
53
  IF(INSTALL_MYSQLTESTDIR)
 
54
    INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mtr 
 
55
      ${CMAKE_CURRENT_BINARY_DIR}/mysql-test-run 
 
56
      DESTINATION ${INSTALL_MYSQLTESTDIR}
 
57
      COMPONENT Test)
 
58
  ENDIF()
 
59
ENDIF()
 
60
 
 
61
 
 
62
SET(EXP --experimental=collections/default.experimental)
 
63
 
 
64
SET(DEBUG_SERVER "")
 
65
SET(VS_CONFIG "")
 
66
 
 
67
IF(DEBUG_EXTNAME)
 
68
  SET(DEBUG_SERVER "--debug-server")
 
69
ENDIF()
 
70
 
 
71
IF(CMAKE_BUILD_TYPE)
 
72
  IF(CMAKE_BUILD_TYPE MATCHES "Debug")
 
73
    SET(DEBUG_SERVER "--debug-server")
 
74
  ELSE()
 
75
    SET(DEBUG_SERVER "")
 
76
    IF(CMAKE_GENERATOR MATCHES "Visual Studio" OR
 
77
       CMAKE_GENERATOR MATCHES "Xcode")
 
78
      SET(VS_CONFIG "--vs-config=${CMAKE_CFG_INTDIR}")
 
79
    ENDIF()
 
80
  ENDIF()
 
81
ENDIF()
 
82
 
 
83
# On windows do: 'devenv mysql.sln /build Debug /project test-mtr'
 
84
# On unix do: 'make test-mtr'
 
85
ADD_CUSTOM_TARGET(test-mtr
 
86
  COMMAND perl ./mysql-test-run.pl --force --parallel=4 --suite=main
 
87
          ${VS_CONFIG} ${DEBUG_SERVER} ${EXP}
 
88
)
 
89
 
 
90
## We could do something like this, but the 'test' target generated
 
91
## by cmake is really for unit testing: all output is muted by default,
 
92
## even in case of test failure.
 
93
## ADD_EXECUTABLE(perl IMPORTED)
 
94
## ADD_TEST(xxx perl ./mysql-test-run.pl --force
 
95
##          ${VS_CONFIG} ${DEBUG_SERVER} ${EXP})
 
96
 
 
97
 
 
98
# Process .in files with includes in collections/
 
99
 
 
100
MACRO(PROCESS_COLLECTION_INCLUDE collin collection)
 
101
  FILE(STRINGS ${collin} inlines)
 
102
  FOREACH(line ${inlines})
 
103
    IF(${line} MATCHES "#include .*")
 
104
      STRING(REPLACE "#include " "collections/" incfile ${line})
 
105
      FILE(READ ${incfile} contents)
 
106
      FILE(APPEND ${collection} "${contents}")
 
107
    ELSE()
 
108
      FILE(APPEND ${collection} "${line}\n")
 
109
    ENDIF()
 
110
  ENDFOREACH()
 
111
ENDMACRO()
 
112
 
 
113
FILE(GLOB infiles "collections/*.in")
 
114
FOREACH(collin ${infiles})
 
115
  STRING(REPLACE ".in" "" collection ${collin})
 
116
  STRING(REPLACE ".in" ".done" colldone ${collin})
 
117
  # Only generate file once
 
118
  IF(NOT EXISTS ${colldone})
 
119
    PROCESS_COLLECTION_INCLUDE(${collin} ${collection})
 
120
    FILE(APPEND ${colldone} "${collin}\n")
 
121
  ENDIF()
 
122
ENDFOREACH()