diff options
| author | William Deegan <bill@baddogconsulting.com> | 2015-09-21 17:03:12 (GMT) |
|---|---|---|
| committer | William Deegan <bill@baddogconsulting.com> | 2015-09-21 17:03:12 (GMT) |
| commit | 0941093e0e5a030faa49968457638a3a6aee7ad8 (patch) | |
| tree | 6d33513c14eb6eac0531dd050de0ecca4c39bd79 /test/Progress | |
| download | SCons-2.4.0.zip SCons-2.4.0.tar.gz SCons-2.4.0.tar.bz2 | |
release 2.4.02.4.0
Diffstat (limited to 'test/Progress')
| -rw-r--r-- | test/Progress/TARGET.py | 71 | ||||
| -rw-r--r-- | test/Progress/dots.py | 66 | ||||
| -rw-r--r-- | test/Progress/file.py | 86 | ||||
| -rw-r--r-- | test/Progress/function.py | 81 | ||||
| -rw-r--r-- | test/Progress/interval.py | 74 | ||||
| -rw-r--r-- | test/Progress/object.py | 84 | ||||
| -rw-r--r-- | test/Progress/spinner.py | 71 |
7 files changed, 533 insertions, 0 deletions
diff --git a/test/Progress/TARGET.py b/test/Progress/TARGET.py new file mode 100644 index 0000000..d7ff3c9 --- /dev/null +++ b/test/Progress/TARGET.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 substition of the $TARGET string in progress output, including +overwriting it by setting the overwrite= keyword argument. +""" + +import os + +import TestSCons + +test = TestSCons.TestSCons(universal_newlines=None) + +test.write('SConstruct', """\ +env = Environment() +env['BUILDERS']['C'] = Builder(action=Copy('$TARGET', '$SOURCE')) +Progress('$TARGET\\r', overwrite=True) +env.C('S1.out', 'S1.in') +env.C('S2.out', 'S2.in') +env.C('S3.out', 'S3.in') +env.C('S4.out', 'S4.in') +""") + +test.write('S1.in', "S1.in\n") +test.write('S2.in', "S2.in\n") +test.write('S3.in', "S3.in\n") +test.write('S4.in', "S4.in\n") + +expect = """\ +S1.in\r \rS1.out\rCopy("S1.out", "S1.in") + \rS2.in\r \rS2.out\rCopy("S2.out", "S2.in") + \rS3.in\r \rS3.out\rCopy("S3.out", "S3.in") + \rS4.in\r \rS4.out\rCopy("S4.out", "S4.in") + \rSConstruct\r \r.\r""" + +if os.linesep != '\n': + expect = expect.replace('\n', os.linesep) + +test.run(arguments = '-Q .', stdout=expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Progress/dots.py b/test/Progress/dots.py new file mode 100644 index 0000000..e31ec56 --- /dev/null +++ b/test/Progress/dots.py @@ -0,0 +1,66 @@ +#!/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 expected behavior of just telling a Progress() object to print +a dot for every visited Node. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +env = Environment() +env['BUILDERS']['C'] = Builder(action=Copy('$TARGET', '$SOURCE')) +Progress('.') +env.C('S1.out', 'S1.in') +env.C('S2.out', 'S2.in') +env.C('S3.out', 'S3.in') +env.C('S4.out', 'S4.in') +""") + +test.write('S1.in', "S1.in\n") +test.write('S2.in', "S2.in\n") +test.write('S3.in', "S3.in\n") +test.write('S4.in', "S4.in\n") + +expect = """\ +..Copy("S1.out", "S1.in") +..Copy("S2.out", "S2.in") +..Copy("S3.out", "S3.in") +..Copy("S4.out", "S4.in") +..""" + +test.run(arguments = '-Q .', stdout=expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Progress/file.py b/test/Progress/file.py new file mode 100644 index 0000000..3184a5b --- /dev/null +++ b/test/Progress/file.py @@ -0,0 +1,86 @@ +#!/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 the file= argument to Progress() allows us to redirect the +progress output. +""" + +import os + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +env = Environment() +env['BUILDERS']['C'] = Builder(action=Copy('$TARGET', '$SOURCE')) +Progress('stderr: $TARGET\\n', file=open('progress.out', 'w')) +env.C('S1.out', 'S1.in') +env.C('S2.out', 'S2.in') +env.C('S3.out', 'S3.in') +env.C('S4.out', 'S4.in') +""") + +test.write('S1.in', "S1.in\n") +test.write('S2.in', "S2.in\n") +test.write('S3.in', "S3.in\n") +test.write('S4.in', "S4.in\n") + +expect = """\ +Copy("S1.out", "S1.in") +Copy("S2.out", "S2.in") +Copy("S3.out", "S3.in") +Copy("S4.out", "S4.in") +""" + +test.run(arguments = '-Q .', stdout=expect) + +expect = """\ +stderr: S1.in +stderr: S1.out +stderr: S2.in +stderr: S2.out +stderr: S3.in +stderr: S3.out +stderr: S4.in +stderr: S4.out +stderr: SConstruct +stderr: . +""" + +if os.linesep != '\n': + expect = expect.replace('\n', os.linesep) + +test.must_match('progress.out', expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Progress/function.py b/test/Progress/function.py new file mode 100644 index 0000000..9998008 --- /dev/null +++ b/test/Progress/function.py @@ -0,0 +1,81 @@ +#!/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 the behavior of passing our own function to Progress(). +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +import sys +env = Environment() +env['BUILDERS']['C'] = Builder(action=Copy('$TARGET', '$SOURCE')) +def my_progress_function(node, *args, **kw): + sys.stderr.write('mpf: %s\\n' % node) +Progress(my_progress_function) +env.C('S1.out', 'S1.in') +env.C('S2.out', 'S2.in') +env.C('S3.out', 'S3.in') +env.C('S4.out', 'S4.in') +""") + +test.write('S1.in', "S1.in\n") +test.write('S2.in', "S2.in\n") +test.write('S3.in', "S3.in\n") +test.write('S4.in', "S4.in\n") + +expect_stdout = """\ +Copy("S1.out", "S1.in") +Copy("S2.out", "S2.in") +Copy("S3.out", "S3.in") +Copy("S4.out", "S4.in") +""" + +expect_stderr = """\ +mpf: S1.in +mpf: S1.out +mpf: S2.in +mpf: S2.out +mpf: S3.in +mpf: S3.out +mpf: S4.in +mpf: S4.out +mpf: SConstruct +mpf: . +""" + +test.run(arguments = '-Q .', stdout=expect_stdout, stderr=expect_stderr) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Progress/interval.py b/test/Progress/interval.py new file mode 100644 index 0000000..2b99238 --- /dev/null +++ b/test/Progress/interval.py @@ -0,0 +1,74 @@ +#!/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 the "interval=" parameter to Progress skips Nodes. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +import sys +env = Environment() +env['BUILDERS']['C'] = Builder(action=Copy('$TARGET', '$SOURCE')) +Progress('stderr: $TARGET\\n', file=sys.stderr, interval=2) +env.C('S1.out', 'S1.in') +env.C('S2.out', 'S2.in') +env.C('S3.out', 'S3.in') +env.C('S4.out', 'S4.in') +""") + +test.write('S1.in', "S1.in\n") +test.write('S2.in', "S2.in\n") +test.write('S3.in', "S3.in\n") +test.write('S4.in', "S4.in\n") + +expect_stdout = """\ +Copy("S1.out", "S1.in") +Copy("S2.out", "S2.in") +Copy("S3.out", "S3.in") +Copy("S4.out", "S4.in") +""" + +expect_stderr = """\ +stderr: S1.out +stderr: S2.out +stderr: S3.out +stderr: S4.out +stderr: . +""" + +test.run(arguments = '-Q .', stdout=expect_stdout, stderr=expect_stderr) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Progress/object.py b/test/Progress/object.py new file mode 100644 index 0000000..2886d06 --- /dev/null +++ b/test/Progress/object.py @@ -0,0 +1,84 @@ +#!/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 the behavior of passing a callable object to Progress(). +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +import sys +env = Environment() +env['BUILDERS']['C'] = Builder(action=Copy('$TARGET', '$SOURCE')) +class my_progress(object): + count = 0 + def __call__(self, node, *args, **kw): + self.count = self.count + 1 + sys.stderr.write('%s: %s\\n' % (self.count, node)) +Progress(my_progress()) +env.C('S1.out', 'S1.in') +env.C('S2.out', 'S2.in') +env.C('S3.out', 'S3.in') +env.C('S4.out', 'S4.in') +""") + +test.write('S1.in', "S1.in\n") +test.write('S2.in', "S2.in\n") +test.write('S3.in', "S3.in\n") +test.write('S4.in', "S4.in\n") + +expect_stdout = """\ +Copy("S1.out", "S1.in") +Copy("S2.out", "S2.in") +Copy("S3.out", "S3.in") +Copy("S4.out", "S4.in") +""" + +expect_stderr = """\ +1: S1.in +2: S1.out +3: S2.in +4: S2.out +5: S3.in +6: S3.out +7: S4.in +8: S4.out +9: SConstruct +10: . +""" + +test.run(arguments = '-Q .', stdout=expect_stdout, stderr=expect_stderr) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Progress/spinner.py b/test/Progress/spinner.py new file mode 100644 index 0000000..85ca32f --- /dev/null +++ b/test/Progress/spinner.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 output when a Progress() call is initialized with the list +that represents a canonical "spinner" on the output. +""" + +import os + +import TestSCons + +test = TestSCons.TestSCons(universal_newlines=None) + +test.write('SConstruct', r""" +env = Environment() +env['BUILDERS']['C'] = Builder(action=Copy('$TARGET', '$SOURCE')) +Progress(['-\r', '\\\r', '|\r', '/\r']) +env.C('S1.out', 'S1.in') +env.C('S2.out', 'S2.in') +env.C('S3.out', 'S3.in') +env.C('S4.out', 'S4.in') +""") + +test.write('S1.in', "S1.in\n") +test.write('S2.in', "S2.in\n") +test.write('S3.in', "S3.in\n") +test.write('S4.in', "S4.in\n") + +expect = """\ +\\\r|\rCopy("S1.out", "S1.in") +/\r-\rCopy("S2.out", "S2.in") +\\\r|\rCopy("S3.out", "S3.in") +/\r-\rCopy("S4.out", "S4.in") +\\\r|\r""" + +if os.linesep != '\n': + expect = expect.replace('\n', os.linesep) + +test.run(arguments = '-Q .', stdout=expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: |
