Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: Tools/Scripts/webkitpy/w3c/test_importer_unittest.py

Issue 16465007: clean up test importer to use webkit_finder and update tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: re-upload Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Tools/Scripts/webkitpy/w3c/test_importer.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions 6 # modification, are permitted provided that the following conditions
7 # are met: 7 # are met:
8 # 8 #
9 # 1. Redistributions of source code must retain the above 9 # 1. Redistributions of source code must retain the above
10 # copyright notice, this list of conditions and the following 10 # copyright notice, this list of conditions and the following
(...skipping 14 matching lines...) Expand all
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
26 # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 26 # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 # SUCH DAMAGE. 28 # SUCH DAMAGE.
29 29
30 import optparse 30 import optparse
31 import shutil 31 import shutil
32 import tempfile 32 import tempfile
33 import unittest2 as unittest 33 import unittest2 as unittest
34 34
35 from webkitpy.common.host import Host 35 from webkitpy.common.host_mock import MockHost
36 from webkitpy.common.system.filesystem_mock import MockFileSystem
36 from webkitpy.common.system.executive_mock import MockExecutive2, ScriptError 37 from webkitpy.common.system.executive_mock import MockExecutive2, ScriptError
37 from webkitpy.common.system.outputcapture import OutputCapture 38 from webkitpy.common.system.outputcapture import OutputCapture
38 from webkitpy.w3c.test_importer import TestImporter 39 from webkitpy.w3c.test_importer import TestImporter
39 40
40 41
41 DUMMY_SOURCE_DIR = '/w3c' 42 FAKE_SOURCE_DIR = '/blink/w3c'
42 DUMMY_REPO_DIR = '/blink/LayoutTests' 43 FAKE_REPO_DIR = '/blink'
44
45 FAKE_FILES = {
46 '/blink/w3c/empty_dir/README.txt': '',
47 '/mock-checkout/LayoutTests/w3c/README.txt': '',
48 }
43 49
44 class TestImporterTest(unittest.TestCase): 50 class TestImporterTest(unittest.TestCase):
45 51
46 def test_import_dir_with_no_tests_and_no_hg(self): 52 def test_import_dir_with_no_tests_and_no_hg(self):
47 # FIXME: Use MockHosts instead. 53 host = MockHost()
48 host = Host()
49 host.executive = MockExecutive2(exception=OSError()) 54 host.executive = MockExecutive2(exception=OSError())
55 host.filesystem = MockFileSystem(files=FAKE_FILES)
50 56
51 importer = TestImporter(host, DUMMY_SOURCE_DIR, DUMMY_REPO_DIR, optparse .Values({"overwrite": False})) 57 importer = TestImporter(host, FAKE_SOURCE_DIR, FAKE_REPO_DIR, optparse.V alues({"overwrite": False}))
52 importer.source_directory = importer.path_from_webkit_root("Tools", "Scr ipts", "webkitpy", "w3c")
53 importer.destination_directory = tempfile.mkdtemp(prefix='csswg')
54 58
55 oc = OutputCapture() 59 oc = OutputCapture()
56 oc.capture_output() 60 oc.capture_output()
57 try: 61 try:
58 importer.do_import() 62 importer.do_import()
59 finally: 63 finally:
60 oc.restore_output() 64 oc.restore_output()
61 shutil.rmtree(importer.destination_directory, ignore_errors=True)
62 65
63 def test_import_dir_with_no_tests(self): 66 def test_import_dir_with_no_tests(self):
64 # FIXME: Use MockHosts instead. 67 host = MockHost()
65 host = Host()
66 host.executive = MockExecutive2(exception=ScriptError("abort: no reposit ory found in '/Volumes/Source/src/wk/Tools/Scripts/webkitpy/w3c' (.hg not found) !")) 68 host.executive = MockExecutive2(exception=ScriptError("abort: no reposit ory found in '/Volumes/Source/src/wk/Tools/Scripts/webkitpy/w3c' (.hg not found) !"))
69 host.filesystem = MockFileSystem(files=FAKE_FILES)
67 70
68 importer = TestImporter(host, '/w3c', '/blink', optparse.Values({"overwr ite": False})) 71 importer = TestImporter(host, FAKE_SOURCE_DIR, FAKE_REPO_DIR, optparse.V alues({"overwrite": False}))
69 importer.source_directory = importer.path_from_webkit_root("Tools", "Scr ipts", "webkitpy", "w3c")
70 importer.destination_directory = tempfile.mkdtemp(prefix='csswg')
71
72 oc = OutputCapture() 72 oc = OutputCapture()
73 oc.capture_output() 73 oc.capture_output()
74 try: 74 try:
75 importer.do_import() 75 importer.do_import()
76 finally: 76 finally:
77 oc.restore_output() 77 oc.restore_output()
78 shutil.rmtree(importer.destination_directory, ignore_errors=True)
79 78
80 # FIXME: Need more tests, but need to add a mock filesystem w/ sample data. 79 # FIXME: Needs more tests.
OLDNEW
« no previous file with comments | « Tools/Scripts/webkitpy/w3c/test_importer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698