On 5 January 2013 00:31, Paweł Tomulik <ptomulik@meil.pw.edu.pl> wrote:
Hi all,

I've faced some bugs in swig that make me unable to progress with
one of my projects and I'm currently working on patches (two of
them are already proposed as pull requests on github).

For one bug (https://sourceforge.net/p/swig/bugs/1297/),
the test cases consist of few %module's, and the resultant
python code is structured such that it contains python modules
within packages and subpackages.

For example, one of my current mini-projects used to replicate the bug
has structure:

case/
| runme.py
|
+ P1/
   |__init__.py
   | foo.hpp
   | Foo_Mod.py
|
   + S1/
       __init__.py
       bar.hpp
       Bar_Mod.i

Is there a way to map such mini-project to a test case that could fit to the
swig's testing framework (under Examples/test-suite/.. or in other right
place) ?

This is a little unusual. There are some %import testcases you could look at, but they use one directory for the inputs which is what we have managed to do up till now. These are the 'MULTI_CPP_TEST_CASES" in common.mk and correlate to:

$ grep -l "%import" *
clientdata_prop_b.i
import_nomodule.i
imports_a.i
imports_b.i
import_stl_b.i
mod_b.i
multi_import_a.i
packageoption_c.i
template_typedef_import.i

Note that the header files they import are prefixed by the testcase name by convention.

There is also inctest.i which is the only testcase that uses a directory hierarchy like you need:

$ find testdir
testdir
testdir/test.i
testdir/subdir1
testdir/subdir1/subinc1.i
testdir/subdir1/hello.i
testdir/subdir1/imports.i
testdir/subdir2
testdir/subdir2/hello.i
testdir/subdir2/imports.i
testdir/subdir2/subinc2.i

I suggest we change testdir to have testcase names as the first subdirectory so change testinc to have:

testdir
testdir/inctest/test.i
testdir/inctest/subdir1
testdir/inctest/subdir1/subinc1.i
testdir/inctest/subdir1/hello.i
testdir/inctest/subdir1/imports.i
testdir/inctest/subdir2
testdir/inctest/subdir2/hello.i
testdir/inctest/subdir2/imports.i
testdir/inctest/subdir2/subinc2.i

then you can create a new directory named after your testcase under testdir.

BTW, if you additional or non-standard command line arguments for the testcase, these can be added per testcase, see the "Custom tests" in csharp/Makefile and java/Makefile. Probably the same approach can be used in common.mk if targeting all languages.

William