diff options
Diffstat (limited to 'Examples/test-suite/errors')
21 files changed, 70 insertions, 28 deletions
diff --git a/Examples/test-suite/errors/.gitignore b/Examples/test-suite/errors/.gitignore new file mode 100644 index 000000000..22ca11947 --- /dev/null +++ b/Examples/test-suite/errors/.gitignore @@ -0,0 +1,4 @@ +*.newerr +cpp_recursive_typedef.py +cpp_shared_ptr.py +xxx.py diff --git a/Examples/test-suite/errors/Makefile.in b/Examples/test-suite/errors/Makefile.in index 601dcd303..4c61001e7 100644 --- a/Examples/test-suite/errors/Makefile.in +++ b/Examples/test-suite/errors/Makefile.in @@ -13,42 +13,44 @@ # file (.stderr) in addition to the test case itself. ####################################################################### -LANGUAGE = python +LANGUAGE = errors ERROR_EXT = newerr -# Portable dos2unix / todos for stripping CR -TODOS = tr -d '\r' -#TODOS = sed -e 's/\r$$//' # On OSX behaves as if written 's/r$$//' srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ # All .i files with prefix 'cpp_' will be treated as C++ input and remaining .i files as C input -ALL_ERROR_TEST_CASES := $(patsubst %.i,%, $(wildcard *.i)) +ALL_ERROR_TEST_CASES := $(patsubst %.i,%, $(notdir $(wildcard $(srcdir)/*.i))) CPP_ERROR_TEST_CASES := $(filter cpp_%, $(ALL_ERROR_TEST_CASES)) C_ERROR_TEST_CASES := $(filter-out $(CPP_ERROR_TEST_CASES), $(ALL_ERROR_TEST_CASES)) ERROR_TEST_CASES := $(CPP_ERROR_TEST_CASES:=.cpptest) \ - $(C_ERROR_TEST_CASES:=.ctest) + $(C_ERROR_TEST_CASES:=.ctest) include $(srcdir)/../common.mk +# Portable dos2unix / todos for stripping CR +TODOS = tr -d '\r' +#TODOS = sed -e 's/\r$$//' # On OSX behaves as if written 's/r$$//' + +# strip source directory from output, so that diffs compare +STRIP_SRCDIR = sed -e 's|\\|/|g' -e 's|^$(SRCDIR)||' # Rules for the different types of tests -%.cpptest: +%.cpptest: echo "$(ACTION)ing errors testcase $*" - -$(SWIG) -c++ -python -Wall -Fstandard $(SWIGOPT) $*.i 2>&1 | $(TODOS) > $*.$(ERROR_EXT) - $(COMPILETOOL) diff -c $*.stderr $*.$(ERROR_EXT) + -$(SWIG) -c++ -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT) + $(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT) %.ctest: echo "$(ACTION)ing errors testcase $*" - -$(SWIG) -python -Wall -Fstandard $(SWIGOPT) $*.i 2>&1 | $(TODOS) > $*.$(ERROR_EXT) - $(COMPILETOOL) diff -c $*.stderr $*.$(ERROR_EXT) + -$(SWIG) -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT) + $(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT) %.clean: - + @exit 0 clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile $(LANGUAGE)_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" python_clean @rm -f *.$(ERROR_EXT) *.py - diff --git a/Examples/test-suite/errors/c_extra_rblock.stderr b/Examples/test-suite/errors/c_extra_rblock.stderr index 82877023a..be14eee4c 100644 --- a/Examples/test-suite/errors/c_extra_rblock.stderr +++ b/Examples/test-suite/errors/c_extra_rblock.stderr @@ -1 +1 @@ -c_extra_rblock.i:5: Error: Syntax error in input(1). +c_extra_rblock.i:5: Error: Syntax error. Extraneous '%}' diff --git a/Examples/test-suite/errors/c_missing_semi.stderr b/Examples/test-suite/errors/c_missing_semi.stderr index 791b959ca..18befaa1b 100644 --- a/Examples/test-suite/errors/c_missing_semi.stderr +++ b/Examples/test-suite/errors/c_missing_semi.stderr @@ -1 +1 @@ -c_missing_semi.i:3: Error: Syntax error in input(1). +c_missing_semi.i:3: Error: Syntax error - possibly a missing semicolon. diff --git a/Examples/test-suite/errors/cpp_extra_brackets.stderr b/Examples/test-suite/errors/cpp_extra_brackets.stderr index 12bb1f327..f1fabc78d 100644 --- a/Examples/test-suite/errors/cpp_extra_brackets.stderr +++ b/Examples/test-suite/errors/cpp_extra_brackets.stderr @@ -1 +1 @@ -cpp_extra_brackets.i:5: Error: Syntax error in input(3). +cpp_extra_brackets.i:5: Error: Unexpected ')'. diff --git a/Examples/test-suite/errors/pp_constant.i b/Examples/test-suite/errors/pp_constant.i index 2be108e83..c29f4c86d 100644 --- a/Examples/test-suite/errors/pp_constant.i +++ b/Examples/test-suite/errors/pp_constant.i @@ -29,7 +29,9 @@ comment */ %constant int ddd=; #define E1 1234 -#/*C comment*/define E2 1234 +// This case doesn't actually work, but appeared to before we gave an error +// for unknown preprocessor directives. +// #/*C comment*/define E2 1234 #define E3 1234 %constant int eee=; diff --git a/Examples/test-suite/errors/pp_constant.stderr b/Examples/test-suite/errors/pp_constant.stderr index 9c79ec2be..54a87edfe 100644 --- a/Examples/test-suite/errors/pp_constant.stderr +++ b/Examples/test-suite/errors/pp_constant.stderr @@ -2,7 +2,7 @@ pp_constant.i:9: Warning 305: Bad constant value (ignored). pp_constant.i:15: Warning 305: Bad constant value (ignored). pp_constant.i:23: Warning 305: Bad constant value (ignored). pp_constant.i:29: Warning 305: Bad constant value (ignored). -pp_constant.i:35: Warning 305: Bad constant value (ignored). -pp_constant.i:42: Warning 305: Bad constant value (ignored). -pp_constant.i:46: Warning 305: Bad constant value (ignored). -pp_constant.i:49: Warning 305: Bad constant value (ignored). +pp_constant.i:37: Warning 305: Bad constant value (ignored). +pp_constant.i:44: Warning 305: Bad constant value (ignored). +pp_constant.i:48: Warning 305: Bad constant value (ignored). +pp_constant.i:51: Warning 305: Bad constant value (ignored). diff --git a/Examples/test-suite/errors/pp_missing_enddef.stderr b/Examples/test-suite/errors/pp_missing_enddef.stderr index bb4ea3c75..c461699e6 100644 --- a/Examples/test-suite/errors/pp_missing_enddef.stderr +++ b/Examples/test-suite/errors/pp_missing_enddef.stderr @@ -1 +1 @@ -pp_missing_enddef.i:EOF: Error: Missing %enddef for macro starting on line 3 +pp_missing_enddef.i:3: Error: Missing %enddef for macro starting here diff --git a/Examples/test-suite/errors/pp_missing_endif.stderr b/Examples/test-suite/errors/pp_missing_endif.stderr index 0bbfad7f2..4db4021aa 100644 --- a/Examples/test-suite/errors/pp_missing_endif.stderr +++ b/Examples/test-suite/errors/pp_missing_endif.stderr @@ -1 +1 @@ -pp_missing_endif.i:EOF: Error: Missing #endif for conditional starting on line 3 +pp_missing_endif.i:3: Error: Missing #endif for conditional starting here diff --git a/Examples/test-suite/errors/pp_missing_endoffile.i b/Examples/test-suite/errors/pp_missing_endoffile.i new file mode 100644 index 000000000..2074495a8 --- /dev/null +++ b/Examples/test-suite/errors/pp_missing_endoffile.i @@ -0,0 +1,7 @@ +%module xxx +/* %beginfile and %endoffile are internal directives inserted when %include is + * used. Users should never use them directly, but test coverage for this + * error message still seems useful to have. + */ +%includefile "dummy.i" %beginfile + diff --git a/Examples/test-suite/errors/pp_missing_endoffile.stderr b/Examples/test-suite/errors/pp_missing_endoffile.stderr new file mode 100644 index 000000000..7269f2e92 --- /dev/null +++ b/Examples/test-suite/errors/pp_missing_endoffile.stderr @@ -0,0 +1 @@ +pp_missing_endoffile.i:6: Error: Missing %endoffile for file inclusion block starting here diff --git a/Examples/test-suite/errors/pp_missing_rblock.stderr b/Examples/test-suite/errors/pp_missing_rblock.stderr index 8f4a54c0a..f00457d73 100644 --- a/Examples/test-suite/errors/pp_missing_rblock.stderr +++ b/Examples/test-suite/errors/pp_missing_rblock.stderr @@ -1 +1 @@ -pp_missing_rblock.i:EOF: Error: Unterminated %{ ... %} block starting on line 3 +pp_missing_rblock.i:3: Error: Unterminated %{ ... %} block diff --git a/Examples/test-suite/errors/pp_unknowndirective.i b/Examples/test-suite/errors/pp_unknowndirective.i new file mode 100644 index 000000000..659a997d3 --- /dev/null +++ b/Examples/test-suite/errors/pp_unknowndirective.i @@ -0,0 +1,7 @@ +%module xxx + +/* This used to give the rather cryptic "Syntax error in input(1)." prior to + * SWIG 3.0.4. This testcase checks that the improved message is actually + * issued. + */ +%remane("typo") tyop; diff --git a/Examples/test-suite/errors/pp_unknowndirective.stderr b/Examples/test-suite/errors/pp_unknowndirective.stderr new file mode 100644 index 000000000..d0d5e249f --- /dev/null +++ b/Examples/test-suite/errors/pp_unknowndirective.stderr @@ -0,0 +1 @@ +pp_unknowndirective.i:7: Error: Unknown directive '%remane'. diff --git a/Examples/test-suite/errors/pp_unknowndirective2.i b/Examples/test-suite/errors/pp_unknowndirective2.i new file mode 100644 index 000000000..889e6c5b2 --- /dev/null +++ b/Examples/test-suite/errors/pp_unknowndirective2.i @@ -0,0 +1,11 @@ +%module xxx + +#ifdef FOO +long long i; +/* Check we get an error for an unknown directive (this should be #elif). + * Unknown directives were silently ignored by SWIG < 3.0.3. */ +#elsif defined(BAR) +long i; +#else +int i; +#endif diff --git a/Examples/test-suite/errors/pp_unknowndirective2.stderr b/Examples/test-suite/errors/pp_unknowndirective2.stderr new file mode 100644 index 000000000..70afa670c --- /dev/null +++ b/Examples/test-suite/errors/pp_unknowndirective2.stderr @@ -0,0 +1 @@ +pp_unknowndirective2.i:7: Error: Unknown SWIG preprocessor directive: elsif (if this is a block of target language code, delimit it with %{ and %}) diff --git a/Examples/test-suite/errors/pp_unterm_char.stderr b/Examples/test-suite/errors/pp_unterm_char.stderr index 4386e933d..147e3859d 100644 --- a/Examples/test-suite/errors/pp_unterm_char.stderr +++ b/Examples/test-suite/errors/pp_unterm_char.stderr @@ -1 +1 @@ -pp_unterm_char.i:EOF: Error: Unterminated character constant starting at line 4 +pp_unterm_char.i:4: Error: Unterminated character constant diff --git a/Examples/test-suite/errors/pp_unterm_comment.stderr b/Examples/test-suite/errors/pp_unterm_comment.stderr index 4ff34230c..ab1edac14 100644 --- a/Examples/test-suite/errors/pp_unterm_comment.stderr +++ b/Examples/test-suite/errors/pp_unterm_comment.stderr @@ -1 +1 @@ -pp_unterm_comment.i:EOF: Error: Unterminated comment starting on line 3 +pp_unterm_comment.i:3: Error: Unterminated comment diff --git a/Examples/test-suite/errors/pp_unterm_string.stderr b/Examples/test-suite/errors/pp_unterm_string.stderr index 16b4034f3..14e110ebb 100644 --- a/Examples/test-suite/errors/pp_unterm_string.stderr +++ b/Examples/test-suite/errors/pp_unterm_string.stderr @@ -1 +1 @@ -pp_unterm_string.i:EOF: Error: Unterminated string constant starting at line 4 +pp_unterm_string.i:4: Error: Unterminated string constant diff --git a/Examples/test-suite/errors/pp_unterminated_block.i b/Examples/test-suite/errors/pp_unterminated_block.i new file mode 100644 index 000000000..99f5f0bc2 --- /dev/null +++ b/Examples/test-suite/errors/pp_unterminated_block.i @@ -0,0 +1,5 @@ +%module xxx + +%{ +int foo(int x); + diff --git a/Examples/test-suite/errors/pp_unterminated_block.stderr b/Examples/test-suite/errors/pp_unterminated_block.stderr new file mode 100644 index 000000000..03c16a45f --- /dev/null +++ b/Examples/test-suite/errors/pp_unterminated_block.stderr @@ -0,0 +1 @@ +pp_unterminated_block.i:3: Error: Unterminated %{ ... %} block |