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

@@ -1097,7 +1097,7 @@ g_assert_warning (const char *log_domain,
*
* Note that you cannot use this to test g_error() messages, since
* g_error() intentionally never returns even if the program doesn't
* abort; use g_test_trap_fork() in this case.
* abort; use g_test_trap_subprocess() in this case.
*
* Since: 2.34
*/