summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2014-05-09 07:58:41 +0100
committerPhilip Withnall <philip.withnall@collabora.co.uk>2014-05-09 07:58:41 +0100
commit46e127a803ec7bf3b22044ee1f2128a3bd8156f2 (patch)
tree3d6354303a538017c5cac82c50f33cbcd5ac3b49 /tests
parent9d7eb5cd25071bc632eac9987a7cd0e591c2cac5 (diff)
tests: Check for all expected error lines rather than just one
Previously, the wrapper-compiler-errors script was assuming a test was successful if it could see at least one of the expected error message lines in the compiler output. Since several of those lines are boilerplate, this hid legitimate test failures. Fix it so that *all* expected lines are checked for (although there are no checks which test that *only* those lines were output), and fix up a few tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/gsignal-connect.c10
-rw-r--r--tests/gvariant-get.c8
-rw-r--r--tests/gvariant-new.c18
-rwxr-xr-xtests/wrapper-compiler-errors17
4 files changed, 32 insertions, 21 deletions
diff --git a/tests/gsignal-connect.c b/tests/gsignal-connect.c
index 7f529bf..dc63a53 100644
--- a/tests/gsignal-connect.c
+++ b/tests/gsignal-connect.c
@@ -61,7 +61,7 @@
}
/*
- * Incorrect type for argument 1 in signal handler for signal ‘GObject::notify’. Expected ‘GObject *’ but saw ‘GIOStream *’.
+ * Incorrect type for argument ‘self’ in signal handler for signal ‘GObject::notify’. Expected ‘GObject *’ but saw ‘GIOStream *’.
* (GCallback) object_notify_invalid_parameter_subclass_cb,
* ^
* note: expanded from macro 'g_signal_connect'
@@ -76,7 +76,7 @@
}
/*
- * Incorrect type for argument 1 in signal handler for signal ‘GObject::notify’. Expected ‘GObject *’ but saw ‘const GObject *’.
+ * Incorrect type for argument ‘self’ in signal handler for signal ‘GObject::notify’. Expected ‘GObject *’ but saw ‘const GObject *’.
* (GCallback) object_notify_invalid_parameter_const_cb,
* ^
* note: expanded from macro 'g_signal_connect'
@@ -91,7 +91,7 @@
}
/*
- * Incorrect type for argument 2 in signal handler for signal ‘GObject::notify’. Expected ‘GParamSpec *’ but saw ‘void *’.
+ * Incorrect type for argument ‘pspec’ in signal handler for signal ‘GObject::notify’. Expected ‘GParamSpec *’ but saw ‘void *’.
* (GCallback) object_notify_invalid_parameter_middle_cb,
* ^
* note: expanded from macro 'g_signal_connect'
@@ -106,7 +106,7 @@
}
/*
- * Incorrect type for argument 3 in signal handler for signal ‘GObject::notify’. Expected ‘void *’ but saw ‘guint’.
+ * Incorrect type for argument ‘user_data’ in signal handler for signal ‘GObject::notify’. Expected ‘void *’ but saw ‘guint’.
* (GCallback) object_notify_invalid_parameter_user_data_cb,
* ^
* note: expanded from macro 'g_signal_connect'
@@ -160,7 +160,7 @@
}
/*
- * No signal named ‘invalid-signal’ in GObject class ‘Object’.
+ * No signal named ‘invalid-signal’ in GObject class ‘GObject’. To improve static analysis, add a typecast to the GObject parameter of g_signal_connect_data().
* g_signal_connect (some_object, "invalid-signal",
* ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* note: expanded from macro 'g_signal_connect'
diff --git a/tests/gvariant-get.c b/tests/gvariant-get.c
index cfa2700..5eccae7 100644
--- a/tests/gvariant-get.c
+++ b/tests/gvariant-get.c
@@ -37,7 +37,7 @@
/*
* Expected a GVariant variadic argument of type ‘int *’ but there wasn’t one.
- * g_variant_get ("invalid");
+ * g_variant_get (existing_variant, "invalid");
* ^
*/
{
@@ -176,7 +176,7 @@
}
/*
- * Expected a GVariant variadic argument of type ‘GVariant **’ but saw one of type ‘char **’.
+ * Expected a GVariant variadic argument of type ‘GVariant **’ but saw one of type ‘gchar **’.
* g_variant_get (existing_variant, "@s", &some_str);
* ^
*/
@@ -214,8 +214,8 @@
/*
- * Unexpected GVariant format strings ‘u’ with unpaired arguments. If using multiple format strings, they should be enclosed in brackets to create a tuple (e.g. ‘(su)’).
- * g_variant_get (existing_variant, "su", &some_str, &some_int);
+ * Unexpected GVariant format strings ‘i’ with unpaired arguments. If using multiple format strings, they should be enclosed in brackets to create a tuple (e.g. ‘(si)’).
+ * g_variant_get (existing_variant, "si", &some_str, &some_int);
* ^
*/
{
diff --git a/tests/gvariant-new.c b/tests/gvariant-new.c
index 1508654..75e6e0e 100644
--- a/tests/gvariant-new.c
+++ b/tests/gvariant-new.c
@@ -3,7 +3,7 @@
/*
* Expected a GVariant variadic argument of type ‘char *’ but saw one of type ‘guint’.
* floating_variant = g_variant_new ("(sss)", "hello", my_string, a_little_int_short_and_stout);
- * ^ ^
+ * ^
*/
{
const gchar *my_string = "there";
@@ -58,9 +58,9 @@
}
/*
- * Expected a GVariant variadic argument of type ‘unsigned char’ but saw one of type ‘char *’.
+ * Expected a GVariant variadic argument of type ‘int’ but saw one of type ‘char *’.
* floating_variant = g_variant_new ("y", "nope");
- * ^ ^
+ * ^
*/
{
floating_variant = g_variant_new ("y", "nope");
@@ -82,7 +82,7 @@
}
/*
- * Expected a GVariant variadic argument of type ‘short’ but saw one of type ‘char *’.
+ * Expected a GVariant variadic argument of type ‘int’ but saw one of type ‘char *’.
* floating_variant = g_variant_new ("n", "nope");
* ^
*/
@@ -242,7 +242,7 @@
}
/*
- * Expected a GVariant variadic argument of type ‘signed long’ but saw one of type ‘char *’.
+ * Expected a GVariant variadic argument of type ‘unsigned long’ but saw one of type ‘char *’.
* floating_variant = g_variant_new ("t", "nada");
* ^
*/
@@ -251,7 +251,7 @@
}
/*
- * Expected a GVariant variadic argument of type ‘unsigned long’ but saw one of type ‘int’.
+ * Expected a GVariant variadic argument of type ‘unsigned long’ but saw one of type ‘unsigned int’.
* floating_variant = g_variant_new ("t", 5);
* ^
*/
@@ -463,8 +463,8 @@
}
/*
- * Unexpected GVariant format strings ‘u’ with unpaired arguments. If using multiple format strings, they should be enclosed in brackets to create a tuple (e.g. ‘(su)’).
- * floating_variant = g_variant_new ("su", "some", 56);
+ * Unexpected GVariant format strings ‘i’ with unpaired arguments. If using multiple format strings, they should be enclosed in brackets to create a tuple (e.g. ‘(si)’).
+ * floating_variant = g_variant_new ("si", "some", 56);
* ^
*/
{
@@ -642,7 +642,7 @@
/*
* Expected a GVariant variadic argument of type ‘char *’ but saw NULL instead.
- * floating_variant = g_variant_new ("{ss}", NULL, "key");
+ * floating_variant = g_variant_new ("{ss}", NULL, "value");
* ^
*/
{
diff --git a/tests/wrapper-compiler-errors b/tests/wrapper-compiler-errors
index 38eaaa0..3cc1618 100755
--- a/tests/wrapper-compiler-errors
+++ b/tests/wrapper-compiler-errors
@@ -99,10 +99,21 @@ while [[ -f `printf "${temp_dir}/${input_filename}_%02d.c" ${num}` ]]; do
# Expecting an error. Check that the expected errors are a
# subset of the actual errors, to allow for spurious Clang
# warnings because generated code is hard.
- grep -F "$(<${expected_error_filename})" "${actual_error_filename}" >/dev/null
- grep_status=$?
+ grep_failed=0
- if [ $grep_status -ne 0 ]; then
+ while read line
+ do
+ grep -F "${line}" "${actual_error_filename}" >/dev/null
+ grep_status=$?
+
+ if [ $grep_status -ne 0 ]; then
+ echo " * Non-matching line:" 1>&2
+ echo "${line}" 1>&2
+ grep_failed=1
+ fi
+ done < "${expected_error_filename}"
+
+ if [ $grep_failed = 1 ]; then
echo " * Error: Expected compiler error was not seen." 1>&2
echo " - Expected:" 1>&2