[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

aroben at apple.com aroben at apple.com
Wed Dec 22 15:28:46 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit a6cb3f7a46ff0cb1d5bd970146d503fb117ce3a5
Author: aroben at apple.com <aroben at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 4 15:24:40 2010 +0000

    Reduce our dependence on coreutils when running Python tests
    
    This patch introduces versions of the standard echo and cat utilities
    implemented in Python. They are probably missing features of their
    coreutils equivalents, but they can do what's necessary for our Python
    tests. This is useful on Windows, where these utilities typically
    aren't available.
    
    Fixes <http://webkit.org/b/48883> executive_unittest relies on echo
    and cat utilities from coreutils, which are not present on Windows
    
    Reviewed by Eric Seidel.
    
    * Scripts/webkitpy/common/system/executive_unittest.py: Changed to use
    our Python-based echo and cat.
    
    * Scripts/webkitpy/common/system/fileutils.py: Added.
    (make_stdout_binary): On Windows, puts sys.stdout into binary mode so
    that \n won't be translated into \r\n. I couldn't think of a good way
    to test this directly without touching the filesystem, but it is tested
    indirectly by echo_unittest.
    
    * Scripts/webkitpy/test/cat.py: Added.
    (command_arguments): Returns a list for invoking cat with the given arguments.
    (main): Acts like a simplified version of the coreutils cat utility.
    
    * Scripts/webkitpy/test/cat_unittest.py: Added.
    (CatTest.assert_cat): Runs cat with the given input and ensures the
    output matches the input.
    (CatTest.test_basic): Performs a simple test of cat.
    (CatTest.test_no_newline): Tests what happens when the input string
    doesn't have a trailing newline.
    (CatTest.test_unicode): Tests passing a unicode string to cat.
    (CatTest.test_as_command): Tests running cat as a separate command.
    
    * Scripts/webkitpy/test/echo.py: Added.
    (command_arguments): Returns a list for invoking echo with the given arguments.
    (main): Acts like a simplified version of the coreutils echo utility.
    
    * Scripts/webkitpy/test/echo_unittest.py: Added.
    (EchoTest.test_basic): Performs a simple test of echo.
    (EchoTest.test_no_newline): Tests passing -n to echo to suppress the
    trailing newline.
    (EchoTest.test_unicode): Tests passing unicode and non-unicode strings
    to echo.
    (EchoTest.test_argument_order): Tests what happens when -n is not the
    first argument.
    (EchoTest.test_empty_arguments): Tests what happens when you pass [] to
    echo.main.
    (EchoTest.test_no_arguments): Tests what happens when you call
    echo.main with no arguments.
    (EchoTest.test_as_command): Tests running echo as a separate command.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71336 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index e7c6d0c..1f1cb5c 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,58 @@
+2010-11-02  Adam Roben  <aroben at apple.com>
+
+        Reduce our dependence on coreutils when running Python tests
+
+        This patch introduces versions of the standard echo and cat utilities
+        implemented in Python. They are probably missing features of their
+        coreutils equivalents, but they can do what's necessary for our Python
+        tests. This is useful on Windows, where these utilities typically
+        aren't available.
+
+        Fixes <http://webkit.org/b/48883> executive_unittest relies on echo
+        and cat utilities from coreutils, which are not present on Windows
+
+        Reviewed by Eric Seidel.
+
+        * Scripts/webkitpy/common/system/executive_unittest.py: Changed to use
+        our Python-based echo and cat.
+
+        * Scripts/webkitpy/common/system/fileutils.py: Added.
+        (make_stdout_binary): On Windows, puts sys.stdout into binary mode so
+        that \n won't be translated into \r\n. I couldn't think of a good way
+        to test this directly without touching the filesystem, but it is tested
+        indirectly by echo_unittest.
+
+        * Scripts/webkitpy/test/cat.py: Added.
+        (command_arguments): Returns a list for invoking cat with the given arguments.
+        (main): Acts like a simplified version of the coreutils cat utility.
+
+        * Scripts/webkitpy/test/cat_unittest.py: Added.
+        (CatTest.assert_cat): Runs cat with the given input and ensures the
+        output matches the input.
+        (CatTest.test_basic): Performs a simple test of cat.
+        (CatTest.test_no_newline): Tests what happens when the input string
+        doesn't have a trailing newline.
+        (CatTest.test_unicode): Tests passing a unicode string to cat.
+        (CatTest.test_as_command): Tests running cat as a separate command.
+
+        * Scripts/webkitpy/test/echo.py: Added.
+        (command_arguments): Returns a list for invoking echo with the given arguments.
+        (main): Acts like a simplified version of the coreutils echo utility.
+
+        * Scripts/webkitpy/test/echo_unittest.py: Added.
+        (EchoTest.test_basic): Performs a simple test of echo.
+        (EchoTest.test_no_newline): Tests passing -n to echo to suppress the
+        trailing newline.
+        (EchoTest.test_unicode): Tests passing unicode and non-unicode strings
+        to echo.
+        (EchoTest.test_argument_order): Tests what happens when -n is not the
+        first argument.
+        (EchoTest.test_empty_arguments): Tests what happens when you pass [] to
+        echo.main.
+        (EchoTest.test_no_arguments): Tests what happens when you call
+        echo.main with no arguments.
+        (EchoTest.test_as_command): Tests running echo as a separate command.
+
 2010-11-04  Renata Hodovan  <reni at inf.u-szeged.hu>
 
         Unreviewed: Add myself to the list of Committers.
diff --git a/WebKitTools/Scripts/webkitpy/common/system/executive_unittest.py b/WebKitTools/Scripts/webkitpy/common/system/executive_unittest.py
index 32f8f51..6106be8 100644
--- a/WebKitTools/Scripts/webkitpy/common/system/executive_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/common/system/executive_unittest.py
@@ -33,6 +33,7 @@ import sys
 import unittest
 
 from webkitpy.common.system.executive import Executive, run_command, ScriptError
+from webkitpy.test import cat, echo
 
 
 class ExecutiveTest(unittest.TestCase):
@@ -46,8 +47,8 @@ class ExecutiveTest(unittest.TestCase):
         executive = Executive()
         self.assertRaises(AssertionError, executive.run_command, "echo")
         self.assertRaises(AssertionError, executive.run_command, u"echo")
-        executive.run_command(["echo", "foo"])
-        executive.run_command(("echo", "foo"))
+        executive.run_command(echo.command_arguments('foo'))
+        executive.run_command(tuple(echo.command_arguments('foo')))
 
     def test_run_command_with_unicode(self):
         """Validate that it is safe to pass unicode() objects
@@ -57,24 +58,24 @@ class ExecutiveTest(unittest.TestCase):
         unicode_tor = u"WebKit \u2661 Tor Arne Vestb\u00F8!"
         utf8_tor = unicode_tor.encode("utf-8")
 
-        output = executive.run_command(["cat"], input=unicode_tor)
+        output = executive.run_command(cat.command_arguments(), input=unicode_tor)
         self.assertEquals(output, unicode_tor)
 
-        output = executive.run_command(["echo", "-n", unicode_tor])
+        output = executive.run_command(echo.command_arguments("-n", unicode_tor))
         self.assertEquals(output, unicode_tor)
 
-        output = executive.run_command(["echo", "-n", unicode_tor], decode_output=False)
+        output = executive.run_command(echo.command_arguments("-n", unicode_tor), decode_output=False)
         self.assertEquals(output, utf8_tor)
 
         # Make sure that str() input also works.
-        output = executive.run_command(["cat"], input=utf8_tor, decode_output=False)
+        output = executive.run_command(cat.command_arguments(), input=utf8_tor, decode_output=False)
         self.assertEquals(output, utf8_tor)
 
         # FIXME: We should only have one run* method to test
-        output = executive.run_and_throw_if_fail(["echo", "-n", unicode_tor], quiet=True)
+        output = executive.run_and_throw_if_fail(echo.command_arguments("-n", unicode_tor), quiet=True)
         self.assertEquals(output, unicode_tor)
 
-        output = executive.run_and_throw_if_fail(["echo", "-n", unicode_tor], quiet=True, decode_output=False)
+        output = executive.run_and_throw_if_fail(echo.command_arguments("-n", unicode_tor), quiet=True, decode_output=False)
         self.assertEquals(output, utf8_tor)
 
     def test_kill_process(self):
diff --git a/WebKitTools/Scripts/webkitpy/common/system/fileutils.py b/WebKitTools/Scripts/webkitpy/common/system/fileutils.py
new file mode 100644
index 0000000..55821f8
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/common/system/fileutils.py
@@ -0,0 +1,33 @@
+# Copyright (C) 2010 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import sys
+
+
+def make_stdout_binary():
+    """Puts sys.stdout into binary mode (on platforms that have a distinction
+    between text and binary mode)."""
+    if sys.platform != 'win32' or not hasattr(sys.stdout, 'fileno'):
+        return
+    import msvcrt
+    import os
+    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
diff --git a/WebKitTools/Scripts/webkitpy/test/cat.py b/WebKitTools/Scripts/webkitpy/test/cat.py
new file mode 100644
index 0000000..ae1e143
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/test/cat.py
@@ -0,0 +1,42 @@
+# Copyright (C) 2010 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import os.path
+import sys
+
+# Add WebKitTools/Scripts to the path to ensure we can find webkitpy.
+sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
+
+from webkitpy.common.system import fileutils
+
+
+def command_arguments(*args):
+    return ['python', __file__] + list(args)
+
+
+def main():
+    fileutils.make_stdout_binary()
+    sys.stdout.write(sys.stdin.read())
+    return 0
+
+if __name__ == '__main__':
+    sys.exit(main())
diff --git a/WebKitTools/Scripts/webkitpy/test/cat_unittest.py b/WebKitTools/Scripts/webkitpy/test/cat_unittest.py
new file mode 100644
index 0000000..4ed1f67
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/test/cat_unittest.py
@@ -0,0 +1,52 @@
+# Copyright (C) 2010 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import StringIO
+import os.path
+import sys
+import unittest
+
+from webkitpy.common.system import executive, outputcapture
+from webkitpy.test import cat
+
+
+class CatTest(outputcapture.OutputCaptureTestCaseBase):
+    def assert_cat(self, input):
+        saved_stdin = sys.stdin
+        sys.stdin = StringIO.StringIO(input)
+        cat.main()
+        self.assertStdout(input)
+        sys.stdin = saved_stdin
+
+    def test_basic(self):
+        self.assert_cat('foo bar baz\n')
+
+    def test_no_newline(self):
+        self.assert_cat('foo bar baz')
+
+    def test_unicode(self):
+        self.assert_cat(u'WebKit \u2661 Tor Arne Vestb\u00F8!')
+
+    def test_as_command(self):
+        input = 'foo bar baz\n'
+        output = executive.Executive().run_command(cat.command_arguments(), input=input)
+        self.assertEqual(input, output)
diff --git a/WebKitTools/Scripts/webkitpy/test/echo.py b/WebKitTools/Scripts/webkitpy/test/echo.py
new file mode 100644
index 0000000..f7468f7
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/test/echo.py
@@ -0,0 +1,52 @@
+# Copyright (C) 2010 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import os.path
+import sys
+
+# Add WebKitTools/Scripts to the path to ensure we can find webkitpy.
+sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
+
+from webkitpy.common.system import fileutils
+
+
+def command_arguments(*args):
+    return ['python', __file__] + list(args)
+
+
+def main(args=None):
+    if args is None:
+        args = sys.argv[1:]
+
+    fileutils.make_stdout_binary()
+
+    print_newline = True
+    if len(args) and args[0] == '-n':
+        print_newline = False
+        del args[0]
+    sys.stdout.write(' '.join(args))
+    if print_newline:
+        sys.stdout.write('\n')
+    return 0
+
+if __name__ == '__main__':
+    sys.exit(main())
diff --git a/WebKitTools/Scripts/webkitpy/test/echo_unittest.py b/WebKitTools/Scripts/webkitpy/test/echo_unittest.py
new file mode 100644
index 0000000..bc13b5e
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/test/echo_unittest.py
@@ -0,0 +1,64 @@
+# Copyright (C) 2010 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import os.path
+import sys
+import unittest
+
+from webkitpy.common.system import executive, outputcapture
+from webkitpy.test import echo
+
+
+class EchoTest(outputcapture.OutputCaptureTestCaseBase):
+    def test_basic(self):
+        echo.main(['foo', 'bar', 'baz'])
+        self.assertStdout('foo bar baz\n')
+
+    def test_no_newline(self):
+        echo.main(['-n', 'foo', 'bar', 'baz'])
+        self.assertStdout('foo bar baz')
+
+    def test_unicode(self):
+        echo.main([u'WebKit \u2661', 'Tor Arne', u'Vestb\u00F8!'])
+        self.assertStdout(u'WebKit \u2661 Tor Arne Vestb\u00F8!\n')
+
+    def test_argument_order(self):
+        echo.main(['foo', '-n', 'bar'])
+        self.assertStdout('foo -n bar\n')
+
+    def test_empty_arguments(self):
+        old_argv = sys.argv
+        sys.argv = ['echo.py', 'foo', 'bar', 'baz']
+        echo.main([])
+        self.assertStdout('\n')
+        sys.argv = old_argv
+
+    def test_no_arguments(self):
+        old_argv = sys.argv
+        sys.argv = ['echo.py', 'foo', 'bar', 'baz']
+        echo.main()
+        self.assertStdout('foo bar baz\n')
+        sys.argv = old_argv
+
+    def test_as_command(self):
+        output = executive.Executive().run_command(echo.command_arguments('foo', 'bar', 'baz'))
+        self.assertEqual(output, 'foo bar baz\n')

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list