summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorgrbd <garlicbready@googlemail.com>2017-08-03 14:53:20 (GMT)
committergrbd <garlicbready@googlemail.com>2017-08-03 14:53:20 (GMT)
commit1849ff611b22a55b8933dc9f05db66114e34cd14 (patch)
treed149ae7ee604fbb9200b06ca96ebe49bfdb5e0f3 /test
parente2f981db1c087c2d684cfd4ace988a4e173d975d (diff)
downloadSCons-1849ff611b22a55b8933dc9f05db66114e34cd14.zip
SCons-1849ff611b22a55b8933dc9f05db66114e34cd14.tar.gz
SCons-1849ff611b22a55b8933dc9f05db66114e34cd14.tar.bz2
Added support for a PyPackageDir function
Diffstat (limited to 'test')
-rw-r--r--test/Dir/PyPackageDir/PyPackageDir.py56
-rw-r--r--test/Dir/PyPackageDir/image/SConstruct29
-rw-r--r--test/Dir/PyPackageDir/image/sconstest.skip0
-rw-r--r--test/Dir/PyPackageDir/image/syspath/sconstest.skip0
-rw-r--r--test/Dir/PyPackageDir/image/syspath/submod1/__init__.py0
-rw-r--r--test/Dir/PyPackageDir/image/syspath/submod1/sconstest.skip0
-rw-r--r--test/Dir/PyPackageDir/image/syspath/submod1/submod2/__init__.py0
-rw-r--r--test/Dir/PyPackageDir/image/syspath/submod1/submod2/sconstest.skip0
-rw-r--r--test/Dir/PyPackageDir/image/syspath/submod1/submod2/testmod4.py0
-rw-r--r--test/Dir/PyPackageDir/image/syspath/submod1/testmod3.py0
-rw-r--r--test/Dir/PyPackageDir/image/syspath/testmod1/__init__.py0
-rw-r--r--test/Dir/PyPackageDir/image/syspath/testmod1/sconstest.skip0
-rw-r--r--test/Dir/PyPackageDir/image/syspath/testmod2.py0
-rw-r--r--test/toolpath/nested/image/SConstruct7
-rw-r--r--test/toolpath/nested/nested.py3
15 files changed, 95 insertions, 0 deletions
diff --git a/test/Dir/PyPackageDir/PyPackageDir.py b/test/Dir/PyPackageDir/PyPackageDir.py
new file mode 100644
index 0000000..b215c7b
--- /dev/null
+++ b/test/Dir/PyPackageDir/PyPackageDir.py
@@ -0,0 +1,56 @@
+#!/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 ...
+Test identification of directory for a given python package
+testmod1
+.
+submod1
+submod1/submod2
+Test parameter substitution
+submod1/submod2
+submod1/submod2
+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:
diff --git a/test/Dir/PyPackageDir/image/SConstruct b/test/Dir/PyPackageDir/image/SConstruct
new file mode 100644
index 0000000..90d2a80
--- /dev/null
+++ b/test/Dir/PyPackageDir/image/SConstruct
@@ -0,0 +1,29 @@
+import sys, os
+
+oldsyspath = sys.path
+dir_path = Dir('.').srcnode().abspath
+dir_path = os.path.join(dir_path, 'syspath')
+sys.path.append(dir_path)
+
+def TestPyPackageDir(env, modname):
+ packagepath = env.PyPackageDir(modname).abspath
+ # Convert from an absolute path back to a relative one for testing
+ commonprefix = os.path.commonprefix([dir_path, packagepath])
+ relpath = os.path.relpath(packagepath, commonprefix)
+ relpath = relpath.replace(os.sep, '/')
+ print(relpath)
+
+print("Test identification of directory for a given python package")
+env = Environment()
+TestPyPackageDir(env, 'testmod1')
+TestPyPackageDir(env, 'testmod2')
+TestPyPackageDir(env, 'submod1.testmod3')
+TestPyPackageDir(env, 'submod1.submod2.testmod4')
+
+print("Test parameter substitution")
+env = Environment(FOO = 'submod1.submod2.testmod4')
+TestPyPackageDir(env, '${FOO}')
+env = Environment(FOO = 'submod1.submod2', BAR = 'testmod4')
+TestPyPackageDir(env, '${FOO}.${BAR}')
+
+sys.path = oldsyspath
diff --git a/test/Dir/PyPackageDir/image/sconstest.skip b/test/Dir/PyPackageDir/image/sconstest.skip
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Dir/PyPackageDir/image/sconstest.skip
diff --git a/test/Dir/PyPackageDir/image/syspath/sconstest.skip b/test/Dir/PyPackageDir/image/syspath/sconstest.skip
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Dir/PyPackageDir/image/syspath/sconstest.skip
diff --git a/test/Dir/PyPackageDir/image/syspath/submod1/__init__.py b/test/Dir/PyPackageDir/image/syspath/submod1/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Dir/PyPackageDir/image/syspath/submod1/__init__.py
diff --git a/test/Dir/PyPackageDir/image/syspath/submod1/sconstest.skip b/test/Dir/PyPackageDir/image/syspath/submod1/sconstest.skip
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Dir/PyPackageDir/image/syspath/submod1/sconstest.skip
diff --git a/test/Dir/PyPackageDir/image/syspath/submod1/submod2/__init__.py b/test/Dir/PyPackageDir/image/syspath/submod1/submod2/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Dir/PyPackageDir/image/syspath/submod1/submod2/__init__.py
diff --git a/test/Dir/PyPackageDir/image/syspath/submod1/submod2/sconstest.skip b/test/Dir/PyPackageDir/image/syspath/submod1/submod2/sconstest.skip
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Dir/PyPackageDir/image/syspath/submod1/submod2/sconstest.skip
diff --git a/test/Dir/PyPackageDir/image/syspath/submod1/submod2/testmod4.py b/test/Dir/PyPackageDir/image/syspath/submod1/submod2/testmod4.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Dir/PyPackageDir/image/syspath/submod1/submod2/testmod4.py
diff --git a/test/Dir/PyPackageDir/image/syspath/submod1/testmod3.py b/test/Dir/PyPackageDir/image/syspath/submod1/testmod3.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Dir/PyPackageDir/image/syspath/submod1/testmod3.py
diff --git a/test/Dir/PyPackageDir/image/syspath/testmod1/__init__.py b/test/Dir/PyPackageDir/image/syspath/testmod1/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Dir/PyPackageDir/image/syspath/testmod1/__init__.py
diff --git a/test/Dir/PyPackageDir/image/syspath/testmod1/sconstest.skip b/test/Dir/PyPackageDir/image/syspath/testmod1/sconstest.skip
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Dir/PyPackageDir/image/syspath/testmod1/sconstest.skip
diff --git a/test/Dir/PyPackageDir/image/syspath/testmod2.py b/test/Dir/PyPackageDir/image/syspath/testmod2.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Dir/PyPackageDir/image/syspath/testmod2.py
diff --git a/test/toolpath/nested/image/SConstruct b/test/toolpath/nested/image/SConstruct
index 211a0d7..78ae21d 100644
--- a/test/toolpath/nested/image/SConstruct
+++ b/test/toolpath/nested/image/SConstruct
@@ -55,4 +55,11 @@ print("env3['Toolpath_TestTool1_2'] =", env3.get('Toolpath_TestTool1_2'))
print("env3['Toolpath_TestTool2_1'] =", env3.get('Toolpath_TestTool2_1'))
print("env3['Toolpath_TestTool2_2'] =", env3.get('Toolpath_TestTool2_2'))
+
+print('Test using PyPackageDir')
+toollist = ['Toolpath_TestTool2_1', 'Toolpath_TestTool2_2']
+env4 = Environment(tools = toollist, toolpath = [PyPackageDir('tools_example.subdir1.subdir2')])
+print("env4['Toolpath_TestTool2_1'] =", env4.get('Toolpath_TestTool2_1'))
+print("env4['Toolpath_TestTool2_2'] =", env4.get('Toolpath_TestTool2_2'))
+
sys.path = oldsyspath
diff --git a/test/toolpath/nested/nested.py b/test/toolpath/nested/nested.py
index a736d58..df2ba07 100644
--- a/test/toolpath/nested/nested.py
+++ b/test/toolpath/nested/nested.py
@@ -57,6 +57,9 @@ env3['Toolpath_TestTool1_1'] = 1
env3['Toolpath_TestTool1_2'] = 1
env3['Toolpath_TestTool2_1'] = 1
env3['Toolpath_TestTool2_2'] = 1
+Test using PyPackageDir
+env4['Toolpath_TestTool2_1'] = 1
+env4['Toolpath_TestTool2_2'] = 1
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.