mirror of
https://github.com/gflags/gflags.git
synced 2025-04-05 05:25:04 +00:00
Fix unit tests for Windows and CygWin.
This commit is contained in:
parent
e491f0161d
commit
1e0b54c6ed
1 changed files with 30 additions and 24 deletions
|
@ -16,7 +16,7 @@ link_libraries (gflags_nothreads)
|
|||
|
||||
# ----------------------------------------------------------------------------
|
||||
# STRIP_FLAG_HELP: check with "strings" that help text is not in binary
|
||||
if (UNIX)
|
||||
if (UNIX AND NOT CYGWIN)
|
||||
add_executable (strip_flags gflags_strip_flags_test.cc)
|
||||
add_test (
|
||||
NAME strip_flags
|
||||
|
@ -34,11 +34,17 @@ add_executable (unittest gflags_unittest.cc)
|
|||
add_executable (unittest2 gflags_unittest-main.cc)
|
||||
add_executable (unittest3 gflags_unittest_main.cc)
|
||||
|
||||
if (UNIX)
|
||||
set (SLASH "/")
|
||||
else ()
|
||||
set (SLASH "\\\\")
|
||||
endif ()
|
||||
|
||||
# First, just make sure the unittest works as-is
|
||||
add_gflags_test(unittest 0 "" "" unittest)
|
||||
|
||||
# --help should show all flags, including flags from gflags_reporting
|
||||
add_gflags_test(help-reporting 1 "gflags_reporting.cc" "" unittest --help)
|
||||
add_gflags_test(help-reporting 1 "${SLASH}gflags_reporting.cc" "" unittest --help)
|
||||
|
||||
# Make sure that --help prints even very long helpstrings.
|
||||
add_gflags_test(long-helpstring 1 "end of a long helpstring" "" unittest --help)
|
||||
|
@ -54,18 +60,18 @@ add_gflags_test(nohelp 0 "PASS" "" unittest --nohelp)
|
|||
add_gflags_test(help=false 0 "PASS" "" unittest --help=false)
|
||||
|
||||
# --helpfull is the same as help
|
||||
add_gflags_test(helpfull 1 "gflags_reporting.cc" "" unittest --helpfull)
|
||||
add_gflags_test(helpfull 1 "${SLASH}gflags_reporting.cc" "" unittest --helpfull)
|
||||
|
||||
# --helpshort should show only flags from the unittest itself
|
||||
add_gflags_test(helpshort 1 "gflags_unittest.cc" "gflags_reporting.cc" unittest --helpshort)
|
||||
add_gflags_test(helpshort 1 "${SLASH}gflags_unittest.cc" "${SLASH}gflags_reporting.cc" unittest --helpshort)
|
||||
|
||||
# --helpshort should show the tldflag we created in the unittest dir
|
||||
add_gflags_test(helpshort-tldflag1 1 "tldflag1" "google.cc" unittest --helpshort)
|
||||
add_gflags_test(helpshort-tldflag2 1 "tldflag2" "google.cc" unittest --helpshort)
|
||||
add_gflags_test(helpshort-tldflag1 1 "tldflag1" "${SLASH}google.cc" unittest --helpshort)
|
||||
add_gflags_test(helpshort-tldflag2 1 "tldflag2" "${SLASH}google.cc" unittest --helpshort)
|
||||
|
||||
# --helpshort should work if the main source file is suffixed with [_-]main
|
||||
add_gflags_test(helpshort-main 1 "gflags_unittest-main.cc" "gflags_reporting.cc" unittest2 --helpshort)
|
||||
add_gflags_test(helpshort_main 1 "gflags_unittest_main.cc" "gflags_reporting.cc" unittest3 --helpshort)
|
||||
add_gflags_test(helpshort-main 1 "${SLASH}gflags_unittest-main.cc" "${SLASH}gflags_reporting.cc" unittest2 --helpshort)
|
||||
add_gflags_test(helpshort_main 1 "${SLASH}gflags_unittest_main.cc" "${SLASH}gflags_reporting.cc" unittest3 --helpshort)
|
||||
|
||||
# --helpon needs an argument
|
||||
add_gflags_test(helpon 1 "'--helpon' is missing its argument; flag description: show help on" "" unittest --helpon)
|
||||
|
@ -73,33 +79,33 @@ add_gflags_test(helpon 1 "'--helpon' is missing its argument; flag description:
|
|||
if (BUILD_SHARED_LIBS)
|
||||
# --helpon argument indicates what file we'll show args from
|
||||
# TODO(andreas): This test fails. Why is there no help for the gflags module ?
|
||||
add_gflags_test(helpon=gflags 1 "gflags.cc" "gflags_unittest.cc" unittest --helpon=gflags)
|
||||
add_gflags_test(helpon=gflags 1 "${SLASH}gflags.cc" "${SLASH}gflags_unittest.cc" unittest --helpon=gflags)
|
||||
# another way of specifying the argument
|
||||
# TODO(andreas): This test fails. Why is there no help for the gflags module ?
|
||||
add_gflags_test(helpon_gflags 1 "gflags.cc" "gflags_unittest.cc" unittest --helpon gflags)
|
||||
add_gflags_test(helpon_gflags 1 "${SLASH}gflags.cc" "${SLASH}gflags_unittest.cc" unittest --helpon gflags)
|
||||
endif ()
|
||||
|
||||
# test another argument
|
||||
add_gflags_test(helpon=gflags_unittest 1 "gflags_unittest.cc" "gflags.cc" unittest --helpon=gflags_unittest)
|
||||
add_gflags_test(helpon=gflags_unittest 1 "${SLASH}gflags_unittest.cc" "${SLASH}gflags.cc" unittest --helpon=gflags_unittest)
|
||||
|
||||
# helpmatch is like helpon but takes substrings
|
||||
add_gflags_test(helpmatch_reporting 1 "gflags_reporting.cc" "gflags_unittest.cc" unittest -helpmatch reporting)
|
||||
add_gflags_test(helpmatch=unittest 1 "gflags_unittest.cc" "gflags.cc:" unittest -helpmatch=unittest)
|
||||
add_gflags_test(helpmatch_reporting 1 "${SLASH}gflags_reporting.cc" "${SLASH}gflags_unittest.cc" unittest -helpmatch reporting)
|
||||
add_gflags_test(helpmatch=unittest 1 "${SLASH}gflags_unittest.cc" "${SLASH}gflags.cc:" unittest -helpmatch=unittest)
|
||||
|
||||
# if no flags are found with helpmatch or helpon, suggest --help
|
||||
add_gflags_test(helpmatch=nosuchsubstring 1 "No modules matched" "gflags_unittest.cc" unittest -helpmatch=nosuchsubstring)
|
||||
add_gflags_test(helpon=nosuchmodule 1 "No modules matched" "gflags_unittest.cc" unittest -helpon=nosuchmodule)
|
||||
add_gflags_test(helpmatch=nosuchsubstring 1 "No modules matched" "${SLASH}gflags_unittest.cc" unittest -helpmatch=nosuchsubstring)
|
||||
add_gflags_test(helpon=nosuchmodule 1 "No modules matched" "${SLASH}gflags_unittest.cc" unittest -helpon=nosuchmodule)
|
||||
|
||||
# helppackage shows all the flags in the same dir as this unittest
|
||||
# --help should show all flags, including flags from google.cc
|
||||
add_gflags_test(helppackage 1 "gflags_reporting.cc" "" unittest --helppackage)
|
||||
add_gflags_test(helppackage 1 "${SLASH}gflags_reporting.cc" "" unittest --helppackage)
|
||||
|
||||
# xml!
|
||||
add_gflags_test(helpxml 1 "gflags_unittest.cc</file>" "gflags_unittest.cc:" unittest --helpxml)
|
||||
add_gflags_test(helpxml 1 "${SLASH}gflags_unittest.cc</file>" "${SLASH}gflags_unittest.cc:" unittest --helpxml)
|
||||
|
||||
# just print the version info and exit
|
||||
add_gflags_test(version-1 0 "gflags_unittest" "gflags_unittest.cc" unittest --version)
|
||||
add_gflags_test(version-2 0 "version test_version" "gflags_unittest.cc" unittest --version)
|
||||
add_gflags_test(version-1 0 "gflags_unittest" "${SLASH}gflags_unittest.cc" unittest --version)
|
||||
add_gflags_test(version-2 0 "version test_version" "${SLASH}gflags_unittest.cc" unittest --version)
|
||||
|
||||
# --undefok is a fun flag...
|
||||
add_gflags_test(undefok-1 1 "unknown command line flag 'foo'" "" unittest --undefok= --foo --unused_bool)
|
||||
|
@ -113,24 +119,24 @@ 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)
|
||||
|
||||
# See if we can successfully load our flags from the flagfile
|
||||
add_gflags_test(flagfile.1 0 "gflags_unittest" "gflags_unittest.cc" unittest "--flagfile=flagfile.1")
|
||||
add_gflags_test(flagfile.1 0 "gflags_unittest" "${SLASH}gflags_unittest.cc" unittest "--flagfile=flagfile.1")
|
||||
add_gflags_test(flagfile.2 0 "PASS" "" unittest "--flagfile=flagfile.2")
|
||||
add_gflags_test(flagfile.3 0 "PASS" "" unittest "--flagfile=flagfile.3")
|
||||
|
||||
# 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(tryfromenv=version 0 "gflags_unittest" "gflags_unittest.cc" unittest --tryfromenv=version)
|
||||
add_gflags_test(fromenv=version 0 "gflags_unittest" "${SLASH}gflags_unittest.cc" unittest --fromenv=version)
|
||||
add_gflags_test(tryfromenv=version 0 "gflags_unittest" "${SLASH}gflags_unittest.cc" unittest --tryfromenv=version)
|
||||
add_gflags_test(fromenv=help 0 "PASS" "" unittest --fromenv=help)
|
||||
add_gflags_test(tryfromenv=help 0 "PASS" "" unittest --tryfromenv=help)
|
||||
add_gflags_test(fromenv=helpfull 1 "helpfull not found in environment" "" unittest --fromenv=helpfull)
|
||||
add_gflags_test(tryfromenv=helpfull 0 "PASS" "" unittest --tryfromenv=helpfull)
|
||||
add_gflags_test(tryfromenv=undefok 0 "PASS" "" unittest --tryfromenv=undefok --foo)
|
||||
add_gflags_test(tryfromenv=weirdo 1 "unknown command line flag" "" unittest --tryfromenv=weirdo)
|
||||
add_gflags_test(tryfromenv-multiple 0 "gflags_unittest" "gflags_unittest.cc" unittest --tryfromenv=test_bool,version,unused_bool)
|
||||
add_gflags_test(tryfromenv-multiple 0 "gflags_unittest" "${SLASH}gflags_unittest.cc" unittest --tryfromenv=test_bool,version,unused_bool)
|
||||
add_gflags_test(fromenv=test_bool 1 "not found in environment" "" unittest --fromenv=test_bool)
|
||||
add_gflags_test(fromenv=test_bool-ok 1 "unknown command line flag" "" unittest --fromenv=test_bool,ok)
|
||||
# Here, the --version overrides the fromenv
|
||||
add_gflags_test(version-overrides-fromenv 0 "gflags_unittest" "gflags_unittest.cc" unittest --fromenv=test_bool,version,ok)
|
||||
add_gflags_test(version-overrides-fromenv 0 "gflags_unittest" "${SLASH}gflags_unittest.cc" unittest --fromenv=test_bool,version,ok)
|
||||
|
||||
# Make sure -- by itself stops argv processing
|
||||
add_gflags_test(dashdash 0 "PASS" "" unittest -- --help)
|
||||
|
|
Loading…
Add table
Reference in a new issue