summaryrefslogtreecommitdiff
path: root/tests/warn
diff options
context:
space:
mode:
Diffstat (limited to 'tests/warn')
-rw-r--r--tests/warn/Makefile.am10
-rw-r--r--tests/warn/annotationparser.h11
-rw-r--r--tests/warn/invalid-element-type.h10
-rw-r--r--tests/warn/missing-element-type.h8
-rw-r--r--tests/warn/unknown-parameter.h20
-rw-r--r--tests/warn/warningtester.py19
-rwxr-xr-xtests/warn/warntestrunner8
7 files changed, 75 insertions, 11 deletions
diff --git a/tests/warn/Makefile.am b/tests/warn/Makefile.am
index c4354223..bce45629 100644
--- a/tests/warn/Makefile.am
+++ b/tests/warn/Makefile.am
@@ -1,10 +1,11 @@
include $(top_srcdir)/common.mk
-TESTS = \
+TESTS = warntestrunner
+
+alltests = \
annotationparser.h \
callback-invalid-scope.h \
callback-missing-scope.h \
- return-gobject.h \
invalid-array.h \
invalid-closure.h \
invalid-constructor.h \
@@ -14,9 +15,10 @@ TESTS = \
invalid-out.h \
invalid-transfer.h \
missing-element-type.h \
+ return-gobject.h \
unknown-parameter.h \
unresolved-type.h
-EXTRA_DIST = warningtester.py common.h $(TESTS)
+EXTRA_DIST = warningtester.py $(alltests) common.h $(TESTS)
-TESTS_ENVIRONMENT = PYTHONPATH=$(top_builddir):$(top_srcdir) TOP_BUILDDIR=$(top_builddir) UNINSTALLED_INTROSPECTION_SRCDIR=$(top_srcdir) $(PYTHON) $(srcdir)/warningtester.py
+TESTS_ENVIRONMENT = PYTHONPATH=$(top_builddir):$(top_srcdir) TOP_BUILDDIR=$(top_builddir) UNINSTALLED_INTROSPECTION_SRCDIR=$(top_srcdir) PYTHON=$(PYTHON) srcdir=$(srcdir) alltests="$(alltests)"
diff --git a/tests/warn/annotationparser.h b/tests/warn/annotationparser.h
index ff9030e4..dba69711 100644
--- a/tests/warn/annotationparser.h
+++ b/tests/warn/annotationparser.h
@@ -203,3 +203,14 @@ void test_symbol_twice_documented();
// EXPECT:195: Warning: Test: ignoring unrecognized GTK-Doc comment block, identifier not found:
//+
//+^
+
+/**
+ * regress_test_invalid_comment_end:
+ * @foo: a param
+ *
+ * invalid comment with a line without
+ * https://bugzilla.gnome.org/show_bug.cgi?id=689354 */
+
+// EXPECT:212: Warning: Test: Comments should end with */ on a new line:
+//+ * https://bugzilla.gnome.org/show_bug.cgi?id=689354 */
+//+ ^
diff --git a/tests/warn/invalid-element-type.h b/tests/warn/invalid-element-type.h
index 52e31164..bcd9123b 100644
--- a/tests/warn/invalid-element-type.h
+++ b/tests/warn/invalid-element-type.h
@@ -65,6 +65,14 @@ void test_invalid_ptrarray_element_type(GPtrArray *p1, GPtrArray *p2);
GList* test_unresolved_element_type(void);
+/**
+ * test_unresolved_value_element_type:
+ *
+ * Returns: (element-type GLib.Value) (transfer full):
+ */
+
+GPtrArray* test_unresolved_value_element_type(void);
+
// EXPECT:5: Warning: Test: element-type annotation takes at least one option, none given
// EXPECT:6: Warning: Test: element-type annotation for a list must have exactly one option, not 2 options
@@ -78,5 +86,7 @@ GList* test_unresolved_element_type(void);
// EXPECT:51: Warning: Test: element-type annotation takes at least one option, none given
// EXPECT:52: Warning: Test: invalid (element-type) for a GPtrArray, must be a pointer
// EXPECT:63: Warning: Test: test_unresolved_element_type: Unknown type: 'Unresolved'
+// EXPECT:71: Warning: Test: test_unresolved_value_element_type: Unknown type: 'GLib.Value'
// EXPECT:4: Warning: Test: test_invalid_list_element_type: argument l1: Missing (element-type) annotation
// EXPECT:4: Warning: Test: test_invalid_list_element_type: argument l2: Missing (element-type) annotation
+// EXPECT:50: Warning: Test: test_invalid_ptrarray_element_type: argument p1: Missing (element-type) annotation
diff --git a/tests/warn/missing-element-type.h b/tests/warn/missing-element-type.h
index 1f958a74..87206403 100644
--- a/tests/warn/missing-element-type.h
+++ b/tests/warn/missing-element-type.h
@@ -8,3 +8,11 @@
GSList *test_gslist_element_type(void);
// EXPECT:6: Warning: Test: test_gslist_element_type: return value: Missing (element-type) annotation
+
+/**
+ * test_ptrarray_element_type:
+ * @somearray: An array.
+ */
+void test_ptrarray_arg_element_type(GPtrArray *somearray);
+
+// EXPECT:16: Warning: Test: test_ptrarray_arg_element_type: argument somearray: Missing (element-type) annotation
diff --git a/tests/warn/unknown-parameter.h b/tests/warn/unknown-parameter.h
index 3d339b32..384704df 100644
--- a/tests/warn/unknown-parameter.h
+++ b/tests/warn/unknown-parameter.h
@@ -46,3 +46,23 @@ void test_param_missing(void);
void test_param_varargs(int i, ...);
// Should not warn
+
+/**
+ * test_undocumentable_param:
+ */
+void test_undocumentable_param(int);
+
+// EXPECT:53: Warning: Test: symbol='test_undocumentable_param': missing parameter name; undocumentable
+
+void test_undocumentable_param_2(int a, int);
+
+// EXPECT:57: Warning: Test: symbol='test_undocumentable_param_2': missing parameter name; undocumentable
+
+void test_undocumentable_param_3(int, int);
+
+// EXPECT:61: Warning: Test: symbol='test_undocumentable_param_3': missing parameter name; undocumentable
+// EXPECT:61: Warning: Test: symbol='test_undocumentable_param_3': missing parameter name; undocumentable
+
+void test_void(void);
+
+// Should not warn
diff --git a/tests/warn/warningtester.py b/tests/warn/warningtester.py
index ee6b3c16..fc3c3d2d 100644
--- a/tests/warn/warningtester.py
+++ b/tests/warn/warningtester.py
@@ -61,23 +61,24 @@ def _diff(a, b):
for line in a[i1:i2]:
for l in line.split('\n'):
if l != '':
- retval += ' ' + l + '\n'
+ retval += ' ' + l + '\n'
continue
if tag in ('replace', 'delete'):
for line in a[i1:i2]:
for l in line.split('\n'):
if l != '':
- retval += '-' + l + '\n'
+ retval += '-' + l + '\n'
if tag in ('replace', 'insert'):
for line in b[j1:j2]:
for l in line.split('\n'):
if l != '':
- retval += '+' + l + '\n'
+ retval += '+' + l + '\n'
return retval
+
def _extract_expected(filename):
fd = open(filename, 'rU')
data = fd.read()
@@ -92,6 +93,7 @@ def _extract_expected(filename):
return retval
+
def check(args):
filename = args[0]
@@ -128,12 +130,15 @@ def check(args):
expected_warnings = _extract_expected(filename)
+ expected_warnings.sort()
+ emitted_warnings.sort()
+
if len(expected_warnings) != len(emitted_warnings):
raise SystemExit('ERROR in %r: %d warnings were emitted, '
- 'expected %d:\n%s' %(os.path.basename(filename),
- len(emitted_warnings),
- len(expected_warnings),
- _diff(expected_warnings, emitted_warnings)))
+ 'expected %d:\n%s' % (os.path.basename(filename),
+ len(emitted_warnings),
+ len(expected_warnings),
+ _diff(expected_warnings, emitted_warnings)))
for emitted_warning, expected_warning in zip(emitted_warnings, expected_warnings):
if expected_warning != emitted_warning:
diff --git a/tests/warn/warntestrunner b/tests/warn/warntestrunner
new file mode 100755
index 00000000..d3a4e87a
--- /dev/null
+++ b/tests/warn/warntestrunner
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+
+set -e
+
+for testname in ${alltests}; do
+ echo "Running warning test:" $testname
+ $PYTHON $srcdir/warningtester.py "$srcdir/$testname"
+done