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

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

Issue 2838843002: [tools] add script to simplify backporting patch to Node.js (Closed)
Patch Set: address comments Created 3 years, 7 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 | « tools/release/backport_node.py ('k') | 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
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 import os
7 import shutil
8 import subprocess
9 import sys
10 import tempfile
11 import unittest
12
13 import backport_node
14
15 # Base paths.
16 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
17 TEST_DATA = os.path.join(BASE_DIR, 'testdata')
18
19 def gitify(path):
20 files = os.listdir(path)
21 subprocess.check_call(['git', 'init'], cwd=path)
22 subprocess.check_call(['git', 'add'] + files, cwd=path)
23 subprocess.check_call(['git', 'commit', '-m', 'Initial'], cwd=path)
24
25 class TestUpdateNode(unittest.TestCase):
26 def setUp(self):
27 self.workdir = tempfile.mkdtemp(prefix='tmp_test_node_')
28
29 def tearDown(self):
30 shutil.rmtree(self.workdir)
31
32 def testUpdate(self):
33 v8_cwd = os.path.join(self.workdir, 'v8')
34 node_cwd = os.path.join(self.workdir, 'node')
35
36 # Set up V8 test fixture.
37 shutil.copytree(src=os.path.join(TEST_DATA, 'v8'), dst=v8_cwd)
38 gitify(v8_cwd)
39
40 # Set up node test fixture.
41 shutil.copytree(src=os.path.join(TEST_DATA, 'node'), dst=node_cwd)
42 gitify(os.path.join(node_cwd))
43
44 # Add a patch.
45 with open(os.path.join(v8_cwd, 'v8_foo'), 'w') as f:
46 f.write('zonk')
47 subprocess.check_call(['git', 'add', 'v8_foo'], cwd=v8_cwd)
48 subprocess.check_call(['git', 'commit', '-m', "Title\n\nBody"], cwd=v8_cwd)
49 commit = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=v8_cwd).s trip()
50
51 # Run update script.
52 backport_node.Main([v8_cwd, node_cwd, commit, "--no-review"])
53
54 # Check message.
55 message = subprocess.check_output(['git', 'log', '-1', '--format=%B'], cwd=n ode_cwd)
56 self.assertIn('Original commit message:\n\n Title\n\n Body', message)
57
58 # Check patch.
59 gitlog = subprocess.check_output(
60 ['git', 'diff', 'master', '--cached', '--', 'deps/v8/v8_foo'],
61 cwd=node_cwd,
62 )
63 self.assertIn('+zonk', gitlog.strip())
64
65 if __name__ == "__main__":
66 unittest.main()
OLDNEW
« no previous file with comments | « tools/release/backport_node.py ('k') | tools/release/update_node.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698