gtestutils: add g_test_trap_subprocess()

g_test_trap_fork() doesn't work on Windows and is potentially flaky on
unix anyway given the fork-but-don't-exec. Replace it with
g_test_trap_subprocess(), which re-spawns the same program with
arguments telling it to run a specific (otherwise-ignored) test case.

Make the existing g_test_trap_fork() unit tests be unix-only (they
never passed on Windows anyway), and add a parallel set of
g_test_trap_subprocess() tests.

Also fix the logic of gtestutils's "-p" argument (which is used by the
subprocess tests); previously if you had tests "/foo/bar" and
"/foo/bar/baz", and ran the test program with "-p /foo/bar/baz", it
would run "/foo/bar" too. Fix that and add tests.

https://bugzilla.gnome.org/show_bug.cgi?id=679683
This commit is contained in:
Dan Winship
2012-11-24 15:58:27 -05:00
parent 38859e8e29
commit 960f5500e2
5 changed files with 712 additions and 246 deletions

View File

@@ -2907,6 +2907,7 @@ g_test_perf
g_test_verbose
g_test_undefined
g_test_quiet
g_test_subprocess
g_test_run
GTestFunc
g_test_add_func
@@ -2934,7 +2935,7 @@ g_test_expect_message
g_test_assert_expected_messages
GTestTrapFlags
g_test_trap_fork
g_test_trap_subprocess
g_test_trap_has_passed
g_test_trap_reached_timeout
g_test_trap_assert_passed
@@ -2943,6 +2944,7 @@ g_test_trap_assert_stdout
g_test_trap_assert_stdout_unmatched
g_test_trap_assert_stderr
g_test_trap_assert_stderr_unmatched
g_test_trap_fork
g_test_rand_bit
g_test_rand_int