diff options
author | grbd <garlicbready@googlemail.com> | 2017-06-19 19:02:42 (GMT) |
---|---|---|
committer | grbd <garlicbready@googlemail.com> | 2017-06-19 19:02:42 (GMT) |
commit | 7d06499e935343a60817c44169b0c4d15c6e72da (patch) | |
tree | 61021beebec66c537ce3344a6404424bee3332ba /test | |
parent | a25367b4f6151a7888b9446e45e234ed84c9a163 (diff) | |
download | SCons-7d06499e935343a60817c44169b0c4d15c6e72da.zip SCons-7d06499e935343a60817c44169b0c4d15c6e72da.tar.gz SCons-7d06499e935343a60817c44169b0c4d15c6e72da.tar.bz2 |
Added tests for nested / namespaced tools
Diffstat (limited to 'test')
-rw-r--r-- | test/toolpath/nested.py | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/test/toolpath/nested.py b/test/toolpath/nested.py new file mode 100644 index 0000000..88104a4 --- /dev/null +++ b/test/toolpath/nested.py @@ -0,0 +1,140 @@ +#!/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.write('SConstruct', """ +# Test where tools are located under site_scons/site_tools +env1 = Environment(tools=['subdir1.Site_TestTool1', 'subdir1.subdir2.Site_TestTool2', 'subdir1.Site_TestTool3']) +print("env1['Site_TestTool1'] =", env1.get('Site_TestTool1')) +print("env1['Site_TestTool2'] =", env1.get('Site_TestTool2')) +print("env1['Site_TestTool3'] =", env1.get('Site_TestTool3')) + +# Test where toolpath is set in the env constructor +env2 = Environment(tools=['subdir1.Toolpath_TestTool1', 'subdir1.subdir2.Toolpath_TestTool2', 'subdir1.Toolpath_TestTool3'], toolpath=['tools']) +print("env2['Toolpath_TestTool1'] =", env2.get('Toolpath_TestTool1')) +print("env2['Toolpath_TestTool2'] =", env2.get('Toolpath_TestTool2')) +print("env2['Toolpath_TestTool3'] =", env2.get('Toolpath_TestTool3')) + +base = Environment(tools=[], toolpath=['tools']) +derived = base.Clone(tools=['subdir1.Toolpath_TestTool1']) +print("derived['Toolpath_TestTool1'] =", derived.get('Toolpath_TestTool1')) +""") + + +# Test where tools are located under site_scons/site_tools +test.subdir('site_scons', ['site_scons', 'site_tools']) + +# One level down - site_scons/site_tools +test.subdir(['site_scons', 'site_tools', 'subdir1']) +test.write(['site_scons', 'site_tools', 'subdir1', '__init__.py'], '') +test.write(['site_scons', 'site_tools', 'subdir1', 'Site_TestTool1.py'], r"""\ +def generate(env): + env['Site_TestTool1'] = 1 +def exists(env): + return 1 +""") + +# Two levels down - site_scons/site_tools +test.subdir(['site_scons', 'site_tools', 'subdir1', 'subdir2']) +test.write(['site_scons', 'site_tools', 'subdir1', 'subdir2', '__init__.py'], '') +test.write(['site_scons', 'site_tools', 'subdir1', 'subdir2', 'Site_TestTool2.py'], r"""\ +def generate(env): + env['Site_TestTool2'] = 1 +def exists(env): + return 1 +""") + +# Two levels down - site_scons/site_tools - using __init__.py within a directory +test.subdir(['site_scons', 'site_tools', 'subdir1', 'Site_TestTool3']) +test.write(['site_scons', 'site_tools', 'subdir1', 'Site_TestTool3', '__init__.py'], r"""\ +def generate(env): + env['Site_TestTool3'] = 1 +def exists(env): + return 1 +""") + + +# Test where toolpath is set in the env constructor +test.subdir('tools') + +# One level down - tools +test.subdir(['tools', 'subdir1']) +test.write(['tools', 'subdir1', '__init__.py'], '') +test.write(['tools', 'subdir1', 'Toolpath_TestTool1.py'], r"""\ +def generate(env): + env['Toolpath_TestTool1'] = 1 +def exists(env): + return 1 +""") + +# Two levels down - tools +test.subdir(['tools', 'subdir1', 'subdir2']) +test.write(['tools', 'subdir1', 'subdir2', '__init__.py'], '') +test.write(['tools', 'subdir1', 'subdir2', 'Toolpath_TestTool2.py'], r"""\ +def generate(env): + env['Toolpath_TestTool2'] = 1 +def exists(env): + return 1 +""") + +# Two levels down - tools - using __init__.py within a directory +test.subdir(['tools', 'subdir1', 'Toolpath_TestTool3']) +test.write(['tools', 'subdir1', 'Toolpath_TestTool3', '__init__.py'], r"""\ +def generate(env): + env['Toolpath_TestTool3'] = 1 +def exists(env): + return 1 +""") + + + +test.run(arguments = '.', stdout = """\ +scons: Reading SConscript files ... +env1['Site_TestTool1'] = 1 +env1['Site_TestTool2'] = 1 +env1['Site_TestTool3'] = 1 +env2['Toolpath_TestTool1'] = 1 +env2['Toolpath_TestTool2'] = 1 +env2['Toolpath_TestTool3'] = 1 +derived['Toolpath_TestTool1'] = 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: |