diff options
author | Steven Knight <knight@baldmt.com> | 2008-04-17 06:35:51 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2008-04-17 06:35:51 (GMT) |
commit | 12ced93c8d443babcf3ba0c0a3503ed6a8fed2d9 (patch) | |
tree | 340da0ff0ef5002982fcfd5ee2a2a5e34a4bf5e0 /test/Deprecated | |
parent | f80d3313d70eace1274f0b5ffbdc53b19acf8250 (diff) | |
download | SCons-12ced93c8d443babcf3ba0c0a3503ed6a8fed2d9.zip SCons-12ced93c8d443babcf3ba0c0a3503ed6a8fed2d9.tar.gz SCons-12ced93c8d443babcf3ba0c0a3503ed6a8fed2d9.tar.bz2 |
Merged revisions 2725-2865 via svnmerge from
http://scons.tigris.org/svn/scons/branches/core
........
r2731 | stevenknight | 2008-04-01 09:22:37 -0700 (Tue, 01 Apr 2008) | 4 lines
Fix test/Interactive/version.py, which still had the old hard-coded
Copyright string, by moving the test copy of the Copyright string
into QMTest/TestSCons.py, where it's available to all test scripts.
........
r2732 | stevenknight | 2008-04-02 13:28:32 -0700 (Wed, 02 Apr 2008) | 3 lines
Issues 317, 323, 329: Ignore the -d, -e and -w options, which we're
not going to implement.
........
r2734 | stevenknight | 2008-04-05 07:50:49 -0700 (Sat, 05 Apr 2008) | 2 lines
Fix bootstrap.py for pre-2.3 versions of Python, which don't have __file__.
........
r2735 | stevenknight | 2008-04-05 07:54:44 -0700 (Sat, 05 Apr 2008) | 2 lines
Fix the non-breaking-hyphen regular expression(s) for Python 1.5.
........
r2736 | garyo | 2008-04-05 19:15:52 -0700 (Sat, 05 Apr 2008) | 1 line
Added Users Guide section for AddMethod.
........
r2737 | stevenknight | 2008-04-08 09:43:31 -0700 (Tue, 08 Apr 2008) | 3 lines
Don't raise strings as exceptions in the exception-handling unit tests.
That's now deprecated Python behavior.
........
r2738 | stevenknight | 2008-04-08 10:36:00 -0700 (Tue, 08 Apr 2008) | 5 lines
Address a serious inefficiency in Java builds by moving the pre-build
check for whether source files exist from the Node class to the Executor
class, so we only have to perform the check once when building a whole
bunch of targets from a whole bunch of sources.
........
r2739 | stevenknight | 2008-04-08 13:53:44 -0700 (Tue, 08 Apr 2008) | 2 lines
Add a backwards-compatibility version of the "itertools" module.
........
r2740 | stevenknight | 2008-04-08 14:12:05 -0700 (Tue, 08 Apr 2008) | 2 lines
Issue 1961: speed up SCons.Util.to_String*() functions. (Benoit Belley)
........
r2741 | stevenknight | 2008-04-08 14:15:36 -0700 (Tue, 08 Apr 2008) | 2 lines
Use the itertools.izip() method for some key Node.FS methods. (Benoit Belley)
........
r2742 | stevenknight | 2008-04-08 14:35:35 -0700 (Tue, 08 Apr 2008) | 2 lines
Issues 1961: use izip() instead of zip() where possible (Benoit Belley)
........
r2743 | stevenknight | 2008-04-08 14:48:08 -0700 (Tue, 08 Apr 2008) | 3 lines
Issue 1961: more efficient get_contents() implementation for Python
function Actions. (Benoit Belley)
........
r2744 | stevenknight | 2008-04-08 17:55:30 -0700 (Tue, 08 Apr 2008) | 3 lines
Issue 1961: make SCons.Node.* state variables global in Taskmaster.py so
we avoid unneceesary attribute fetches. (Benoit Belley)
........
r2745 | stevenknight | 2008-04-08 20:40:31 -0700 (Tue, 08 Apr 2008) | 2 lines
Issue 1961: Optimize the code in Node.get_binfo(). (Benoit Belley)
........
r2746 | stevenknight | 2008-04-08 21:05:17 -0700 (Tue, 08 Apr 2008) | 3 lines
Issue 1961: Enhance the backwards-compatibility sets() module with the
ability to compare sets. (Benoit Belley)
........
r2747 | stevenknight | 2008-04-08 22:11:20 -0700 (Tue, 08 Apr 2008) | 2 lines
Issue 1961: Optimize Executor.scan(). (Benoit Belley)
........
r2748 | stevenknight | 2008-04-08 22:17:55 -0700 (Tue, 08 Apr 2008) | 3 lines
Python 1.5 compatibility: use for p in paths.keys() for dictionaries.
(Benoit Belley)
........
r2749 | stevenknight | 2008-04-08 22:54:02 -0700 (Tue, 08 Apr 2008) | 10 lines
Issue 1961: additional build optimizations:
-- Make taskmastertrace output more useful and readable.
-- Move dependency cycle checking to avoid re-doing it.
-- Have Nodes use sets, not dictionaries, to track various things.
-- Eliminate intermediate function calls from fetching Node children.
-- Add a Task.needs_execute() method to avoid doing that check over and
over as part of needs_execute().
-- Remove the unused Node.found_includes attribute.
(Benoit Belley)
........
r2750 | stevenknight | 2008-04-09 14:47:44 -0700 (Wed, 09 Apr 2008) | 4 lines
Make target Java .class files depend *only* on the input .java files as
their sources when determining if they require rebuilding. This eliminates
O(NxM) checking for every single edge in a big, overly-connected DAG mesh.
........
r2751 | stevenknight | 2008-04-09 16:58:41 -0700 (Wed, 09 Apr 2008) | 2 lines
Remove 0.95 and 0.96* release notes.
........
r2752 | stevenknight | 2008-04-10 02:24:50 -0700 (Thu, 10 Apr 2008) | 2 lines
Issue 1956: Fix --debug=stree printing its tree twice. (Benoit Belley)
........
r2753 | stevenknight | 2008-04-10 02:33:28 -0700 (Thu, 10 Apr 2008) | 2 lines
Issue 1896: Add support for the GDC D language compiler. (Matthew Wesley)
........
r2754 | stevenknight | 2008-04-10 02:39:24 -0700 (Thu, 10 Apr 2008) | 2 lines
Fix tabs.
........
r2755 | stevenknight | 2008-04-10 02:41:50 -0700 (Thu, 10 Apr 2008) | 3 lines
Issue 1964: Fix passing variable names in a list to Return() (as
already documented in the man page!) (Mike Wake)
........
r2756 | stevenknight | 2008-04-10 02:55:40 -0700 (Thu, 10 Apr 2008) | 2 lines
Support the ability to download 2.6 candidate releases (e.g. 2.6a2).
........
r2757 | stevenknight | 2008-04-10 02:58:35 -0700 (Thu, 10 Apr 2008) | 3 lines
Issue 1669: Fix the ability to use LoadableModule() under MinGW.
(Johan Boule)
........
r2758 | stevenknight | 2008-04-10 03:03:15 -0700 (Thu, 10 Apr 2008) | 3 lines
Update the test/Interactive/tree.py script for Benoit's fix to
remove duplicate tree printing.
........
r2759 | stevenknight | 2008-04-10 06:43:44 -0700 (Thu, 10 Apr 2008) | 3 lines
Fix Tool/dmd.py when no D compiler is installed -- we don't want to
search for a path if the result is None.
........
r2760 | GregNoel | 2008-04-10 15:30:34 -0700 (Thu, 10 Apr 2008) | 1 line
Issue 2009: separate Debug.caller() by functionality
........
r2761 | stevenknight | 2008-04-11 04:47:25 -0700 (Fri, 11 Apr 2008) | 3 lines
Issue 1882: Add the scons.bat directory to %PATH% so it can find python.exe.
(Anatoly Techtonik)
........
r2762 | stevenknight | 2008-04-11 09:15:22 -0700 (Fri, 11 Apr 2008) | 4 lines
Issues 1835,1901: fix the ability to list a source file multiple
times for a target by making sure we only store unique entries in the
.sconsign file.
........
r2763 | stevenknight | 2008-04-11 10:58:26 -0700 (Fri, 11 Apr 2008) | 4 lines
Issue 1882: Fix earlier patch to scons.bat by adding ~dp0;~dp0.. to
the front of %PATH%, and only executing endlocal on NT-based systems.
(Anatoly Techtonik)
........
r2764 | stevenknight | 2008-04-11 13:06:29 -0700 (Fri, 11 Apr 2008) | 4 lines
Add a Variables object and {Bool,Envum,List,Package,Path}Variable()
functions as a first step towards eventually deprecating the
Options object and {Bool,Envum,List,Package,Path}Option() functions.
........
r2765 | stevenknight | 2008-04-11 18:13:53 -0700 (Fri, 11 Apr 2008) | 3 lines
Issue 1962: Capture a test case for ListActions that contain a
command-line string containing unicode, and Python FunctionAction.
........
r2766 | stevenknight | 2008-04-11 22:03:14 -0700 (Fri, 11 Apr 2008) | 3 lines
Issue 1933: expect .py files generated by the SWIG -python option
to be in the same (sub)directory as the target.
........
r2767 | stevenknight | 2008-04-12 06:41:57 -0700 (Sat, 12 Apr 2008) | 2 lines
Remove the SCons.Options package in favor of the new SCons.Variables package.
........
r2768 | stevenknight | 2008-04-12 13:33:52 -0700 (Sat, 12 Apr 2008) | 5 lines
Issue 1971: Move the incorporation of $CCFLAGS and $SHCCFLAGS directly
into the C++ command lines (${SHCXX,CXX}COM) instead of through indirect
expansion of $CXXFLAGS and $SHCXXFLAGS. This requires removing -fPIC
from the default setting of $SHCXXFLAGS under the GNU toolchain.
........
r2769 | stevenknight | 2008-04-13 07:01:27 -0700 (Sun, 13 Apr 2008) | 3 lines
Fix __all__ definitions in the Variables/*Variable.py file that were
cause epydoc to blow up when generating developer documentation.
........
r2770 | stevenknight | 2008-04-13 11:47:49 -0700 (Sun, 13 Apr 2008) | 3 lines
Add variables= keyword argument to Environment() creation as a first
step towards deprecating options=.
........
r2771 | stevenknight | 2008-04-13 11:54:19 -0700 (Sun, 13 Apr 2008) | 2 lines
Correct underscore-instead-of-hyphen misspellings in option names.
........
r2772 | bdbaddog | 2008-04-13 17:39:21 -0700 (Sun, 13 Apr 2008) | 3 lines
Changes to fix 15 tests which were failing on cygwin.
........
r2773 | GregNoel | 2008-04-13 22:31:07 -0700 (Sun, 13 Apr 2008) | 1 line
Various fixes to tests on Darwin using 1.5.2
........
r2774 | stevenknight | 2008-04-14 15:00:44 -0700 (Mon, 14 Apr 2008) | 2 lines
Python 1.5.2 fix in new test/SWIG/subdir.py script (use the -classic option).
........
r2775 | belley | 2008-04-14 18:02:40 -0700 (Mon, 14 Apr 2008) | 32 lines
Dont use KeyboardInterrupt to stop a build! [Issue 1907]
SCons would often hang after pressing Ctrl-C. I started investigating and I
realized that most of the Python libraries are not really safe with respect to
asynchronous exceptions. Although,there are enough try/finally blocks to handle
exceptions thrown synchronously by the library code, the Python libraries are
not always protected against exceptions being thrown asynchronously, such as a
KeyboardInterrupt being thrown at a completely random location.
For example, the function Queue.empty() does not protect its mutex with a
try/finally block. If the KeyboardInterrupt exception gets thrown while the
mutex is held, any further attempt to access the Queue will lead to dead-lock
(explaining why SCons hangs sometimes after pressing CTRL-C). Even the
threading.Condition condition variables are not async-exception safe. It
therefore seems a lost battle to try to stop a build by raising an exception.
Instead, I have implemented a signal handler that tells the Jobs (and its
associated Taskmaster) to stop the build. I have been careful to wait after the
.sconsign file has been written back to re-install the default SIGINT signal
handler that raises a KeyboardInterrupt exception.
This patch is submitted against changeset 2773 of branches/core. The
regression test suite has been run on RHEL4 using Pyhon 2.5.1 and
1.5.2. My team has been using an SCons build with this patch for a
while now on Windows, Linux and OSX.
See:
http://scons.tigris.org/issues/show_bug.cgi?id=1907
Benoit Belley
........
r2777 | cournape | 2008-04-14 20:11:56 -0700 (Mon, 14 Apr 2008) | 3 lines
Initialized merge tracking via "svnmerge" with revisions "1-2776" from
http://scons.tigris.org/svn/scons/branches/fortran_refactor
........
r2788 | stevenknight | 2008-04-14 22:09:27 -0700 (Mon, 14 Apr 2008) | 2 lines
Fix the print the "script" line in the --version output.
........
r2789 | stevenknight | 2008-04-14 22:18:27 -0700 (Mon, 14 Apr 2008) | 2 lines
Add a __COPYRIGHT__ line.
........
r2790 | stevenknight | 2008-04-14 22:20:39 -0700 (Mon, 14 Apr 2008) | 3 lines
Issue 2008: in checkpoint releases, use a '.' to separate (e.g.) 0.98.0
from 0d20080414.
........
r2817 | belley | 2008-04-15 06:44:21 -0700 (Tue, 15 Apr 2008) | 13 lines
TestSCons.up_to_date() should use match_re_dotall
I changed TestSCons.up_to_date() to use match_re_dotall instead of
match_exact. This is necessary so that I can call up_to_date() with
the TestSCons.deprecated_python_expr error message in one of my test.
Note that TestSCons.not_up_to_date() is already using match_re_dotall.
Ran the test suite on both Python 2.5.1 and 1.5.2.
Benoit
........
r2818 | belley | 2008-04-15 12:10:52 -0700 (Tue, 15 Apr 2008) | 10 lines
Improved the multiple-parents.py test to also tests the following
cases:
d) Some children are ignored
e) Some children are pre-requesites
f) Some sources are missing
The test still passes. No extra bug were found.
........
r2850 | stevenknight | 2008-04-16 11:15:24 -0700 (Wed, 16 Apr 2008) | 4 lines
Fix problems with the __del__() method referencing other module functions
through global variables, which can get deleted out from under us at
shutdown.
........
r2851 | stevenknight | 2008-04-16 11:17:07 -0700 (Wed, 16 Apr 2008) | 4 lines
Fix use of --interactive with -u/-U/-D and VariantDir() by making the
method that cleans Node states between interactive commands aware of
the alter_targets() method that tells us about an associated VariantDir().
........
Diffstat (limited to 'test/Deprecated')
-rw-r--r-- | test/Deprecated/Copy-Method.py (renamed from test/Deprecated/Copy.py) | 0 | ||||
-rw-r--r-- | test/Deprecated/Options/BoolOption.py | 87 | ||||
-rw-r--r-- | test/Deprecated/Options/EnumOption.py | 102 | ||||
-rw-r--r-- | test/Deprecated/Options/ListOption.py | 175 | ||||
-rw-r--r-- | test/Deprecated/Options/Options.py | 364 | ||||
-rw-r--r-- | test/Deprecated/Options/PackageOption.py | 89 | ||||
-rw-r--r-- | test/Deprecated/Options/PathOption.py | 285 | ||||
-rw-r--r-- | test/Deprecated/Options/chdir.py | 71 | ||||
-rw-r--r-- | test/Deprecated/Options/help.py | 151 | ||||
-rw-r--r-- | test/Deprecated/Options/import.py | 69 | ||||
-rw-r--r-- | test/Deprecated/debug-stree.py | 4 |
11 files changed, 1395 insertions, 2 deletions
diff --git a/test/Deprecated/Copy.py b/test/Deprecated/Copy-Method.py index f17fc9f..f17fc9f 100644 --- a/test/Deprecated/Copy.py +++ b/test/Deprecated/Copy-Method.py diff --git a/test/Deprecated/Options/BoolOption.py b/test/Deprecated/Options/BoolOption.py new file mode 100644 index 0000000..38b30d5 --- /dev/null +++ b/test/Deprecated/Options/BoolOption.py @@ -0,0 +1,87 @@ +#!/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__" + +""" +Test the BoolOption canned Option type. +""" + +import os.path +import string + +try: + True, False +except NameError: + True = (0 == 0) + False = (0 != 0) + +import TestSCons + +test = TestSCons.TestSCons() + +SConstruct_path = test.workpath('SConstruct') + +def check(expect): + result = string.split(test.stdout(), '\n') + assert result[1:len(expect)+1] == expect, (result[1:len(expect)+1], expect) + + + +test.write(SConstruct_path, """\ +from SCons.Options import BoolOption + +opts = Options(args=ARGUMENTS) +opts.AddOptions( + BoolOption('warnings', 'compilation with -Wall and similiar', 1), + BoolOption('profile', 'create profiling informations', 0), + ) + +env = Environment(options=opts) +Help(opts.GenerateHelpText(env)) + +print env['warnings'] +print env['profile'] + +Default(env.Alias('dummy', None)) +""") + + + +test.run() +check([str(True), str(False)]) + +test.run(arguments='warnings=0 profile=no profile=true') +check([str(False), str(True)]) + +expect_stderr = """ +scons: *** Error converting option: warnings +Invalid value for boolean option: irgendwas +""" + test.python_file_line(SConstruct_path, 9) + +test.run(arguments='warnings=irgendwas', stderr = expect_stderr, status=2) + + + +test.pass_test() diff --git a/test/Deprecated/Options/EnumOption.py b/test/Deprecated/Options/EnumOption.py new file mode 100644 index 0000000..610a485 --- /dev/null +++ b/test/Deprecated/Options/EnumOption.py @@ -0,0 +1,102 @@ +#!/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__" + +""" +Test the EnumOption canned Option type. +""" + +import os.path +import string + +import TestSCons + +test = TestSCons.TestSCons() + +SConstruct_path = test.workpath('SConstruct') + +def check(expect): + result = string.split(test.stdout(), '\n') + assert result[1:len(expect)+1] == expect, (result[1:len(expect)+1], expect) + + + +test.write(SConstruct_path, """\ +from SCons.Options import EnumOption + +list_of_libs = Split('x11 gl qt ical') + +opts = Options(args=ARGUMENTS) +opts.AddOptions( + EnumOption('debug', 'debug output and symbols', 'no', + allowed_values=('yes', 'no', 'full'), + map={}, ignorecase=0), # case sensitive + EnumOption('guilib', 'gui lib to use', 'gtk', + allowed_values=('motif', 'gtk', 'kde'), + map={}, ignorecase=1), # case insensitive + EnumOption('some', 'some option', 'xaver', + allowed_values=('xaver', 'eins'), + map={}, ignorecase=2), # make lowercase + ) + +env = Environment(options=opts) +Help(opts.GenerateHelpText(env)) + +print env['debug'] +print env['guilib'] +print env['some'] + +Default(env.Alias('dummy', None)) +""") + + +test.run(); check(['no', 'gtk', 'xaver']) + +test.run(arguments='debug=yes guilib=Motif some=xAVER') +check(['yes', 'Motif', 'xaver']) + +test.run(arguments='debug=full guilib=KdE some=EiNs') +check(['full', 'KdE', 'eins']) + +expect_stderr = """ +scons: *** Invalid value for option debug: FULL +""" + test.python_file_line(SConstruct_path, 18) + +test.run(arguments='debug=FULL', stderr=expect_stderr, status=2) + +expect_stderr = """ +scons: *** Invalid value for option guilib: irgendwas +""" + test.python_file_line(SConstruct_path, 18) + +test.run(arguments='guilib=IrGeNdwas', stderr=expect_stderr, status=2) + +expect_stderr = """ +scons: *** Invalid value for option some: irgendwas +""" + test.python_file_line(SConstruct_path, 18) + +test.run(arguments='some=IrGeNdwas', stderr=expect_stderr, status=2) + + +test.pass_test() diff --git a/test/Deprecated/Options/ListOption.py b/test/Deprecated/Options/ListOption.py new file mode 100644 index 0000000..68d2ee8 --- /dev/null +++ b/test/Deprecated/Options/ListOption.py @@ -0,0 +1,175 @@ +#!/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__" + +""" +Test the ListOption canned Option type. +""" + +import os +import os.path +import string + +import TestSCons + + +test = TestSCons.TestSCons() + +SConstruct_path = test.workpath('SConstruct') + +def check(expect): + result = string.split(test.stdout(), '\n') + r = result[1:len(expect)+1] + assert r == expect, (r, expect) + + + +test.write(SConstruct_path, """\ +from SCons.Options import ListOption + +list_of_libs = Split('x11 gl qt ical') + +optsfile = 'scons.options' +opts = Options(optsfile, args=ARGUMENTS) +opts.AddOptions( + ListOption('shared', + 'libraries to build as shared libraries', + 'all', + names = list_of_libs, + map = {'GL':'gl', 'QT':'qt'}), + ) + +env = Environment(options=opts) +opts.Save(optsfile, env) +Help(opts.GenerateHelpText(env)) + +print env['shared'] +if 'ical' in env['shared']: print '1' +else: print '0' +for x in env['shared']: + print x, +print +print env.subst('$shared') +# Test subst_path() because it's used in $CPPDEFINES expansions. +print env.subst_path('$shared') +Default(env.Alias('dummy', None)) +""") + +test.run() +check(['all', '1', 'gl ical qt x11', 'gl ical qt x11', + "['gl ical qt x11']"]) + +test.must_match(test.workpath('scons.options'), + "shared = 'all'"+os.linesep, + mode='r') + +check(['all', '1', 'gl ical qt x11', 'gl ical qt x11', + "['gl ical qt x11']"]) + +test.run(arguments='shared=none') +check(['none', '0', '', '', "['']"]) + +test.run(arguments='shared=') +check(['none', '0', '', '', "['']"]) + +test.run(arguments='shared=x11,ical') +check(['ical,x11', '1', 'ical x11', 'ical x11', + "['ical x11']"]) + +test.run(arguments='shared=x11,,ical,,') +check(['ical,x11', '1', 'ical x11', 'ical x11', + "['ical x11']"]) + +test.run(arguments='shared=GL') +check(['gl', '0', 'gl', 'gl']) + +test.run(arguments='shared=QT,GL') +check(['gl,qt', '0', 'gl qt', 'gl qt', "['gl qt']"]) + + +expect_stderr = """ +scons: *** Error converting option: shared +Invalid value(s) for option: foo +""" + test.python_file_line(SConstruct_path, 15) + +test.run(arguments='shared=foo', stderr=expect_stderr, status=2) + +# be paranoid in testing some more combinations + +expect_stderr = """ +scons: *** Error converting option: shared +Invalid value(s) for option: foo +""" + test.python_file_line(SConstruct_path, 15) + +test.run(arguments='shared=foo,ical', stderr=expect_stderr, status=2) + +expect_stderr = """ +scons: *** Error converting option: shared +Invalid value(s) for option: foo +""" + test.python_file_line(SConstruct_path, 15) + +test.run(arguments='shared=ical,foo', stderr=expect_stderr, status=2) + +expect_stderr = """ +scons: *** Error converting option: shared +Invalid value(s) for option: foo +""" + test.python_file_line(SConstruct_path, 15) + +test.run(arguments='shared=ical,foo,x11', stderr=expect_stderr, status=2) + +expect_stderr = """ +scons: *** Error converting option: shared +Invalid value(s) for option: foo,bar +""" + test.python_file_line(SConstruct_path, 15) + +test.run(arguments='shared=foo,x11,,,bar', stderr=expect_stderr, status=2) + + + +test.write('SConstruct', """ +from SCons.Options import ListOption + +opts = Options(args=ARGUMENTS) +opts.AddOptions( + ListOption('gpib', + 'comment', + ['ENET', 'GPIB'], + names = ['ENET', 'GPIB', 'LINUX_GPIB', 'NO_GPIB']), + ) + +env = Environment(options=opts) +Help(opts.GenerateHelpText(env)) + +print env['gpib'] +Default(env.Alias('dummy', None)) +""") + +test.run(stdout=test.wrap_stdout(read_str="ENET,GPIB\n", build_str="""\ +scons: Nothing to be done for `dummy'. +""")) + + + +test.pass_test() diff --git a/test/Deprecated/Options/Options.py b/test/Deprecated/Options/Options.py new file mode 100644 index 0000000..11452b1 --- /dev/null +++ b/test/Deprecated/Options/Options.py @@ -0,0 +1,364 @@ +#!/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 TestSCons +import string + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +import string +env = Environment() +print env['CC'] +print string.join(env['CCFLAGS']) +Default(env.Alias('dummy', None)) +""") +test.run() +cc, ccflags = string.split(test.stdout(), '\n')[1:3] + +test.write('SConstruct', """ +import string + +# test validator. Change a key and add a new one to the environment +def validator(key, value, environ): + environ[key] = "v" + environ["valid_key"] = "v" + + +def old_converter (value): + return "old_converter" + +def new_converter (value, env): + return "new_converter" + + +opts = Options('custom.py') +opts.Add('RELEASE_BUILD', + 'Set to 1 to build a release build', + 0, + None, + int) + +opts.Add('DEBUG_BUILD', + 'Set to 1 to build a debug build', + 1, + None, + int) + +opts.Add('CC', + 'The C compiler') + +opts.Add('VALIDATE', + 'An option for testing validation', + "notset", + validator, + None) + +opts.Add('OLD_CONVERTER', + 'An option for testing converters that take one parameter', + "foo", + None, + old_converter) + +opts.Add('NEW_CONVERTER', + 'An option for testing converters that take two parameters', + "foo", + None, + new_converter) + +opts.Add('UNSPECIFIED', + 'An option with no value') + +def test_tool(env): + if env['RELEASE_BUILD']: + env.Append(CCFLAGS = '-O') + if env['DEBUG_BUILD']: + env.Append(CCFLAGS = '-g') + + +env = Environment(options=opts, tools=['default', test_tool]) + +Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env)) + +print env['RELEASE_BUILD'] +print env['DEBUG_BUILD'] +print env['CC'] +print string.join(env['CCFLAGS']) +print env['VALIDATE'] +print env['valid_key'] + +# unspecified options should not be set: +assert not env.has_key('UNSPECIFIED') + +# undeclared options should be ignored: +assert not env.has_key('UNDECLARED') + +# calling Update() should not effect options that +# are not declared on the options object: +r = env['RELEASE_BUILD'] +opts = Options() +opts.Update(env) +assert env['RELEASE_BUILD'] == r + +Default(env.Alias('dummy', None)) + +""") + +def check(expect): + result = string.split(test.stdout(), '\n') + assert result[1:len(expect)+1] == expect, (result[1:len(expect)+1], expect) + +test.run() +check(['0', '1', cc, string.strip(ccflags + ' -g'), 'v', 'v']) + +test.run(arguments='RELEASE_BUILD=1') +check(['1', '1', cc, string.strip(ccflags + ' -O -g'), 'v', 'v']) + +test.run(arguments='RELEASE_BUILD=1 DEBUG_BUILD=0') +check(['1', '0', cc, string.strip(ccflags + ' -O'), 'v', 'v']) + +test.run(arguments='CC=not_a_c_compiler') +check(['0', '1', 'not_a_c_compiler', string.strip(ccflags + ' -g'), 'v', 'v']) + +test.run(arguments='UNDECLARED=foo') +check(['0', '1', cc, string.strip(ccflags + ' -g'), 'v', 'v']) + +test.run(arguments='CCFLAGS=--taco') +check(['0', '1', cc, string.strip(ccflags + ' -g'), 'v', 'v']) + +test.write('custom.py', """ +DEBUG_BUILD=0 +RELEASE_BUILD=1 +""") + +test.run() +check(['1', '0', cc, string.strip(ccflags + ' -O'), 'v', 'v']) + +test.run(arguments='DEBUG_BUILD=1') +check(['1', '1', cc, string.strip(ccflags + ' -O -g'), 'v', 'v']) + +test.run(arguments='-h', + stdout = """\ +scons: Reading SConscript files ... +1 +0 +%s +%s +v +v +scons: done reading SConscript files. +Variables settable in custom.py or on the command line: + +RELEASE_BUILD: Set to 1 to build a release build + default: 0 + actual: 1 + +DEBUG_BUILD: Set to 1 to build a debug build + default: 1 + actual: 0 + +CC: The C compiler + default: None + actual: %s + +VALIDATE: An option for testing validation + default: notset + actual: v + +OLD_CONVERTER: An option for testing converters that take one parameter + default: foo + actual: old_converter + +NEW_CONVERTER: An option for testing converters that take two parameters + default: foo + actual: new_converter + +UNSPECIFIED: An option with no value + default: None + actual: None + +Use scons -H for help about command-line options. +"""%(cc, ccflags and ccflags + ' -O' or '-O', cc)) + +# Test saving of options and multi loading +# +test.write('SConstruct', """ +opts = Options(['custom.py', 'options.saved']) +opts.Add('RELEASE_BUILD', + 'Set to 1 to build a release build', + 0, + None, + int) + +opts.Add('DEBUG_BUILD', + 'Set to 1 to build a debug build', + 1, + None, + int) + +opts.Add('UNSPECIFIED', + 'An option with no value') + +env = Environment(options = opts) + +print env['RELEASE_BUILD'] +print env['DEBUG_BUILD'] + +opts.Save('options.saved', env) +""") + +# Check the save file by executing and comparing against +# the expected dictionary +def checkSave(file, expected): + gdict = {} + ldict = {} + execfile(file, gdict, ldict) + assert expected == ldict, "%s\n...not equal to...\n%s" % (expected, ldict) + +# First test with no command line options +# This should just leave the custom.py settings +test.run() +check(['1','0']) +checkSave('options.saved', { 'RELEASE_BUILD':1, 'DEBUG_BUILD':0}) + +# Override with command line arguments +test.run(arguments='DEBUG_BUILD=3') +check(['1','3']) +checkSave('options.saved', {'RELEASE_BUILD':1, 'DEBUG_BUILD':3}) + +# Now make sure that saved options are overridding the custom.py +test.run() +check(['1','3']) +checkSave('options.saved', {'DEBUG_BUILD':3, 'RELEASE_BUILD':1}) + +# Load no options from file(s) +# Used to test for correct output in save option file +test.write('SConstruct', """ +opts = Options() +opts.Add('RELEASE_BUILD', + 'Set to 1 to build a release build', + '0', + None, + int) + +opts.Add('DEBUG_BUILD', + 'Set to 1 to build a debug build', + '1', + None, + int) + +opts.Add('UNSPECIFIED', + 'An option with no value') + +opts.Add('LISTOPTION_TEST', + 'testing list option persistence', + 'none', + names = ['a','b','c',]) + +env = Environment(options = opts) + +print env['RELEASE_BUILD'] +print env['DEBUG_BUILD'] +print env['LISTOPTION_TEST'] + +opts.Save('options.saved', env) +""") + +# First check for empty output file when nothing is passed on command line +test.run() +check(['0','1']) +checkSave('options.saved', {}) + +# Now specify one option the same as default and make sure it doesn't write out +test.run(arguments='DEBUG_BUILD=1') +check(['0','1']) +checkSave('options.saved', {}) + +# Now specify same option non-default and make sure only it is written out +test.run(arguments='DEBUG_BUILD=0 LISTOPTION_TEST=a,b') +check(['0','0']) +checkSave('options.saved',{'DEBUG_BUILD':0, 'LISTOPTION_TEST':'a,b'}) + +test.write('SConstruct', """ +opts = Options('custom.py') +opts.Add('RELEASE_BUILD', + 'Set to 1 to build a release build', + 0, + None, + int) + +opts.Add('DEBUG_BUILD', + 'Set to 1 to build a debug build', + 1, + None, + int) + +opts.Add('CC', + 'The C compiler') + +opts.Add('UNSPECIFIED', + 'An option with no value') + +env = Environment(options=opts) + +Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env,sort=cmp)) + +""") + +test.run(arguments='-h', + stdout = """\ +scons: Reading SConscript files ... +scons: done reading SConscript files. +Variables settable in custom.py or on the command line: + +CC: The C compiler + default: None + actual: %s + +DEBUG_BUILD: Set to 1 to build a debug build + default: 1 + actual: 0 + +RELEASE_BUILD: Set to 1 to build a release build + default: 0 + actual: 1 + +UNSPECIFIED: An option with no value + default: None + actual: None + +Use scons -H for help about command-line options. +"""%cc) + +test.write('SConstruct', """ +import SCons.Options +env1 = Environment(options = Options()) +env2 = Environment(options = SCons.Options.Options()) +""") + +test.run() + +test.pass_test() diff --git a/test/Deprecated/Options/PackageOption.py b/test/Deprecated/Options/PackageOption.py new file mode 100644 index 0000000..79d4dda --- /dev/null +++ b/test/Deprecated/Options/PackageOption.py @@ -0,0 +1,89 @@ +#!/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__" + +""" +Test the PackageOption canned Option type. +""" + +import os.path +import string + +try: + True, False +except NameError: + True = (0 == 0) + False = (0 != 0) + +import TestSCons + +test = TestSCons.TestSCons() + +SConstruct_path = test.workpath('SConstruct') + +def check(expect): + result = string.split(test.stdout(), '\n') + assert result[1:len(expect)+1] == expect, (result[1:len(expect)+1], expect) + + + +test.write(SConstruct_path, """\ +from SCons.Options import PackageOption + +opts = Options(args=ARGUMENTS) +opts.AddOptions( + PackageOption('x11', + 'use X11 installed here (yes = search some places', + 'yes'), + ) + +env = Environment(options=opts) +Help(opts.GenerateHelpText(env)) + +print env['x11'] +Default(env.Alias('dummy', None)) +""") + +test.run() +check([str(True)]) + +test.run(arguments='x11=no') +check([str(False)]) + +test.run(arguments='x11=0') +check([str(False)]) + +test.run(arguments=['x11=%s' % test.workpath()]) +check([test.workpath()]) + +expect_stderr = """ +scons: *** Path does not exist for option x11: /non/existing/path/ +""" + test.python_file_line(SConstruct_path, 10) + +test.run(arguments='x11=/non/existing/path/', stderr=expect_stderr, status=2) + + + +test.pass_test() diff --git a/test/Deprecated/Options/PathOption.py b/test/Deprecated/Options/PathOption.py new file mode 100644 index 0000000..23fec6e --- /dev/null +++ b/test/Deprecated/Options/PathOption.py @@ -0,0 +1,285 @@ +#!/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__" + +""" +Test the PathOption canned option type, with tests for its +various canned validators. +""" + +import os.path +import string + +import TestSCons + +test = TestSCons.TestSCons() + +SConstruct_path = test.workpath('SConstruct') + +def check(expect): + result = string.split(test.stdout(), '\n') + assert result[1:len(expect)+1] == expect, (result[1:len(expect)+1], expect) + +#### test PathOption #### + +test.subdir('lib', 'qt', ['qt', 'lib'], 'nolib' ) +workpath = test.workpath() +libpath = os.path.join(workpath, 'lib') + +test.write(SConstruct_path, """\ +from SCons.Options import PathOption + +qtdir = r'%s' + +opts = Options(args=ARGUMENTS) +opts.AddOptions( + PathOption('qtdir', 'where the root of Qt is installed', qtdir), + PathOption('qt_libraries', 'where the Qt library is installed', r'%s'), + ) + +env = Environment(options=opts) +Help(opts.GenerateHelpText(env)) + +print env['qtdir'] +print env['qt_libraries'] +print env.subst('$qt_libraries') + +Default(env.Alias('dummy', None)) +""" % (workpath, os.path.join('$qtdir', 'lib') )) + +qtpath = workpath +libpath = os.path.join(qtpath, 'lib') +test.run() +check([qtpath, os.path.join('$qtdir', 'lib'), libpath]) + +qtpath = os.path.join(workpath, 'qt') +libpath = os.path.join(qtpath, 'lib') +test.run(arguments=['qtdir=%s' % qtpath]) +check([qtpath, os.path.join('$qtdir', 'lib'), libpath]) + +qtpath = workpath +libpath = os.path.join(qtpath, 'nolib') +test.run(arguments=['qt_libraries=%s' % libpath]) +check([qtpath, libpath, libpath]) + +qtpath = os.path.join(workpath, 'qt') +libpath = os.path.join(workpath, 'nolib') +test.run(arguments=['qtdir=%s' % qtpath, 'qt_libraries=%s' % libpath]) +check([qtpath, libpath, libpath]) + +qtpath = os.path.join(workpath, 'non', 'existing', 'path') +SConstruct_file_line = test.python_file_line(test.workpath('SConstruct'), 11)[:-1] + +expect_stderr = """ +scons: *** Path for option qtdir does not exist: %(qtpath)s +%(SConstruct_file_line)s +""" % locals() + +test.run(arguments=['qtdir=%s' % qtpath], stderr=expect_stderr, status=2) + +expect_stderr = """ +scons: *** Path for option qt_libraries does not exist: %(qtpath)s +%(SConstruct_file_line)s +""" % locals() + +test.run(arguments=['qt_libraries=%s' % qtpath], stderr=expect_stderr, status=2) + + + +default_file = test.workpath('default_file') +default_subdir = test.workpath('default_subdir') + +existing_subdir = test.workpath('existing_subdir') +test.subdir(existing_subdir) + +existing_file = test.workpath('existing_file') +test.write(existing_file, "existing_file\n") + +non_existing_subdir = test.workpath('non_existing_subdir') +non_existing_file = test.workpath('non_existing_file') + + + +test.write('SConstruct', """\ +opts = Options(args=ARGUMENTS) +opts.AddOptions( + PathOption('X', 'X variable', r'%s', validator=PathOption.PathAccept), + ) + +env = Environment(options=opts) + +print env['X'] + +Default(env.Alias('dummy', None)) +""" % default_subdir) + +test.run() +check([default_subdir]) + +test.run(arguments=['X=%s' % existing_file]) +check([existing_file]) + +test.run(arguments=['X=%s' % non_existing_file]) +check([non_existing_file]) + +test.run(arguments=['X=%s' % existing_subdir]) +check([existing_subdir]) + +test.run(arguments=['X=%s' % non_existing_subdir]) +check([non_existing_subdir]) + +test.must_not_exist(non_existing_file) +test.must_not_exist(non_existing_subdir) + + + +test.write(SConstruct_path, """\ +opts = Options(args=ARGUMENTS) +opts.AddOptions( + PathOption('X', 'X variable', r'%s', validator=PathOption.PathIsFile), + ) + +env = Environment(options=opts) + +print env['X'] + +Default(env.Alias('dummy', None)) +""" % default_file) + +SConstruct_file_line = test.python_file_line(test.workpath('SConstruct'), 6)[:-1] + +expect_stderr = """ +scons: *** File path for option X does not exist: %(default_file)s +%(SConstruct_file_line)s +""" % locals() + +test.run(status=2, stderr=expect_stderr) + +test.write(default_file, "default_file\n") + +test.run() +check([default_file]) + +expect_stderr = """ +scons: *** File path for option X is a directory: %(existing_subdir)s +%(SConstruct_file_line)s +""" % locals() + +test.run(arguments=['X=%s' % existing_subdir], status=2, stderr=expect_stderr) + +test.run(arguments=['X=%s' % existing_file]) +check([existing_file]) + +expect_stderr = """ +scons: *** File path for option X does not exist: %(non_existing_file)s +%(SConstruct_file_line)s +""" % locals() + +test.run(arguments=['X=%s' % non_existing_file], status=2, stderr=expect_stderr) + + + +test.write('SConstruct', """\ +opts = Options(args=ARGUMENTS) +opts.AddOptions( + PathOption('X', 'X variable', r'%s', validator=PathOption.PathIsDir), + ) + +env = Environment(options=opts) + +print env['X'] + +Default(env.Alias('dummy', None)) +""" % default_subdir) + +expect_stderr = """ +scons: *** Directory path for option X does not exist: %(default_subdir)s +%(SConstruct_file_line)s +""" % locals() + +test.run(status=2, stderr=expect_stderr) + +test.subdir(default_subdir) + +test.run() +check([default_subdir]) + +expect_stderr = """ +scons: *** Directory path for option X is a file: %(existing_file)s +%(SConstruct_file_line)s +""" % locals() + +test.run(arguments=['X=%s' % existing_file], + status=2, + stderr=expect_stderr) + +test.run(arguments=['X=%s' % existing_subdir]) +check([existing_subdir]) + +expect_stderr = """ +scons: *** Directory path for option X does not exist: %(non_existing_subdir)s +%(SConstruct_file_line)s +""" % locals() + +test.run(arguments=['X=%s' % non_existing_subdir], + status=2, + stderr=expect_stderr) + + + +test.write('SConstruct', """\ +opts = Options(args=ARGUMENTS) +opts.AddOptions( + PathOption('X', 'X variable', r'%s', validator=PathOption.PathIsDirCreate), + ) + +env = Environment(options=opts) + +print env['X'] + +Default(env.Alias('dummy', None)) +""" % default_subdir) + +test.run() +check([default_subdir]) + +expect_stderr = """ +scons: *** Path for option X is a file, not a directory: %(existing_file)s +%(SConstruct_file_line)s +""" % locals() + +test.run(arguments=['X=%s' % existing_file], status=2, stderr=expect_stderr) + +test.run(arguments=['X=%s' % existing_subdir]) +check([existing_subdir]) + +test.run(arguments=['X=%s' % non_existing_subdir]) +check([non_existing_subdir]) + +test.must_exist(non_existing_subdir) + + + +test.pass_test() diff --git a/test/Deprecated/Options/chdir.py b/test/Deprecated/Options/chdir.py new file mode 100644 index 0000000..7ba85ea --- /dev/null +++ b/test/Deprecated/Options/chdir.py @@ -0,0 +1,71 @@ +#!/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__" + +""" +Verify that we can chdir() to the directory in which an Options +file lives by using the __name__ value. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('bin', 'subdir') + +test.write('SConstruct', """\ +opts = Options('../bin/opts.cfg', ARGUMENTS) +opts.Add('VARIABLE') +Export("opts") +SConscript('subdir/SConscript') +""") + +SConscript_contents = """\ +Import("opts") +env = Environment() +opts.Update(env) +print "VARIABLE =", repr(env['VARIABLE']) +""" + +test.write(['bin', 'opts.cfg'], """\ +import os +import os.path +os.chdir(os.path.split(__name__)[0]) +execfile('opts2.cfg') +""") + +test.write(['bin', 'opts2.cfg'], """\ +VARIABLE = 'opts2.cfg value' +""") + +test.write(['subdir', 'SConscript'], SConscript_contents) + +expect = """\ +VARIABLE = 'opts2.cfg value' +""" + +test.run(arguments = '-q -Q .', stdout=expect) + +test.pass_test() diff --git a/test/Deprecated/Options/help.py b/test/Deprecated/Options/help.py new file mode 100644 index 0000000..d3fa9ad --- /dev/null +++ b/test/Deprecated/Options/help.py @@ -0,0 +1,151 @@ +#!/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__" + +""" +Test the Options help messages. +""" + +import os.path +import string + +try: + True, False +except NameError: + True = (0 == 0) + False = (0 != 0) + +str_True = str(True) +str_False = str(False) + +import TestSCons + +test = TestSCons.TestSCons() + + + +workpath = test.workpath() +qtpath = os.path.join(workpath, 'qt') +libpath = os.path.join(qtpath, 'lib') +libdirvar = os.path.join('$qtdir', 'lib') + +test.subdir(qtpath) +test.subdir(libpath) + +test.write('SConstruct', """ +from SCons.Options import BoolOption, EnumOption, ListOption, \ + PackageOption, PathOption + +list_of_libs = Split('x11 gl qt ical') +qtdir = r'%(qtpath)s' + +opts = Options(args=ARGUMENTS) +opts.AddOptions( + BoolOption('warnings', 'compilation with -Wall and similiar', 1), + BoolOption('profile', 'create profiling informations', 0), + EnumOption('debug', 'debug output and symbols', 'no', + allowed_values=('yes', 'no', 'full'), + map={}, ignorecase=0), # case sensitive + EnumOption('guilib', 'gui lib to use', 'gtk', + allowed_values=('motif', 'gtk', 'kde'), + map={}, ignorecase=1), # case insensitive + EnumOption('some', 'some option', 'xaver', + allowed_values=('xaver', 'eins'), + map={}, ignorecase=2), # make lowercase + ListOption('shared', + 'libraries to build as shared libraries', + 'all', + names = list_of_libs), + PackageOption('x11', + 'use X11 installed here (yes = search some places)', + 'yes'), + PathOption('qtdir', 'where the root of Qt is installed', qtdir), + PathOption('qt_libraries', + 'where the Qt library is installed', + r'%(libdirvar)s'), + ) + +env = Environment(options=opts) +Help(opts.GenerateHelpText(env)) + +print env['warnings'] +print env['profile'] + +Default(env.Alias('dummy', None)) +""" % locals()) + + +test.run(arguments='-h', + stdout = """\ +scons: Reading SConscript files ... +%(str_True)s +%(str_False)s +scons: done reading SConscript files. + +warnings: compilation with -Wall and similiar (yes|no) + default: 1 + actual: %(str_True)s + +profile: create profiling informations (yes|no) + default: 0 + actual: %(str_False)s + +debug: debug output and symbols (yes|no|full) + default: no + actual: no + +guilib: gui lib to use (motif|gtk|kde) + default: gtk + actual: gtk + +some: some option (xaver|eins) + default: xaver + actual: xaver + +shared: libraries to build as shared libraries + (all|none|comma-separated list of names) + allowed names: x11 gl qt ical + default: all + actual: x11 gl qt ical + +x11: use X11 installed here (yes = search some places) + ( yes | no | /path/to/x11 ) + default: yes + actual: %(str_True)s + +qtdir: where the root of Qt is installed ( /path/to/qtdir ) + default: %(qtpath)s + actual: %(qtpath)s + +qt_libraries: where the Qt library is installed ( /path/to/qt_libraries ) + default: %(libdirvar)s + actual: %(libpath)s + +Use scons -H for help about command-line options. +""" % locals()) + + + +test.pass_test() diff --git a/test/Deprecated/Options/import.py b/test/Deprecated/Options/import.py new file mode 100644 index 0000000..0a3d367 --- /dev/null +++ b/test/Deprecated/Options/import.py @@ -0,0 +1,69 @@ +#!/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__" + +""" +Verify that an Options file in a different directory can import +a module in that directory. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +workpath = test.workpath('') + +test.subdir('bin', 'subdir') + +test.write('SConstruct', """\ +opts = Options('../bin/opts.cfg', ARGUMENTS) +opts.Add('VARIABLE') +Export("opts") +SConscript('subdir/SConscript') +""") + +SConscript_contents = """\ +Import("opts") +env = Environment() +opts.Update(env) +print "VARIABLE =", env.get('VARIABLE') +""" + +test.write(['bin', 'opts.cfg'], """\ +import sys +from local_options import VARIABLE +""" % locals()) + +test.write(['bin', 'local_options.py'], """\ +VARIABLE = 'bin/local_options.py' +""") + +test.write(['subdir', 'SConscript'], SConscript_contents) + +expect = "VARIABLE = bin/local_options.py\n" + +test.run(arguments = '-q -Q .', stdout = expect) + +test.pass_test() diff --git a/test/Deprecated/debug-stree.py b/test/Deprecated/debug-stree.py index 8907c6c..9b6e067 100644 --- a/test/Deprecated/debug-stree.py +++ b/test/Deprecated/debug-stree.py @@ -100,7 +100,7 @@ stree = """ test.run(arguments = "--debug=stree foo.xxx", stderr = stderr) -test.fail_test(string.find(test.stdout(), stree) == -1) +test.fail_test(string.count(test.stdout(), stree) != 1) stree2 = """ E = exists @@ -132,6 +132,6 @@ test.run(arguments = '-c foo.xxx') test.run(arguments = "--no-exec --debug=stree foo.xxx", stderr = stderr) -test.fail_test(string.find(test.stdout(), stree2) == -1) +test.fail_test(string.count(test.stdout(), stree2) != 1) test.pass_test() |