Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
G
gflags
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
gflags
Commits
1c9f065d
Commit
1c9f065d
authored
Aug 01, 2013
by
Andreas Schuh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add negative compilation tests.
parent
7abcbdcb
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
16 deletions
+92
-16
CMakeLists.txt
CMakeLists.txt
+16
-16
CMakeLists.txt
test/CMakeLists.txt
+22
-0
gflags_nc.py.in
test/gflags_nc.py.in
+33
-0
CMakeLists.txt
test/nc/CMakeLists.txt
+16
-0
gflags_nc.cc
test/nc/gflags_nc.cc
+5
-0
No files found.
CMakeLists.txt
View file @
1c9f065d
...
...
@@ -137,20 +137,6 @@ add_library (gflags ${GFLAGS_SRCS})
add_library
(
gflags_nothreads
${
GFLAGS_SRCS
}
)
set_target_properties
(
gflags_nothreads PROPERTIES COMPILE_DEFINITIONS NO_THREADS
)
# ----------------------------------------------------------------------------
# testing
# TODO(andreas) Replace Bash scripts such that tests can be run on Windows (e.g., Python).
# The gflags_unittest.sh script should best be replaced by multiple
# add_test commands in the test/CMakeLists.txt file.
if
(
UNIX
)
include
(
CTest
)
if
(
BUILD_TESTING
)
enable_testing
()
add_subdirectory
(
test
)
endif
()
endif
()
# ----------------------------------------------------------------------------
# installation
if
(
WIN32
)
...
...
@@ -165,7 +151,7 @@ else ()
set
(
CONFIG_INSTALL_DIR lib/cmake/
${
PACKAGE_NAME
}
)
endif
()
install
(
TARGETS gflags
DESTINATION
${
LIBRARY_INSTALL_DIR
}
EXPORT gflags-lib
)
install
(
TARGETS gflags
gflags_nothreads
DESTINATION
${
LIBRARY_INSTALL_DIR
}
EXPORT gflags-lib
)
install
(
FILES
${
PUBLIC_HDRS
}
DESTINATION
${
INCLUDE_INSTALL_DIR
}
/
${
GFLAGS_NAMESPACE
}
)
file
(
RELATIVE_PATH INSTALL_PREFIX_REL2CONFIG_DIR
"
${
CMAKE_INSTALL_PREFIX
}
/
${
CONFIG_INSTALL_DIR
}
"
"
${
CMAKE_INSTALL_PREFIX
}
"
)
...
...
@@ -192,5 +178,19 @@ endif ()
# ----------------------------------------------------------------------------
# support direct use of build tree
set
(
INSTALL_PREFIX_REL2CONFIG_DIR .
)
export
(
TARGETS gflags FILE
"
${
PROJECT_BINARY_DIR
}
/
${
PACKAGE_NAME
}
-export.cmake"
)
export
(
TARGETS gflags
gflags_nothreads
FILE
"
${
PROJECT_BINARY_DIR
}
/
${
PACKAGE_NAME
}
-export.cmake"
)
configure_file
(
cmake/config.cmake.in
"
${
PROJECT_BINARY_DIR
}
/
${
PACKAGE_NAME
}
-config.cmake"
@ONLY
)
# ----------------------------------------------------------------------------
# testing - MUST follow the generation of the build tree config file
# TODO(andreas) Replace Bash scripts such that tests can be run on Windows (e.g., Python).
# The gflags_unittest.sh script should best be replaced by multiple
# add_test commands in the test/CMakeLists.txt file.
if
(
UNIX
)
include
(
CTest
)
if
(
BUILD_TESTING
)
enable_testing
()
add_subdirectory
(
test
)
endif
()
endif
()
test/CMakeLists.txt
View file @
1c9f065d
## gflags tests
find_package
(
PythonInterp
)
# ----------------------------------------------------------------------------
# output directories
set
(
CMAKE_RUNTIME_OUTPUT_DIRECTORY
"
${
PROJECT_BINARY_DIR
}
/Testing/bin"
)
...
...
@@ -18,11 +20,31 @@ link_libraries (gflags_nothreads)
configure_file
(
gflags_unittest.cc gflags_unittest-main.cc COPYONLY
)
configure_file
(
gflags_unittest.cc gflags_unittest_main.cc COPYONLY
)
set
(
SRCDIR
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/nc"
)
configure_file
(
gflags_nc.py.in
"
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/nc.py"
@ONLY
)
add_executable
(
strip_flags gflags_strip_flags_test.cc
)
add_executable
(
unittest gflags_unittest.cc
)
add_executable
(
unittest2 gflags_unittest-main.cc
)
add_executable
(
unittest3 gflags_unittest_main.cc
)
# ----------------------------------------------------------------------------
# (negative) compilation tests
if
(
PYTHON_EXECUTABLE
)
macro
(
add_nc_test name
)
add_test
(
NAME nc_
${
name
}
COMMAND
"
${
PYTHON_EXECUTABLE
}
"
"
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/nc.py"
${
name
}
)
endmacro
()
add_nc_test
(
sanity
)
add_nc_test
(
swapped_args
)
add_nc_test
(
int_instead_of_bool
)
add_nc_test
(
bool_in_quotes
)
add_nc_test
(
define_string_with_0
)
endif
()
# ----------------------------------------------------------------------------
# test commands
add_test
(
...
...
test/gflags_nc.py.in
0 → 100644
View file @
1c9f065d
#!/usr/bin/env python
import
os
import
sys
import
subprocess
import
shutil
CMAKE
=
'@CMAKE_COMMAND@'
TMPDIR
=
'@TEMPDIR@'
SRCDIR
=
'@SRCDIR@'
GFLAGS_DIR
=
'@gflags_BINARY_DIR@'
if
__name__
==
"__main__"
:
if
len
(
sys
.
argv
)
!=
2
:
sys
.
stderr
.
write
(
' '
.
join
([
'usage:'
,
sys
.
argv
[
0
],
'<test_name>
\n
'
]))
sys
.
exit
(
1
)
test_name
=
sys
.
argv
[
1
]
bindir
=
os
.
path
.
join
(
TMPDIR
,
'_'
.
join
([
'nc'
,
test_name
]))
if
TMPDIR
==
''
:
sys
.
stderr
.
write
(
'Temporary directory not set!
\n
'
)
sys
.
exit
(
1
)
# create build directory
if
os
.
path
.
isdir
(
bindir
):
shutil
.
rmtree
(
bindir
)
os
.
makedirs
(
bindir
)
# configure the build tree
if
subprocess
.
call
([
CMAKE
,
'-Dgflags_DIR:PATH='
+
GFLAGS_DIR
,
'-DTEST_NAME:STRING='
+
test_name
,
SRCDIR
],
cwd
=
bindir
)
!=
0
:
sys
.
stderr
.
write
(
'Failed to configure the build tree!
\n
'
)
sys
.
exit
(
1
)
# try build, which is supposed to fail (except in case of the sanity check)
if
subprocess
.
call
([
CMAKE
,
'--build'
,
bindir
],
cwd
=
bindir
)
==
0
and
test_name
!=
'sanity'
:
sys
.
stderr
.
write
(
'Build expected to fail, but it succeeded!
\n
'
)
sys
.
exit
(
1
)
sys
.
exit
(
0
)
test/nc/CMakeLists.txt
0 → 100644
View file @
1c9f065d
## gflags negative compilation tests
cmake_minimum_required
(
VERSION 2.8
)
if
(
NOT TEST_NAME
)
message
(
FATAL_ERROR
"Missing TEST_NAME CMake flag"
)
endif
()
string
(
TOUPPER
${
TEST_NAME
}
TEST_NAME_UPPER
)
project
(
gflags_nc_
${
TEST_NAME
}
)
find_package
(
gflags REQUIRED
)
include_directories
(
${
gflags_INCLUDE_DIR
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/.."
)
link_libraries
(
gflags_nothreads
)
add_definitions
(
-DTEST_
${
TEST_NAME_UPPER
}
)
add_executable
(
gflags_nc_
${
TEST_NAME
}
gflags_nc.cc
)
test/gflags_nc.cc
→
test/
nc/
gflags_nc.cc
View file @
1c9f065d
...
...
@@ -66,3 +66,8 @@ DEFINE_string(some_string_flag,
"Trying to construct a string by passing 0 would cause a crash."
);
#endif
int
main
(
int
,
char
**
)
{
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment