Thrift: Support for explicit Python module declaration.
Summary:
Previously, Thrift used the name of the .thrift file as the python module name.
This wasn't very flexible. Now the python module can be explicitly declared.
Also, there was no need for t_py_generator to inherit from t_oop_generator.
Reviewed By: mcslee
Test Plan:
cd test/py/explicit_module
./runtest.sh
Revert Plan: ok
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665234 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/py/explicit_module/runtest.sh b/test/py/explicit_module/runtest.sh
new file mode 100755
index 0000000..8659210
--- /dev/null
+++ b/test/py/explicit_module/runtest.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+rm -rf gen-py
+../../../compiler/cpp/thrift -py test1.thrift || exit 1
+../../../compiler/cpp/thrift -py test2.thrift || exit 1
+PYTHONPATH=./gen-py python -c 'import foo.bar.baz' || exit 1
+PYTHONPATH=./gen-py python -c 'import test2' || exit 1
+PYTHONPATH=./gen-py python -c 'import test1' &>/dev/null && exit 1 # Should fail.
+cp -r gen-py simple
+../../../compiler/cpp/thrift -r -py test2.thrift || exit 1
+PYTHONPATH=./gen-py python -c 'import test2' || exit 1
+diff -ur simple gen-py > thediffs
+file thediffs | grep -s -q empty || exit 1
+rm -rf simple thediffs
+echo 'All tests pass!'
diff --git a/test/py/explicit_module/test1.thrift b/test/py/explicit_module/test1.thrift
new file mode 100644
index 0000000..316a173
--- /dev/null
+++ b/test/py/explicit_module/test1.thrift
@@ -0,0 +1,5 @@
+py_module foo.bar.baz
+
+struct astruct {
+ 1: i32 how_unoriginal;
+}
diff --git a/test/py/explicit_module/test2.thrift b/test/py/explicit_module/test2.thrift
new file mode 100644
index 0000000..fd5712e
--- /dev/null
+++ b/test/py/explicit_module/test2.thrift
@@ -0,0 +1,5 @@
+include "test1.thrift"
+
+struct another {
+ 1: test1.astruct something;
+}