From ca777a0529909609ccd29b518348ae52b0b1f120 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Sat, 20 Dec 2008 16:23:36 +0000 Subject: Add warnings for use of the (already) deprecated Options object and its related functions. --- src/CHANGES.txt | 2 + src/engine/SCons/Options/BoolOption.py | 11 +++- src/engine/SCons/Options/EnumOption.py | 11 +++- src/engine/SCons/Options/ListOption.py | 11 +++- src/engine/SCons/Options/PackageOption.py | 11 +++- src/engine/SCons/Options/PathOption.py | 37 ++++++++++- src/engine/SCons/Options/__init__.py | 12 ++++ src/engine/SCons/Warnings.py | 3 + test/Deprecated/Options/BoolOption.py | 21 +++--- test/Deprecated/Options/EnumOption.py | 33 ++++++---- test/Deprecated/Options/ListOption.py | 68 ++++++++++--------- test/Deprecated/Options/Options.py | 43 +++++++----- test/Deprecated/Options/PackageOption.py | 22 ++++--- test/Deprecated/Options/PathOption.py | 106 ++++++++++++++---------------- test/Deprecated/Options/chdir.py | 8 ++- test/Deprecated/Options/help.py | 45 +++++++++---- test/Deprecated/Options/import.py | 10 ++- 17 files changed, 297 insertions(+), 157 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index d334b64..fb44ad7 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -20,6 +20,8 @@ RELEASE 1.X - XXX - Don't fail if can't import a _subprocess module on Windows. + - Add warnings for use of the deprecated Options object. + From Greg Spencer: - Support implicit dependency scanning of files encoded in utf-8 diff --git a/src/engine/SCons/Options/BoolOption.py b/src/engine/SCons/Options/BoolOption.py index c3b50b3..a247ef5 100644 --- a/src/engine/SCons/Options/BoolOption.py +++ b/src/engine/SCons/Options/BoolOption.py @@ -31,5 +31,14 @@ and will then be removed entirely (some day). """ import SCons.Variables +import SCons.Warnings -BoolOption = SCons.Variables.BoolVariable +warned = False + +def BoolOption(*args, **kw): + global warned + if not warned: + msg = "The BoolOption() function is deprecated; use the BoolVariable() function instead." + SCons.Warnings.warn(SCons.Warnings.DeprecatedOptionsWarning, msg) + warned = True + return apply(SCons.Variables.BoolVariable, args, kw) diff --git a/src/engine/SCons/Options/EnumOption.py b/src/engine/SCons/Options/EnumOption.py index 24ccf28..f4c3c03 100644 --- a/src/engine/SCons/Options/EnumOption.py +++ b/src/engine/SCons/Options/EnumOption.py @@ -31,5 +31,14 @@ and will then be removed entirely (some day). """ import SCons.Variables +import SCons.Warnings -EnumOption = SCons.Variables.EnumVariable +warned = False + +def EnumOption(*args, **kw): + global warned + if not warned: + msg = "The EnumOption() function is deprecated; use the EnumVariable() function instead." + SCons.Warnings.warn(SCons.Warnings.DeprecatedOptionsWarning, msg) + warned = True + return apply(SCons.Variables.EnumVariable, args, kw) diff --git a/src/engine/SCons/Options/ListOption.py b/src/engine/SCons/Options/ListOption.py index 1a56806..88334d4 100644 --- a/src/engine/SCons/Options/ListOption.py +++ b/src/engine/SCons/Options/ListOption.py @@ -31,5 +31,14 @@ and will then be removed entirely (some day). """ import SCons.Variables +import SCons.Warnings -ListOption = SCons.Variables.ListVariable +warned = False + +def ListOption(*args, **kw): + global warned + if not warned: + msg = "The ListOption() function is deprecated; use the ListVariable() function instead." + SCons.Warnings.warn(SCons.Warnings.DeprecatedOptionsWarning, msg) + warned = True + return apply(SCons.Variables.ListVariable, args, kw) diff --git a/src/engine/SCons/Options/PackageOption.py b/src/engine/SCons/Options/PackageOption.py index 479a8a2..0f5ef7f 100644 --- a/src/engine/SCons/Options/PackageOption.py +++ b/src/engine/SCons/Options/PackageOption.py @@ -31,5 +31,14 @@ and will then be removed entirely (some day). """ import SCons.Variables +import SCons.Warnings -PackageOption = SCons.Variables.PackageVariable +warned = False + +def PackageOption(*args, **kw): + global warned + if not warned: + msg = "The PackageOption() function is deprecated; use the PackageVariable() function instead." + SCons.Warnings.warn(SCons.Warnings.DeprecatedOptionsWarning, msg) + warned = True + return apply(SCons.Variables.PackageVariable, args, kw) diff --git a/src/engine/SCons/Options/PathOption.py b/src/engine/SCons/Options/PathOption.py index e694127..3223ac3 100644 --- a/src/engine/SCons/Options/PathOption.py +++ b/src/engine/SCons/Options/PathOption.py @@ -31,5 +31,40 @@ and will then be removed entirely (some day). """ import SCons.Variables +import SCons.Warnings -PathOption = SCons.Variables.PathVariable +warned = False + +class _PathOptionClass: + def warn(self): + global warned + if not warned: + msg = "The PathOption() function is deprecated; use the PathVariable() function instead." + SCons.Warnings.warn(SCons.Warnings.DeprecatedOptionsWarning, msg) + warned = True + + def __call__(self, *args, **kw): + self.warn() + return apply(SCons.Variables.PathVariable, args, kw) + + def PathAccept(self, *args, **kw): + self.warn() + return apply(SCons.Variables.PathVariable.PathAccept, args, kw) + + def PathIsDir(self, *args, **kw): + self.warn() + return apply(SCons.Variables.PathVariable.PathIsDir, args, kw) + + def PathIsDirCreate(self, *args, **kw): + self.warn() + return apply(SCons.Variables.PathVariable.PathIsDirCreate, args, kw) + + def PathIsFile(self, *args, **kw): + self.warn() + return apply(SCons.Variables.PathVariable.PathIsFile, args, kw) + + def PathExists(self, *args, **kw): + self.warn() + return apply(SCons.Variables.PathVariable.PathExists, args, kw) + +PathOption = _PathOptionClass() diff --git a/src/engine/SCons/Options/__init__.py b/src/engine/SCons/Options/__init__.py index 5cc09a7..e1e8b3f 100644 --- a/src/engine/SCons/Options/__init__.py +++ b/src/engine/SCons/Options/__init__.py @@ -31,6 +31,7 @@ and will then be removed entirely (some day). """ import SCons.Variables +import SCons.Warnings from BoolOption import BoolOption # okay from EnumOption import EnumOption # okay @@ -38,7 +39,18 @@ from ListOption import ListOption # naja from PackageOption import PackageOption # naja from PathOption import PathOption # okay +warned = False + class Options(SCons.Variables.Variables): + def __init__(self, *args, **kw): + global warned + if not warned: + msg = "The Options class is deprecated; use the Variables class instead." + SCons.Warnings.warn(SCons.Warnings.DeprecatedOptionsWarning, msg) + warned = True + apply(SCons.Variables.Variables.__init__, + (self,) + args, + kw) def AddOptions(self, *args, **kw): return apply(SCons.Variables.Variables.AddVariables, diff --git a/src/engine/SCons/Warnings.py b/src/engine/SCons/Warnings.py index 83e3ccb..e23d1ef 100644 --- a/src/engine/SCons/Warnings.py +++ b/src/engine/SCons/Warnings.py @@ -67,6 +67,9 @@ class DependencyWarning(Warning): class DeprecatedCopyWarning(DeprecatedWarning): pass +class DeprecatedOptionsWarning(DeprecatedWarning): + pass + class DeprecatedSourceSignaturesWarning(DeprecatedWarning): pass diff --git a/test/Deprecated/Options/BoolOption.py b/test/Deprecated/Options/BoolOption.py index d45ad1b..99c2cd7 100644 --- a/test/Deprecated/Options/BoolOption.py +++ b/test/Deprecated/Options/BoolOption.py @@ -28,7 +28,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" Test the BoolOption canned Option type. """ -import os.path import string try: @@ -39,7 +38,7 @@ except NameError: import TestSCons -test = TestSCons.TestSCons() +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) SConstruct_path = test.workpath('SConstruct') @@ -71,19 +70,25 @@ Default(env.Alias('dummy', None)) """) +warnings = """ +scons: warning: The Options class is deprecated; use the Variables class instead. +%s +scons: warning: The BoolOption\\(\\) function is deprecated; use the BoolVariable\\(\\) function instead. +%s""" % (TestSCons.file_expr, TestSCons.file_expr) + +test.run(stderr=warnings) -test.run() check([str(True), str(False)]) -test.run(arguments='warnings=0 profile=no profile=true') +test.run(arguments='warnings=0 profile=no profile=true', stderr=warnings) check([str(False), str(True)]) -expect_stderr = """ -scons: *** Error converting option: warnings +expect_stderr = (warnings + """ +scons: \\*\\*\\* Error converting option: warnings Invalid value for boolean option: irgendwas -""" + test.python_file_line(SConstruct_path, 12) +""" + TestSCons.file_expr) -test.run(arguments='warnings=irgendwas', stderr = expect_stderr, status=2) +test.run(arguments='warnings=irgendwas', stderr=expect_stderr, status=2) diff --git a/test/Deprecated/Options/EnumOption.py b/test/Deprecated/Options/EnumOption.py index 29724f3..d46b898 100644 --- a/test/Deprecated/Options/EnumOption.py +++ b/test/Deprecated/Options/EnumOption.py @@ -33,7 +33,7 @@ import string import TestSCons -test = TestSCons.TestSCons() +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) SConstruct_path = test.workpath('SConstruct') @@ -75,29 +75,36 @@ Default(env.Alias('dummy', None)) """) -test.run(); check(['no', 'gtk', 'xaver']) -test.run(arguments='debug=yes guilib=Motif some=xAVER') +warnings = """ +scons: warning: The Options class is deprecated; use the Variables class instead. +%s +scons: warning: The EnumOption\\(\\) function is deprecated; use the EnumVariable\\(\\) function instead. +%s""" % (TestSCons.file_expr, TestSCons.file_expr) + +test.run(stderr=warnings); check(['no', 'gtk', 'xaver']) + +test.run(arguments='debug=yes guilib=Motif some=xAVER', stderr=warnings) check(['yes', 'Motif', 'xaver']) -test.run(arguments='debug=full guilib=KdE some=EiNs') +test.run(arguments='debug=full guilib=KdE some=EiNs', stderr=warnings) check(['full', 'KdE', 'eins']) -expect_stderr = """ -scons: *** Invalid value for option debug: FULL -""" + test.python_file_line(SConstruct_path, 21) +expect_stderr = warnings + """ +scons: \\*\\*\\* Invalid value for option debug: FULL +""" + TestSCons.file_expr 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, 21) +expect_stderr = warnings + """ +scons: \\*\\*\\* Invalid value for option guilib: irgendwas +""" + TestSCons.file_expr 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, 21) +expect_stderr = warnings + """ +scons: \\*\\*\\* Invalid value for option some: irgendwas +""" + TestSCons.file_expr test.run(arguments='some=IrGeNdwas', stderr=expect_stderr, status=2) diff --git a/test/Deprecated/Options/ListOption.py b/test/Deprecated/Options/ListOption.py index 7e7b18f..62792b6 100644 --- a/test/Deprecated/Options/ListOption.py +++ b/test/Deprecated/Options/ListOption.py @@ -35,7 +35,7 @@ import string import TestSCons -test = TestSCons.TestSCons() +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) SConstruct_path = test.workpath('SConstruct') @@ -81,7 +81,13 @@ print env.subst_path('$shared') Default(env.Alias('dummy', None)) """) -test.run() +warnings = """ +scons: warning: The Options class is deprecated; use the Variables class instead. +%s +scons: warning: The ListOption\\(\\) function is deprecated; use the ListVariable\\(\\) function instead. +%s""" % (TestSCons.file_expr, TestSCons.file_expr) + +test.run(stderr=warnings) check(['all', '1', 'gl ical qt x11', 'gl ical qt x11', "['gl ical qt x11']"]) @@ -91,61 +97,61 @@ test.must_match(test.workpath('scons.options'), expect) check(['all', '1', 'gl ical qt x11', 'gl ical qt x11', "['gl ical qt x11']"]) -test.run(arguments='shared=none') +test.run(arguments='shared=none', stderr=warnings) check(['none', '0', '', '', "['']"]) -test.run(arguments='shared=') +test.run(arguments='shared=', stderr=warnings) check(['none', '0', '', '', "['']"]) -test.run(arguments='shared=x11,ical') +test.run(arguments='shared=x11,ical', stderr=warnings) check(['ical,x11', '1', 'ical x11', 'ical x11', "['ical x11']"]) -test.run(arguments='shared=x11,,ical,,') +test.run(arguments='shared=x11,,ical,,', stderr=warnings) check(['ical,x11', '1', 'ical x11', 'ical x11', "['ical x11']"]) -test.run(arguments='shared=GL') +test.run(arguments='shared=GL', stderr=warnings) check(['gl', '0', 'gl', 'gl']) -test.run(arguments='shared=QT,GL') +test.run(arguments='shared=QT,GL', stderr=warnings) 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, 19) +expect_stderr = warnings + """ +scons: \\*\\*\\* Error converting option: shared +Invalid value\\(s\\) for option: foo +""" + TestSCons.file_expr 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, 19) +expect_stderr = warnings + """ +scons: \\*\\*\\* Error converting option: shared +Invalid value\\(s\\) for option: foo +""" + TestSCons.file_expr 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, 19) +expect_stderr = warnings +""" +scons: \\*\\*\\* Error converting option: shared +Invalid value\\(s\\) for option: foo +""" + TestSCons.file_expr 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, 19) +expect_stderr = warnings +""" +scons: \\*\\*\\* Error converting option: shared +Invalid value\\(s\\) for option: foo +""" + TestSCons.file_expr 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, 19) +expect_stderr = warnings +""" +scons: \\*\\*\\* Error converting option: shared +Invalid value\\(s\\) for option: foo,bar +""" + TestSCons.file_expr test.run(arguments='shared=foo,x11,,,bar', stderr=expect_stderr, status=2) @@ -169,9 +175,11 @@ print env['gpib'] Default(env.Alias('dummy', None)) """) -test.run(stdout=test.wrap_stdout(read_str="ENET,GPIB\n", build_str="""\ +expect = test.wrap_stdout(read_str="ENET,GPIB\n", build_str="""\ scons: Nothing to be done for `dummy'. -""")) +""") + +test.run(stdout=expect, stderr=warnings) diff --git a/test/Deprecated/Options/Options.py b/test/Deprecated/Options/Options.py index 11452b1..1edfa97 100644 --- a/test/Deprecated/Options/Options.py +++ b/test/Deprecated/Options/Options.py @@ -27,7 +27,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons import string -test = TestSCons.TestSCons() +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) test.write('SConstruct', """ import string @@ -127,26 +127,31 @@ Default(env.Alias('dummy', None)) """) +warnings = """ +scons: warning: The Options class is deprecated; use the Variables class instead. +""" + TestSCons.file_expr + + def check(expect): result = string.split(test.stdout(), '\n') assert result[1:len(expect)+1] == expect, (result[1:len(expect)+1], expect) -test.run() +test.run(stderr=warnings) check(['0', '1', cc, string.strip(ccflags + ' -g'), 'v', 'v']) -test.run(arguments='RELEASE_BUILD=1') +test.run(arguments='RELEASE_BUILD=1', stderr=warnings) check(['1', '1', cc, string.strip(ccflags + ' -O -g'), 'v', 'v']) -test.run(arguments='RELEASE_BUILD=1 DEBUG_BUILD=0') +test.run(arguments='RELEASE_BUILD=1 DEBUG_BUILD=0', stderr=warnings) check(['1', '0', cc, string.strip(ccflags + ' -O'), 'v', 'v']) -test.run(arguments='CC=not_a_c_compiler') +test.run(arguments='CC=not_a_c_compiler', stderr=warnings) check(['0', '1', 'not_a_c_compiler', string.strip(ccflags + ' -g'), 'v', 'v']) -test.run(arguments='UNDECLARED=foo') +test.run(arguments='UNDECLARED=foo', stderr=warnings) check(['0', '1', cc, string.strip(ccflags + ' -g'), 'v', 'v']) -test.run(arguments='CCFLAGS=--taco') +test.run(arguments='CCFLAGS=--taco', stderr=warnings) check(['0', '1', cc, string.strip(ccflags + ' -g'), 'v', 'v']) test.write('custom.py', """ @@ -154,10 +159,10 @@ DEBUG_BUILD=0 RELEASE_BUILD=1 """) -test.run() +test.run(stderr=warnings) check(['1', '0', cc, string.strip(ccflags + ' -O'), 'v', 'v']) -test.run(arguments='DEBUG_BUILD=1') +test.run(arguments='DEBUG_BUILD=1', stderr=warnings) check(['1', '1', cc, string.strip(ccflags + ' -O -g'), 'v', 'v']) test.run(arguments='-h', @@ -201,7 +206,8 @@ UNSPECIFIED: An option with no value actual: None Use scons -H for help about command-line options. -"""%(cc, ccflags and ccflags + ' -O' or '-O', cc)) +"""%(cc, ccflags and ccflags + ' -O' or '-O', cc), + stderr=warnings) # Test saving of options and multi loading # @@ -240,17 +246,17 @@ def checkSave(file, expected): # First test with no command line options # This should just leave the custom.py settings -test.run() +test.run(stderr=warnings) check(['1','0']) checkSave('options.saved', { 'RELEASE_BUILD':1, 'DEBUG_BUILD':0}) # Override with command line arguments -test.run(arguments='DEBUG_BUILD=3') +test.run(arguments='DEBUG_BUILD=3', stderr=warnings) 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() +test.run(stderr=warnings) check(['1','3']) checkSave('options.saved', {'DEBUG_BUILD':3, 'RELEASE_BUILD':1}) @@ -288,17 +294,17 @@ opts.Save('options.saved', env) """) # First check for empty output file when nothing is passed on command line -test.run() +test.run(stderr=warnings) 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') +test.run(arguments='DEBUG_BUILD=1', stderr=warnings) 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') +test.run(arguments='DEBUG_BUILD=0 LISTOPTION_TEST=a,b', stderr=warnings) check(['0','0']) checkSave('options.saved',{'DEBUG_BUILD':0, 'LISTOPTION_TEST':'a,b'}) @@ -351,7 +357,8 @@ UNSPECIFIED: An option with no value actual: None Use scons -H for help about command-line options. -"""%cc) +"""%cc, + stderr=warnings) test.write('SConstruct', """ import SCons.Options @@ -359,6 +366,6 @@ env1 = Environment(options = Options()) env2 = Environment(options = SCons.Options.Options()) """) -test.run() +test.run(stderr=warnings) test.pass_test() diff --git a/test/Deprecated/Options/PackageOption.py b/test/Deprecated/Options/PackageOption.py index b7dbc71..11b8df0 100644 --- a/test/Deprecated/Options/PackageOption.py +++ b/test/Deprecated/Options/PackageOption.py @@ -39,7 +39,7 @@ except NameError: import TestSCons -test = TestSCons.TestSCons() +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) SConstruct_path = test.workpath('SConstruct') @@ -70,21 +70,27 @@ print env['x11'] Default(env.Alias('dummy', None)) """) -test.run() +warnings = """ +scons: warning: The Options class is deprecated; use the Variables class instead. +%s +scons: warning: The PackageOption\\(\\) function is deprecated; use the PackageVariable\\(\\) function instead. +%s""" % (TestSCons.file_expr, TestSCons.file_expr) + +test.run(stderr=warnings) check([str(True)]) -test.run(arguments='x11=no') +test.run(arguments='x11=no', stderr=warnings) check([str(False)]) -test.run(arguments='x11=0') +test.run(arguments='x11=0', stderr=warnings) check([str(False)]) -test.run(arguments=['x11=%s' % test.workpath()]) +test.run(arguments=['x11=%s' % test.workpath()], stderr=warnings) check([test.workpath()]) -expect_stderr = """ -scons: *** Path does not exist for option x11: /non/existing/path/ -""" + test.python_file_line(SConstruct_path, 14) +expect_stderr = warnings + """ +scons: \\*\\*\\* Path does not exist for option x11: /non/existing/path/ +""" + TestSCons.file_expr test.run(arguments='x11=/non/existing/path/', stderr=expect_stderr, status=2) diff --git a/test/Deprecated/Options/PathOption.py b/test/Deprecated/Options/PathOption.py index 3fa7e81..9b845a1 100644 --- a/test/Deprecated/Options/PathOption.py +++ b/test/Deprecated/Options/PathOption.py @@ -34,7 +34,7 @@ import string import TestSCons -test = TestSCons.TestSCons() +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) SConstruct_path = test.workpath('SConstruct') @@ -72,40 +72,43 @@ print env.subst('$qt_libraries') Default(env.Alias('dummy', None)) """ % (workpath, os.path.join('$qtdir', 'lib') )) +warnings = """ +scons: warning: The Options class is deprecated; use the Variables class instead. +%s +scons: warning: The PathOption\\(\\) function is deprecated; use the PathVariable\\(\\) function instead. +%s""" % (TestSCons.file_expr, TestSCons.file_expr) + qtpath = workpath libpath = os.path.join(qtpath, 'lib') -test.run() +test.run(stderr=warnings) 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]) +test.run(arguments=['qtdir=%s' % qtpath], stderr=warnings) check([qtpath, os.path.join('$qtdir', 'lib'), libpath]) qtpath = workpath libpath = os.path.join(qtpath, 'nolib') -test.run(arguments=['qt_libraries=%s' % libpath]) +test.run(arguments=['qt_libraries=%s' % libpath], stderr=warnings) 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]) +test.run(arguments=['qtdir=%s' % qtpath, 'qt_libraries=%s' % libpath], stderr=warnings) check([qtpath, libpath, libpath]) qtpath = os.path.join(workpath, 'non', 'existing', 'path') -SConstruct_file_line = test.python_file_line(test.workpath('SConstruct'), 14)[:-1] -expect_stderr = """ -scons: *** Path for option qtdir does not exist: %(qtpath)s -%(SConstruct_file_line)s -""" % locals() +expect_stderr = warnings + (""" +scons: \\*\\*\\* Path for option qtdir does not exist: %(qtpath)s +""" % locals()) + TestSCons.file_expr 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() +expect_stderr = warnings + (""" +scons: \\*\\*\\* Path for option qt_libraries does not exist: %(qtpath)s +""" % locals()) + TestSCons.file_expr test.run(arguments=['qt_libraries=%s' % qtpath], stderr=expect_stderr, status=2) @@ -138,19 +141,19 @@ print env['X'] Default(env.Alias('dummy', None)) """ % default_subdir) -test.run() +test.run(stderr=warnings) check([default_subdir]) -test.run(arguments=['X=%s' % existing_file]) +test.run(arguments=['X=%s' % existing_file], stderr=warnings) check([existing_file]) -test.run(arguments=['X=%s' % non_existing_file]) +test.run(arguments=['X=%s' % non_existing_file], stderr=warnings) check([non_existing_file]) -test.run(arguments=['X=%s' % existing_subdir]) +test.run(arguments=['X=%s' % existing_subdir], stderr=warnings) check([existing_subdir]) -test.run(arguments=['X=%s' % non_existing_subdir]) +test.run(arguments=['X=%s' % non_existing_subdir], stderr=warnings) check([non_existing_subdir]) test.must_not_exist(non_existing_file) @@ -171,34 +174,29 @@ 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() +expect_stderr = warnings + (""" +scons: \\*\\*\\* File path for option X does not exist: %(default_file)s +""" % locals()) + TestSCons.file_expr test.run(status=2, stderr=expect_stderr) test.write(default_file, "default_file\n") -test.run() +test.run(stderr=warnings) check([default_file]) -expect_stderr = """ -scons: *** File path for option X is a directory: %(existing_subdir)s -%(SConstruct_file_line)s -""" % locals() +expect_stderr = warnings + (""" +scons: \\*\\*\\* File path for option X is a directory: %(existing_subdir)s +""" % locals()) + TestSCons.file_expr test.run(arguments=['X=%s' % existing_subdir], status=2, stderr=expect_stderr) -test.run(arguments=['X=%s' % existing_file]) +test.run(arguments=['X=%s' % existing_file], stderr=warnings) check([existing_file]) -expect_stderr = """ -scons: *** File path for option X does not exist: %(non_existing_file)s -%(SConstruct_file_line)s -""" % locals() +expect_stderr = warnings + (""" +scons: \\*\\*\\* File path for option X does not exist: %(non_existing_file)s +""" % locals()) + TestSCons.file_expr test.run(arguments=['X=%s' % non_existing_file], status=2, stderr=expect_stderr) @@ -217,34 +215,31 @@ 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() +expect_stderr = warnings + (""" +scons: \\*\\*\\* Directory path for option X does not exist: %(default_subdir)s +""" % locals()) + TestSCons.file_expr test.run(status=2, stderr=expect_stderr) test.subdir(default_subdir) -test.run() +test.run(stderr=warnings) check([default_subdir]) -expect_stderr = """ -scons: *** Directory path for option X is a file: %(existing_file)s -%(SConstruct_file_line)s -""" % locals() +expect_stderr = warnings + (""" +scons: \\*\\*\\* Directory path for option X is a file: %(existing_file)s +""" % locals()) + TestSCons.file_expr test.run(arguments=['X=%s' % existing_file], status=2, stderr=expect_stderr) -test.run(arguments=['X=%s' % existing_subdir]) +test.run(arguments=['X=%s' % existing_subdir], stderr=warnings) check([existing_subdir]) -expect_stderr = """ -scons: *** Directory path for option X does not exist: %(non_existing_subdir)s -%(SConstruct_file_line)s -""" % locals() +expect_stderr = warnings + (""" +scons: \\*\\*\\* Directory path for option X does not exist: %(non_existing_subdir)s +""" % locals()) + TestSCons.file_expr test.run(arguments=['X=%s' % non_existing_subdir], status=2, @@ -265,20 +260,19 @@ print env['X'] Default(env.Alias('dummy', None)) """ % default_subdir) -test.run() +test.run(stderr=warnings) check([default_subdir]) -expect_stderr = """ -scons: *** Path for option X is a file, not a directory: %(existing_file)s -%(SConstruct_file_line)s -""" % locals() +expect_stderr = warnings + (""" +scons: \\*\\*\\* Path for option X is a file, not a directory: %(existing_file)s +""" % locals()) + TestSCons.file_expr test.run(arguments=['X=%s' % existing_file], status=2, stderr=expect_stderr) -test.run(arguments=['X=%s' % existing_subdir]) +test.run(arguments=['X=%s' % existing_subdir], stderr=warnings) check([existing_subdir]) -test.run(arguments=['X=%s' % non_existing_subdir]) +test.run(arguments=['X=%s' % non_existing_subdir], stderr=warnings) check([non_existing_subdir]) test.must_exist(non_existing_subdir) diff --git a/test/Deprecated/Options/chdir.py b/test/Deprecated/Options/chdir.py index 7ba85ea..dd4eb70 100644 --- a/test/Deprecated/Options/chdir.py +++ b/test/Deprecated/Options/chdir.py @@ -31,7 +31,7 @@ file lives by using the __name__ value. import TestSCons -test = TestSCons.TestSCons() +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) test.subdir('bin', 'subdir') @@ -66,6 +66,10 @@ expect = """\ VARIABLE = 'opts2.cfg value' """ -test.run(arguments = '-q -Q .', stdout=expect) +warnings = """ +scons: warning: The Options class is deprecated; use the Variables class instead. +""" + TestSCons.file_expr + +test.run(arguments = '-q -Q .', stdout=expect, stderr=warnings) test.pass_test() diff --git a/test/Deprecated/Options/help.py b/test/Deprecated/Options/help.py index d3fa9ad..049cb1e 100644 --- a/test/Deprecated/Options/help.py +++ b/test/Deprecated/Options/help.py @@ -42,7 +42,7 @@ str_False = str(False) import TestSCons -test = TestSCons.TestSCons() +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) @@ -97,54 +97,71 @@ Default(env.Alias('dummy', None)) """ % locals()) -test.run(arguments='-h', - stdout = """\ +expected_stdout = """\ scons: Reading SConscript files ... %(str_True)s %(str_False)s scons: done reading SConscript files. -warnings: compilation with -Wall and similiar (yes|no) +warnings: compilation with -Wall and similiar \\(yes|no\\) default: 1 actual: %(str_True)s -profile: create profiling informations (yes|no) +profile: create profiling informations \\(yes|no\\) default: 0 actual: %(str_False)s -debug: debug output and symbols (yes|no|full) +debug: debug output and symbols \\(yes|no|full\\) default: no actual: no -guilib: gui lib to use (motif|gtk|kde) +guilib: gui lib to use \\(motif|gtk|kde\\) default: gtk actual: gtk -some: some option (xaver|eins) +some: some option \\(xaver|eins\\) default: xaver actual: xaver shared: libraries to build as shared libraries - (all|none|comma-separated list of names) + \\(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 ) +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 ) +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 ) +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()) +""" % locals() + +file_expr = TestSCons.file_expr + +expected_stderr = """ +scons: warning: The Options class is deprecated; use the Variables class instead. +%(file_expr)s +scons: warning: The BoolOption\\(\\) function is deprecated; use the BoolVariable\\(\\) function instead. +%(file_expr)s +scons: warning: The EnumOption\\(\\) function is deprecated; use the EnumVariable\\(\\) function instead. +%(file_expr)s +scons: warning: The ListOption\\(\\) function is deprecated; use the ListVariable\\(\\) function instead. +%(file_expr)s +scons: warning: The PackageOption\\(\\) function is deprecated; use the PackageVariable\\(\\) function instead. +%(file_expr)s +scons: warning: The PathOption\\(\\) function is deprecated; use the PathVariable\\(\\) function instead. +%(file_expr)s""" % locals() + +test.run(arguments='-h', stdout=expected_stdout, stderr=expected_stderr) diff --git a/test/Deprecated/Options/import.py b/test/Deprecated/Options/import.py index 0a3d367..9384986 100644 --- a/test/Deprecated/Options/import.py +++ b/test/Deprecated/Options/import.py @@ -31,7 +31,7 @@ a module in that directory. import TestSCons -test = TestSCons.TestSCons() +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) workpath = test.workpath('') @@ -62,8 +62,12 @@ VARIABLE = 'bin/local_options.py' test.write(['subdir', 'SConscript'], SConscript_contents) -expect = "VARIABLE = bin/local_options.py\n" +stdout = "VARIABLE = bin/local_options.py\n" -test.run(arguments = '-q -Q .', stdout = expect) +stderr = """ +scons: warning: The Options class is deprecated; use the Variables class instead. +""" + TestSCons.file_expr + +test.run(arguments = '-q -Q .', stdout = stdout, stderr = stderr) test.pass_test() -- cgit v0.12