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

Side by Side Diff: tools/release/test_update_node.py

Issue 2751513003: Small fixes to update_node.py. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | tools/release/testdata/v8/.gitignore » ('j') | 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 # Copyright 2017 the V8 project authors. All rights reserved. 2 # Copyright 2017 the V8 project authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import os 6 import os
7 import shutil 7 import shutil
8 import subprocess 8 import subprocess
9 import sys 9 import sys
10 import tempfile 10 import tempfile
(...skipping 18 matching lines...) Expand all
29 /unrelated 29 /unrelated
30 """ 30 """
31 31
32 ADDED_FILES = [ 32 ADDED_FILES = [
33 'v8_new', 33 'v8_new',
34 'new/v8_new', 34 'new/v8_new',
35 'baz/v8_new', 35 'baz/v8_new',
36 'testing/gtest/gtest_new', 36 'testing/gtest/gtest_new',
37 'testing/gtest/new/gtest_new', 37 'testing/gtest/new/gtest_new',
38 'testing/gtest/baz/gtest_new', 38 'testing/gtest/baz/gtest_new',
39 'third_party/jinja2/jinja2',
40 'third_party/markupsafe/markupsafe'
39 ] 41 ]
40 42
41 REMOVED_FILES = [ 43 REMOVED_FILES = [
42 'delete_me', 44 'delete_me',
43 'baz/delete_me', 45 'baz/delete_me',
44 'testing/gtest/delete_me', 46 'testing/gtest/delete_me',
45 'testing/gtest/baz/delete_me', 47 'testing/gtest/baz/delete_me',
46 ] 48 ]
47 49
48 def gitify(path): 50 def gitify(path):
49 files = os.listdir(path) 51 files = os.listdir(path)
50 subprocess.check_call(['git', 'init'], cwd=path) 52 subprocess.check_call(['git', 'init'], cwd=path)
51 subprocess.check_call(['git', 'add'] + files, cwd=path) 53 subprocess.check_call(['git', 'add'] + files, cwd=path)
52 subprocess.check_call(['git', 'commit', '-m="Initial"'], cwd=path) 54 subprocess.check_call(['git', 'commit', '-m="Initial"'], cwd=path)
53 55
54 56
55 class TestUpdateNode(unittest.TestCase): 57 class TestUpdateNode(unittest.TestCase):
56 def setUp(self): 58 def setUp(self):
57 self.workdir = tempfile.mkdtemp(prefix='tmp_test_node_') 59 self.workdir = tempfile.mkdtemp(prefix='tmp_test_node_')
58 60
59 def tearDown(self): 61 def tearDown(self):
60 shutil.rmtree(self.workdir) 62 shutil.rmtree(self.workdir)
61 63
62 def testUpdate(self): 64 def testUpdate(self):
63 v8_cwd = os.path.join(self.workdir, 'v8') 65 v8_cwd = os.path.join(self.workdir, 'v8')
64 gtest_cwd = os.path.join(self.workdir, 'v8', 'testing', 'gtest')
65 node_cwd = os.path.join(self.workdir, 'node') 66 node_cwd = os.path.join(self.workdir, 'node')
66 67
67 # Set up V8 test fixture. 68 # Set up V8 test fixture.
68 shutil.copytree(src=os.path.join(TEST_DATA, 'v8'), dst=v8_cwd) 69 shutil.copytree(src=os.path.join(TEST_DATA, 'v8'), dst=v8_cwd)
69 gitify(v8_cwd) 70 gitify(v8_cwd)
70 for repository in update_node.SUB_REPOSITORIES: 71 for repository in update_node.SUB_REPOSITORIES:
71 gitify(os.path.join(v8_cwd, *repository)) 72 gitify(os.path.join(v8_cwd, *repository))
72 73
73 # Set up node test fixture (no git repo required). 74 # Set up node test fixture (no git repo required).
74 shutil.copytree(src=os.path.join(TEST_DATA, 'node'), dst=node_cwd) 75 shutil.copytree(src=os.path.join(TEST_DATA, 'node'), dst=node_cwd)
75 76
76 # Run update script. 77 # Run update script.
77 update_node.Main([v8_cwd, node_cwd]) 78 update_node.Main([v8_cwd, node_cwd])
78 79
79 # Check expectations. 80 # Check expectations.
80 with open(os.path.join(node_cwd, 'deps', 'v8', '.gitignore')) as f: 81 with open(os.path.join(node_cwd, 'deps', 'v8', '.gitignore')) as f:
81 actual_gitignore = f.read() 82 actual_gitignore = f.read()
82 self.assertEquals(EXPECTED_GITIGNORE.strip(), actual_gitignore.strip()) 83 self.assertEquals(EXPECTED_GITIGNORE.strip(), actual_gitignore.strip())
83 for f in ADDED_FILES: 84 for f in ADDED_FILES:
84 added_file = os.path.join(node_cwd, 'deps', 'v8', *f.split('/')) 85 added_file = os.path.join(node_cwd, 'deps', 'v8', *f.split('/'))
85 self.assertTrue(os.path.exists(added_file)) 86 self.assertTrue(os.path.exists(added_file))
86 for f in REMOVED_FILES: 87 for f in REMOVED_FILES:
87 removed_file = os.path.join(node_cwd, 'deps', 'v8', *f.split('/')) 88 removed_file = os.path.join(node_cwd, 'deps', 'v8', *f.split('/'))
88 self.assertFalse(os.path.exists(removed_file)) 89 self.assertFalse(os.path.exists(removed_file))
89 90
90 if __name__ == "__main__": 91 if __name__ == "__main__":
91 unittest.main() 92 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | tools/release/testdata/v8/.gitignore » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698