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

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

Issue 2747123002: Add --commit option and some polish to update_node.py. (Closed)
Patch Set: address comments 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/update_node.py » ('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 11 matching lines...) Expand all
22 !/testing/gtest/include 22 !/testing/gtest/include
23 /testing/gtest/include/* 23 /testing/gtest/include/*
24 !/testing/gtest/include/gtest 24 !/testing/gtest/include/gtest
25 /testing/gtest/include/gtest/* 25 /testing/gtest/include/gtest/*
26 !/testing/gtest/include/gtest/gtest_prod.h 26 !/testing/gtest/include/gtest/gtest_prod.h
27 !/third_party/jinja2 27 !/third_party/jinja2
28 !/third_party/markupsafe 28 !/third_party/markupsafe
29 /unrelated 29 /unrelated
30 """ 30 """
31 31
32 EXPECTED_GIT_DIFF = """
33 rename deps/v8/baz/{delete_me => v8_new} (100%)
34 rename deps/v8/{delete_me => new/v8_new} (100%)
35 create mode 100644 deps/v8/third_party/jinja2/jinja2
36 create mode 100644 deps/v8/third_party/markupsafe/markupsafe
37 create mode 100644 deps/v8/v8_new
38 """
39
32 ADDED_FILES = [ 40 ADDED_FILES = [
33 'v8_new', 41 'v8_new',
34 'new/v8_new', 42 'new/v8_new',
35 'baz/v8_new', 43 'baz/v8_new',
36 'testing/gtest/gtest_new', 44 'testing/gtest/gtest_new',
37 'testing/gtest/new/gtest_new', 45 'testing/gtest/new/gtest_new',
38 'testing/gtest/baz/gtest_new', 46 'testing/gtest/baz/gtest_new',
39 'third_party/jinja2/jinja2', 47 'third_party/jinja2/jinja2',
40 'third_party/markupsafe/markupsafe' 48 'third_party/markupsafe/markupsafe'
41 ] 49 ]
42 50
43 REMOVED_FILES = [ 51 REMOVED_FILES = [
44 'delete_me', 52 'delete_me',
45 'baz/delete_me', 53 'baz/delete_me',
46 'testing/gtest/delete_me', 54 'testing/gtest/delete_me',
47 'testing/gtest/baz/delete_me', 55 'testing/gtest/baz/delete_me',
48 ] 56 ]
49 57
50 def gitify(path): 58 def gitify(path):
51 files = os.listdir(path) 59 files = os.listdir(path)
52 subprocess.check_call(['git', 'init'], cwd=path) 60 subprocess.check_call(['git', 'init'], cwd=path)
53 subprocess.check_call(['git', 'add'] + files, cwd=path) 61 subprocess.check_call(['git', 'add'] + files, cwd=path)
54 subprocess.check_call(['git', 'commit', '-m="Initial"'], cwd=path) 62 subprocess.check_call(['git', 'commit', '-m', 'Initial'], cwd=path)
55 63
56 64
57 class TestUpdateNode(unittest.TestCase): 65 class TestUpdateNode(unittest.TestCase):
58 def setUp(self): 66 def setUp(self):
59 self.workdir = tempfile.mkdtemp(prefix='tmp_test_node_') 67 self.workdir = tempfile.mkdtemp(prefix='tmp_test_node_')
60 68
61 def tearDown(self): 69 def tearDown(self):
62 shutil.rmtree(self.workdir) 70 shutil.rmtree(self.workdir)
63 71
64 def testUpdate(self): 72 def testUpdate(self):
65 v8_cwd = os.path.join(self.workdir, 'v8') 73 v8_cwd = os.path.join(self.workdir, 'v8')
66 node_cwd = os.path.join(self.workdir, 'node') 74 node_cwd = os.path.join(self.workdir, 'node')
67 75
68 # Set up V8 test fixture. 76 # Set up V8 test fixture.
69 shutil.copytree(src=os.path.join(TEST_DATA, 'v8'), dst=v8_cwd) 77 shutil.copytree(src=os.path.join(TEST_DATA, 'v8'), dst=v8_cwd)
70 gitify(v8_cwd) 78 gitify(v8_cwd)
71 for repository in update_node.SUB_REPOSITORIES: 79 for repository in update_node.SUB_REPOSITORIES:
72 gitify(os.path.join(v8_cwd, *repository)) 80 gitify(os.path.join(v8_cwd, *repository))
73 81
74 # Set up node test fixture (no git repo required). 82 # Set up node test fixture.
75 shutil.copytree(src=os.path.join(TEST_DATA, 'node'), dst=node_cwd) 83 shutil.copytree(src=os.path.join(TEST_DATA, 'node'), dst=node_cwd)
84 gitify(os.path.join(node_cwd))
76 85
77 # Run update script. 86 # Run update script.
78 update_node.Main([v8_cwd, node_cwd]) 87 update_node.Main([v8_cwd, node_cwd, "--commit"])
79 88
80 # Check expectations. 89 # Check expectations.
81 with open(os.path.join(node_cwd, 'deps', 'v8', '.gitignore')) as f: 90 with open(os.path.join(node_cwd, 'deps', 'v8', '.gitignore')) as f:
82 actual_gitignore = f.read() 91 actual_gitignore = f.read()
83 self.assertEquals(EXPECTED_GITIGNORE.strip(), actual_gitignore.strip()) 92 self.assertEquals(EXPECTED_GITIGNORE.strip(), actual_gitignore.strip())
84 for f in ADDED_FILES: 93 for f in ADDED_FILES:
85 added_file = os.path.join(node_cwd, 'deps', 'v8', *f.split('/')) 94 added_file = os.path.join(node_cwd, 'deps', 'v8', *f.split('/'))
86 self.assertTrue(os.path.exists(added_file)) 95 self.assertTrue(os.path.exists(added_file))
87 for f in REMOVED_FILES: 96 for f in REMOVED_FILES:
88 removed_file = os.path.join(node_cwd, 'deps', 'v8', *f.split('/')) 97 removed_file = os.path.join(node_cwd, 'deps', 'v8', *f.split('/'))
89 self.assertFalse(os.path.exists(removed_file)) 98 self.assertFalse(os.path.exists(removed_file))
99 gitlog = subprocess.check_output(['git', 'diff', 'master', '--summary'],
100 cwd=node_cwd)
101 self.assertEquals(EXPECTED_GIT_DIFF.strip(), gitlog.strip())
90 102
91 if __name__ == "__main__": 103 if __name__ == "__main__":
92 unittest.main() 104 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | tools/release/update_node.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698