[glib: 1/8] gtestutils: Add regression test for combining -s with --tap
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/8] gtestutils: Add regression test for combining -s with --tap
- Date: Mon, 29 Apr 2019 15:46:29 +0000 (UTC)
commit 88bac46287c648a5bddbe3ac862d44c0038f05dc
Author: Simon McVittie <smcv collabora com>
Date: Thu Dec 20 17:45:46 2018 +0000
gtestutils: Add regression test for combining -s with --tap
Signed-off-by: Simon McVittie <smcv collabora com>
glib/tests/testing-helper.c | 10 ++++++++++
glib/tests/testing.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
---
diff --git a/glib/tests/testing-helper.c b/glib/tests/testing-helper.c
index b0e1f4a98..c472778a5 100644
--- a/glib/tests/testing-helper.c
+++ b/glib/tests/testing-helper.c
@@ -101,6 +101,16 @@ main (int argc,
g_test_add_func ("/incomplete", test_incomplete);
g_test_add_func ("/fail", test_fail);
}
+ else if (g_strcmp0 (argv1, "skip-options") == 0)
+ {
+ /* The caller is expected to skip some of these with
+ * -p, -s and/or --GTestSkipCount */
+ g_test_add_func ("/a", test_pass);
+ g_test_add_func ("/b/a", test_pass);
+ g_test_add_func ("/b/b", test_pass);
+ g_test_add_func ("/c/a", test_pass);
+ g_test_add_func ("/d/a", test_pass);
+ }
else
{
g_assert_not_reached ();
diff --git a/glib/tests/testing.c b/glib/tests/testing.c
index 03b9ca2c4..225f29941 100644
--- a/glib/tests/testing.c
+++ b/glib/tests/testing.c
@@ -1063,6 +1063,39 @@ test_tap (void)
g_assert_no_error (error);
g_ptr_array_unref (argv);
+
+ g_test_message ("-s");
+ argv = g_ptr_array_new ();
+ g_ptr_array_add (argv, (char *) testing_helper);
+ g_ptr_array_add (argv, "skip-options");
+ g_ptr_array_add (argv, "--tap");
+ g_ptr_array_add (argv, "-s");
+ g_ptr_array_add (argv, "/a");
+ g_ptr_array_add (argv, "-s");
+ g_ptr_array_add (argv, "/b");
+ g_ptr_array_add (argv, "-s");
+ g_ptr_array_add (argv, "/c/a");
+ g_ptr_array_add (argv, NULL);
+
+ g_spawn_sync (NULL, (char **) argv->pdata, NULL,
+ G_SPAWN_STDERR_TO_DEV_NULL,
+ NULL, NULL, &output, NULL, &status,
+ &error);
+ g_assert_no_error (error);
+ g_assert_nonnull (strstr (output, "1..5\n"));
+ g_assert_nonnull (strstr (output, "\nok 1 /a # SKIP by request"));
+ /* "-s /b" would skip a test named exactly /b, but not a test named
+ * /b/anything */
+ g_assert_nonnull (strstr (output, "\nok 2 /b/a\n"));
+ g_assert_nonnull (strstr (output, "\nok 3 /b/b\n"));
+ g_assert_nonnull (strstr (output, "\nok 4 /c/a # SKIP by request"));
+ g_assert_nonnull (strstr (output, "\nok 5 /d/a\n"));
+
+ g_spawn_check_exit_status (status, &error);
+ g_assert_no_error (error);
+
+ g_free (output);
+ g_ptr_array_unref (argv);
}
int
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]