diff options
Diffstat (limited to 'test/Options')
-rw-r--r-- | test/Options/BoolOption.py | 15 | ||||
-rw-r--r-- | test/Options/EnumOption.py | 33 | ||||
-rw-r--r-- | test/Options/ListOption.py | 60 | ||||
-rw-r--r-- | test/Options/PackageOption.py | 13 | ||||
-rw-r--r-- | test/Options/PathOption.py | 107 |
5 files changed, 135 insertions, 93 deletions
diff --git a/test/Options/BoolOption.py b/test/Options/BoolOption.py index ef6491d..7af9bfd 100644 --- a/test/Options/BoolOption.py +++ b/test/Options/BoolOption.py @@ -35,13 +35,15 @@ 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', """ +test.write(SConstruct_path, """\ from SCons.Options import BoolOption opts = Options(args=ARGUMENTS) @@ -59,18 +61,21 @@ print env['profile'] Default(env.Alias('dummy', None)) """) + + test.run() check(['1', '0']) test.run(arguments='warnings=0 profile=no profile=true') check(['0', '1']) -test.run(arguments='warnings=irgendwas', - stderr = """ +expect_stderr = """ scons: *** Error converting option: warnings Invalid value for boolean option: irgendwas -File "SConstruct", line 10, in ? -""", status=2) +File "%(SConstruct_path)s", line 9, in ? +""" % locals() + +test.run(arguments='warnings=irgendwas', stderr = expect_stderr, status=2) diff --git a/test/Options/EnumOption.py b/test/Options/EnumOption.py index c47f7d5..5e29477 100644 --- a/test/Options/EnumOption.py +++ b/test/Options/EnumOption.py @@ -35,13 +35,15 @@ 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', """ +test.write(SConstruct_path, """\ from SCons.Options import EnumOption list_of_libs = Split('x11 gl qt ical') @@ -71,28 +73,33 @@ 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']) -test.run(arguments='debug=FULL', - stderr = """ +expect_stderr = """ scons: *** Invalid value for option debug: FULL -File "SConstruct", line 19, in ? -""", status=2) +File "%(SConstruct_path)s", line 18, in ? +""" % locals() -test.run(arguments='guilib=IrGeNdwas', - stderr = """ +test.run(arguments='debug=FULL', stderr=expect_stderr, status=2) + +expect_stderr = """ scons: *** Invalid value for option guilib: irgendwas -File "SConstruct", line 19, in ? -""", status=2) +File "%(SConstruct_path)s", line 18, in ? +""" % locals() + +test.run(arguments='guilib=IrGeNdwas', stderr=expect_stderr, status=2) -test.run(arguments='some=IrGeNdwas', - stderr = """ +expect_stderr = """ scons: *** Invalid value for option some: irgendwas -File "SConstruct", line 19, in ? -""", status=2) +File "%(SConstruct_path)s", line 18, in ? +""" % locals() + +test.run(arguments='some=IrGeNdwas', stderr=expect_stderr, status=2) test.pass_test() diff --git a/test/Options/ListOption.py b/test/Options/ListOption.py index 5dbe0c3..fddfc5f 100644 --- a/test/Options/ListOption.py +++ b/test/Options/ListOption.py @@ -35,13 +35,16 @@ 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) + r = result[1:len(expect)+1] + assert r == expect, (r, expect) -test.write('SConstruct', """ +test.write(SConstruct_path, """\ from SCons.Options import ListOption list_of_libs = Split('x11 gl qt ical') @@ -70,56 +73,69 @@ Default(env.Alias('dummy', None)) test.run() check(['all', '1', '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']) + test.run(arguments='shared=x11,,ical,,') check(['ical,x11', '1', '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']) -test.run(arguments='shared=foo', - stderr = """ +expect_stderr = """ scons: *** Error converting option: shared Invalid value(s) for option: foo -File "SConstruct", line 15, in ? -""", status=2) +File "%(SConstruct_path)s", line 14, in ? +""" % locals() + +test.run(arguments='shared=foo', stderr=expect_stderr, status=2) # be paranoid in testing some more combinations -test.run(arguments='shared=foo,ical', - stderr = """ +expect_stderr = """ scons: *** Error converting option: shared Invalid value(s) for option: foo -File "SConstruct", line 15, in ? -""", status=2) +File "%(SConstruct_path)s", line 14, in ? +""" % locals() + +test.run(arguments='shared=foo,ical', stderr=expect_stderr, status=2) -test.run(arguments='shared=ical,foo', - stderr = """ +expect_stderr = """ scons: *** Error converting option: shared Invalid value(s) for option: foo -File "SConstruct", line 15, in ? -""", status=2) +File "%(SConstruct_path)s", line 14, in ? +""" % locals() -test.run(arguments='shared=ical,foo,x11', - stderr = """ +test.run(arguments='shared=ical,foo', stderr=expect_stderr, status=2) + +expect_stderr = """ scons: *** Error converting option: shared Invalid value(s) for option: foo -File "SConstruct", line 15, in ? -""", status=2) +File "%(SConstruct_path)s", line 14, in ? +""" % locals() + +test.run(arguments='shared=ical,foo,x11', stderr=expect_stderr, status=2) -test.run(arguments='shared=foo,x11,,,bar', - stderr = """ +expect_stderr = """ scons: *** Error converting option: shared Invalid value(s) for option: foo,bar -File "SConstruct", line 15, in ? -""", status=2) +File "%(SConstruct_path)s", line 14, in ? +""" % locals() + +test.run(arguments='shared=foo,x11,,,bar', stderr=expect_stderr, status=2) + + test.write('SConstruct', """ from SCons.Options import ListOption diff --git a/test/Options/PackageOption.py b/test/Options/PackageOption.py index cc520f7..81f7003 100644 --- a/test/Options/PackageOption.py +++ b/test/Options/PackageOption.py @@ -35,13 +35,15 @@ 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', """ +test.write(SConstruct_path, """\ from SCons.Options import PackageOption opts = Options(args=ARGUMENTS) @@ -64,11 +66,12 @@ test.run(arguments='x11=no'); check(['0']) test.run(arguments='x11=0'); check(['0']) test.run(arguments=['x11=%s' % test.workpath()]); check([test.workpath()]) -test.run(arguments='x11=/non/existing/path/', - stderr = """ +expect_stderr = """ scons: *** Path does not exist for option x11: /non/existing/path/ -File "SConstruct", line 11, in ? -""", status=2) +File "%(SConstruct_path)s", line 10, in ? +""" % locals() + +test.run(arguments='x11=/non/existing/path/', stderr=expect_stderr, status=2) diff --git a/test/Options/PathOption.py b/test/Options/PathOption.py index d15f39b..d22071e 100644 --- a/test/Options/PathOption.py +++ b/test/Options/PathOption.py @@ -36,6 +36,8 @@ 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) @@ -46,7 +48,7 @@ test.subdir('lib', 'qt', ['qt', 'lib'], 'nolib' ) workpath = test.workpath() libpath = os.path.join(workpath, 'lib') -test.write('SConstruct', """ +test.write(SConstruct_path, """\ from SCons.Options import PathOption qtdir = r'%s' @@ -88,17 +90,20 @@ test.run(arguments=['qtdir=%s' % qtpath, 'qt_libraries=%s' % libpath]) check([qtpath, libpath, libpath]) qtpath = os.path.join(workpath, 'non', 'existing', 'path') -test.run(arguments=['qtdir=%s' % qtpath], - stderr = """ -scons: *** Path for option qtdir does not exist: %s -File "SConstruct", line 12, in ? -""" % qtpath, status=2) -test.run(arguments=['qt_libraries=%s' % qtpath], - stderr = """ -scons: *** Path for option qt_libraries does not exist: %s -File "SConstruct", line 12, in ? -""" % qtpath, status=2) +expect_stderr = """ +scons: *** Path for option qtdir does not exist: %(qtpath)s +File "%(SConstruct_path)s", line 11, in ? +""" % 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 +File "%(SConstruct_path)s", line 11, in ? +""" % locals() + +test.run(arguments=['qt_libraries=%s' % qtpath], stderr=expect_stderr, status=2) @@ -149,7 +154,7 @@ test.must_not_exist(non_existing_subdir) -test.write('SConstruct', """\ +test.write(SConstruct_path, """\ opts = Options(args=ARGUMENTS) opts.AddOptions( PathOption('X', 'X variable', r'%s', validator=PathOption.PathIsFile), @@ -162,33 +167,34 @@ print env['X'] Default(env.Alias('dummy', None)) """ % default_file) -test.run(status=2, - stderr=""" -scons: *** File path for option X does not exist: %s -File "SConstruct", line 6, in ? -""" % default_file) +expect_stderr = """ +scons: *** File path for option X does not exist: %(default_file)s +File "%(SConstruct_path)s", line 6, in ? +""" % locals() + +test.run(status=2, stderr=expect_stderr) test.write(default_file, "default_file\n") test.run() check([default_file]) -test.run(arguments=['X=%s' % existing_subdir], - status=2, - stderr=""" -scons: *** File path for option X is a directory: %s -File "SConstruct", line 6, in ? -""" % existing_subdir) +expect_stderr = """ +scons: *** File path for option X is a directory: %(existing_subdir)s +File "%(SConstruct_path)s", line 6, in ? +""" % locals() + +test.run(arguments=['X=%s' % existing_subdir], status=2, stderr=expect_stderr) test.run(arguments=['X=%s' % existing_file]) check([existing_file]) -test.run(arguments=['X=%s' % non_existing_file], - status=2, - stderr=""" -scons: *** File path for option X does not exist: %s -File "SConstruct", line 6, in ? -""" % non_existing_file) +expect_stderr = """ +scons: *** File path for option X does not exist: %(non_existing_file)s +File "%(SConstruct_path)s", line 6, in ? +""" % locals() + +test.run(arguments=['X=%s' % non_existing_file], status=2, stderr=expect_stderr) @@ -205,33 +211,38 @@ print env['X'] Default(env.Alias('dummy', None)) """ % default_subdir) -test.run(status=2, - stderr=""" -scons: *** Directory path for option X does not exist: %s -File "SConstruct", line 6, in ? -""" % default_subdir) +expect_stderr = """ +scons: *** Directory path for option X does not exist: %(default_subdir)s +File "%(SConstruct_path)s", line 6, in ? +""" % 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 +File "%(SConstruct_path)s", line 6, in ? +""" % locals() + test.run(arguments=['X=%s' % existing_file], status=2, - stderr=""" -scons: *** Directory path for option X is a file: %s -File "SConstruct", line 6, in ? -""" % existing_file) + 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 +File "%(SConstruct_path)s", line 6, in ? +""" % locals() + test.run(arguments=['X=%s' % non_existing_subdir], status=2, - stderr=""" -scons: *** Directory path for option X does not exist: %s -File "SConstruct", line 6, in ? -""" % non_existing_subdir) + stderr=expect_stderr) @@ -251,12 +262,12 @@ Default(env.Alias('dummy', None)) test.run() check([default_subdir]) -test.run(arguments=['X=%s' % existing_file], - status=2, - stderr=""" -scons: *** Path for option X is a file, not a directory: %s -File "SConstruct", line 6, in ? -""" % existing_file) +expect_stderr = """ +scons: *** Path for option X is a file, not a directory: %(existing_file)s +File "%(SConstruct_path)s", line 6, in ? +""" % locals() + +test.run(arguments=['X=%s' % existing_file], status=2, stderr=expect_stderr) test.run(arguments=['X=%s' % existing_subdir]) check([existing_subdir]) |