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
0d9486f9
Commit
0d9486f9
authored
Mar 17, 2014
by
Andreas Schuh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass --test_tmpdir and --srcdir to unittests.
parent
505686bd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
14 deletions
+11
-14
utils.cmake
cmake/utils.cmake
+4
-2
CMakeLists.txt
test/CMakeLists.txt
+5
-4
gflags_unittest.cc
test/gflags_unittest.cc
+2
-8
No files found.
cmake/utils.cmake
View file @
0d9486f9
...
@@ -70,13 +70,15 @@ endfunction ()
...
@@ -70,13 +70,15 @@ endfunction ()
# expected exit status. Moreover, the execute_test.cmake script
# expected exit status. Moreover, the execute_test.cmake script
# sets environment variables needed by the --fromenv/--tryfromenv tests.
# sets environment variables needed by the --fromenv/--tryfromenv tests.
macro
(
add_gflags_test name expected_rc expected_output unexpected_output cmd
)
macro
(
add_gflags_test name expected_rc expected_output unexpected_output cmd
)
set
(
args
"--test_tmpdir=
${
PROJECT_BINARY_DIR
}
/Testing/Temporary"
"--srcdir=
${
PROJECT_SOURCE_DIR
}
/test"
)
add_test
(
add_test
(
NAME
${
name
}
NAME
${
name
}
COMMAND
"
${
CMAKE_COMMAND
}
"
"-DCOMMAND:STRING=$<TARGET_FILE:
${
cmd
}
>;
${
ARGN
}
"
COMMAND
"
${
CMAKE_COMMAND
}
"
"-DCOMMAND:STRING=$<TARGET_FILE:
${
cmd
}
>;
${
args
}
;
${
ARGN
}
"
"-DEXPECTED_RC:STRING=
${
expected_rc
}
"
"-DEXPECTED_RC:STRING=
${
expected_rc
}
"
"-DEXPECTED_OUTPUT:STRING=
${
expected_output
}
"
"-DEXPECTED_OUTPUT:STRING=
${
expected_output
}
"
"-DUNEXPECTED_OUTPUT:STRING=
${
unexpected_output
}
"
"-DUNEXPECTED_OUTPUT:STRING=
${
unexpected_output
}
"
-P
"
${
PROJECT_SOURCE_DIR
}
/cmake/execute_test.cmake"
-P
"
${
PROJECT_SOURCE_DIR
}
/cmake/execute_test.cmake"
WORKING_DIRECTORY
"
${
PROJECT_SOURCE_DIR
}
/test
"
WORKING_DIRECTORY
"
${
GFLAGS_FLAGFILES_DIR
}
"
)
)
endmacro
()
endmacro
()
test/CMakeLists.txt
View file @
0d9486f9
...
@@ -6,7 +6,8 @@ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/Testing/bin")
...
@@ -6,7 +6,8 @@ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/Testing/bin")
set
(
CMAKE_LIBRARY_OUTPUT_DIRECTORY
"
${
PROJECT_BINARY_DIR
}
/Testing/lib"
)
set
(
CMAKE_LIBRARY_OUTPUT_DIRECTORY
"
${
PROJECT_BINARY_DIR
}
/Testing/lib"
)
set
(
CMAKE_ARCHIVE_OUTPUT_DIRECTORY
"
${
PROJECT_BINARY_DIR
}
/Testing/lib"
)
set
(
CMAKE_ARCHIVE_OUTPUT_DIRECTORY
"
${
PROJECT_BINARY_DIR
}
/Testing/lib"
)
set
(
TEMPDIR
"
${
PROJECT_BINARY_DIR
}
/Testing/Temporary"
)
# set working directory of test commands
set
(
GFLAGS_FLAGFILES_DIR
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
)
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# common include directories and link libraries
# common include directories and link libraries
...
@@ -112,9 +113,9 @@ add_gflags_test(undefok-5 1 "unknown command line flag 'foo'" "" unittest --unde
...
@@ -112,9 +113,9 @@ add_gflags_test(undefok-5 1 "unknown command line flag 'foo'" "" unittest --unde
add_gflags_test
(
undefok-6 1
"unknown command line flag 'foo'"
""
unittest --undefok=foot --foo --unused_bool
)
add_gflags_test
(
undefok-6 1
"unknown command line flag 'foo'"
""
unittest --undefok=foot --foo --unused_bool
)
# See if we can successfully load our flags from the flagfile
# See if we can successfully load our flags from the flagfile
add_gflags_test
(
flagfile.1 0
"gflags_unittest"
"gflags_unittest.cc"
unittest
"--flagfile=
${
CMAKE_CURRENT_LIST_DIR
}
/
flagfile.1"
)
add_gflags_test
(
flagfile.1 0
"gflags_unittest"
"gflags_unittest.cc"
unittest
"--flagfile=flagfile.1"
)
add_gflags_test
(
flagfile.2 0
"PASS"
""
unittest
"--flagfile=
${
CMAKE_CURRENT_LIST_DIR
}
/
flagfile.2"
)
add_gflags_test
(
flagfile.2 0
"PASS"
""
unittest
"--flagfile=flagfile.2"
)
add_gflags_test
(
flagfile.3 0
"PASS"
""
unittest
"--flagfile=
${
CMAKE_CURRENT_LIST_DIR
}
/
flagfile.3"
)
add_gflags_test
(
flagfile.3 0
"PASS"
""
unittest
"--flagfile=flagfile.3"
)
# Also try to load flags from the environment
# Also try to load flags from the environment
add_gflags_test
(
fromenv=version 0
"gflags_unittest"
"gflags_unittest.cc"
unittest --fromenv=version
)
add_gflags_test
(
fromenv=version 0
"gflags_unittest"
"gflags_unittest.cc"
unittest --fromenv=version
)
...
...
test/gflags_unittest.cc
View file @
0d9486f9
...
@@ -66,14 +66,8 @@ using GFLAGS_NAMESPACE::RegisterFlagValidator;
...
@@ -66,14 +66,8 @@ using GFLAGS_NAMESPACE::RegisterFlagValidator;
using
GFLAGS_NAMESPACE
::
CommandLineFlagInfo
;
using
GFLAGS_NAMESPACE
::
CommandLineFlagInfo
;
using
GFLAGS_NAMESPACE
::
GetAllFlags
;
using
GFLAGS_NAMESPACE
::
GetAllFlags
;
DEFINE_string
(
test_tmpdir
,
"/tmp/gflags_unittest"
,
"Dir we use for temp files"
);
DEFINE_string
(
test_tmpdir
,
""
,
"Dir we use for temp files"
);
#ifdef _MSC_VER // in MSVC, we run from the vsprojects directory
DEFINE_string
(
srcdir
,
StringFromEnv
(
"SRCDIR"
,
"."
),
"Source-dir root, needed to find gflags_unittest_flagfile"
);
DEFINE_string
(
srcdir
,
"..
\\
.."
,
"Source-dir root, needed to find gflags_unittest_flagfile"
);
#else
DEFINE_string
(
srcdir
,
StringFromEnv
(
"SRCDIR"
,
"."
),
"Source-dir root, needed to find gflags_unittest_flagfile"
);
#endif
DECLARE_string
(
tryfromenv
);
// in gflags.cc
DECLARE_string
(
tryfromenv
);
// in gflags.cc
...
...
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