diff options
author | grbd <garlicbready@googlemail.com> | 2017-06-27 21:24:55 (GMT) |
---|---|---|
committer | grbd <garlicbready@googlemail.com> | 2017-06-27 21:24:55 (GMT) |
commit | fe8669695dad03dfe0c9e8b322d3ec86d8301229 (patch) | |
tree | 1e620107f8be3b864ee4af3092bc0912046d9afe /test | |
parent | e8f5ebd9ec594fa09dd691750abc96220cc1a83b (diff) | |
download | SCons-fe8669695dad03dfe0c9e8b322d3ec86d8301229.zip SCons-fe8669695dad03dfe0c9e8b322d3ec86d8301229.tar.gz SCons-fe8669695dad03dfe0c9e8b322d3ec86d8301229.tar.bz2 |
Added support for relative imports within tools for python3 and tests for relative imports
Diffstat (limited to 'test')
10 files changed, 95 insertions, 0 deletions
diff --git a/test/toolpath/relative_import/image/SConstruct b/test/toolpath/relative_import/image/SConstruct new file mode 100644 index 0000000..6156929 --- /dev/null +++ b/test/toolpath/relative_import/image/SConstruct @@ -0,0 +1,10 @@ +env = Environment(tools=['TestTool1', 'TestTool1.TestTool1_2'], toolpath=['tools'])
+
+# Test a relative import within the root of the tools directory
+print("env['TestTool1'] =", env.get('TestTool1'))
+print("env['TestTool1_1'] =", env.get('TestTool1_1'))
+
+# Test a relative import within a sub dir
+print("env['TestTool1_2'] =", env.get('TestTool1_2'))
+print("env['TestTool1_2_1'] =", env.get('TestTool1_2_1'))
+print("env['TestTool1_2_2'] =", env.get('TestTool1_2_2'))
diff --git a/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_1.py b/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_1.py new file mode 100644 index 0000000..4c9a7bc --- /dev/null +++ b/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_1.py @@ -0,0 +1,4 @@ +def generate(env):
+ env['TestTool1_1'] = 1
+def exists(env):
+ return 1
diff --git a/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_2/TestTool1_2_1.py b/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_2/TestTool1_2_1.py new file mode 100644 index 0000000..e65f8cd --- /dev/null +++ b/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_2/TestTool1_2_1.py @@ -0,0 +1,4 @@ +def generate(env):
+ env['TestTool1_2_1'] = 1
+def exists(env):
+ return 1
diff --git a/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_2/TestTool1_2_2/__init__.py b/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_2/TestTool1_2_2/__init__.py new file mode 100644 index 0000000..463baee --- /dev/null +++ b/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_2/TestTool1_2_2/__init__.py @@ -0,0 +1,4 @@ +def generate(env):
+ env['TestTool1_2_2'] = 1
+def exists(env):
+ return 1
diff --git a/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_2/TestTool1_2_2/sconstest.skip b/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_2/TestTool1_2_2/sconstest.skip new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_2/TestTool1_2_2/sconstest.skip diff --git a/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_2/__init__.py b/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_2/__init__.py new file mode 100644 index 0000000..8bd698f --- /dev/null +++ b/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_2/__init__.py @@ -0,0 +1,11 @@ +from . import TestTool1_2_1
+from . import TestTool1_2_2
+
+def generate(env):
+ env['TestTool1_2'] = 1
+ TestTool1_2_1.generate(env)
+ TestTool1_2_2.generate(env)
+def exists(env):
+ TestTool1_2_1.exists(env)
+ TestTool1_2_2.exists(env)
+ return 1
diff --git a/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_2/sconstest.skip b/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_2/sconstest.skip new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/toolpath/relative_import/image/tools/TestTool1/TestTool1_2/sconstest.skip diff --git a/test/toolpath/relative_import/image/tools/TestTool1/__init__.py b/test/toolpath/relative_import/image/tools/TestTool1/__init__.py new file mode 100644 index 0000000..d5510d2 --- /dev/null +++ b/test/toolpath/relative_import/image/tools/TestTool1/__init__.py @@ -0,0 +1,9 @@ +from . import TestTool1_1
+
+def generate(env):
+ env['TestTool1'] = 1
+ # Include another tool within the same directory
+ TestTool1_1.generate(env)
+def exists(env):
+ TestTool1_1.exists(env)
+ return 1
diff --git a/test/toolpath/relative_import/image/tools/TestTool1/sconstest.skip b/test/toolpath/relative_import/image/tools/TestTool1/sconstest.skip new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/toolpath/relative_import/image/tools/TestTool1/sconstest.skip diff --git a/test/toolpath/relative_import/relative_import.py b/test/toolpath/relative_import/relative_import.py new file mode 100644 index 0000000..8fa2f62 --- /dev/null +++ b/test/toolpath/relative_import/relative_import.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os.path
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.dir_fixture('image')
+
+test.run(arguments = '.', stdout = """\
+scons: Reading SConscript files ...
+env['TestTool1'] = 1
+env['TestTool1_1'] = 1
+env['TestTool1_2'] = 1
+env['TestTool1_2_1'] = 1
+env['TestTool1_2_2'] = 1
+scons: done reading SConscript files.
+scons: Building targets ...
+scons: `.' is up to date.
+scons: done building targets.
+""")
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
|