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

Unified Diff: tools/release/test_update_node.py

Issue 2744663005: Add script to update relevant changes to Node.js. (Closed)
Patch Set: address nits 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/release/testdata/node/deps/v8/.gitignore » ('j') | tools/release/update_node.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/release/test_update_node.py
diff --git a/tools/release/test_update_node.py b/tools/release/test_update_node.py
new file mode 100755
index 0000000000000000000000000000000000000000..82023d8f6feff4c07c45dd2a356b4f3292b9bd5f
--- /dev/null
+++ b/tools/release/test_update_node.py
@@ -0,0 +1,91 @@
+#!/usr/bin/env python
+# Copyright 2017 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import shutil
+import subprocess
+import sys
+import tempfile
+import unittest
+
+import update_node
+
+# Base paths.
+BASE_DIR = os.path.dirname(os.path.abspath(__file__))
+TEST_DATA = os.path.join(BASE_DIR, 'testdata')
+
+# Expectations.
+EXPECTED_GITIGNORE = """
+/testing/gtest/*
+!/testing/gtest/include
+/testing/gtest/include/*
+!/testing/gtest/include/gtest
+/testing/gtest/include/gtest/*
+!/testing/gtest/include/gtest/gtest_prod.h
+!/third_party/jinja2
+!/third_party/markupsafe
+/unrelated
+"""
+
+ADDED_FILES = [
+ 'v8_new',
+ 'new/v8_new',
+ 'baz/v8_new',
+ 'testing/gtest/gtest_new',
+ 'testing/gtest/new/gtest_new',
+ 'testing/gtest/baz/gtest_new',
Michael Achenbach 2017/03/14 08:37:26 nit: The files from marupsafe and jinja2 could be
+]
+
+REMOVED_FILES = [
+ 'delete_me',
+ 'baz/delete_me',
+ 'testing/gtest/delete_me',
+ 'testing/gtest/baz/delete_me',
+]
+
+def gitify(path):
+ files = os.listdir(path)
+ subprocess.check_call(['git', 'init'], cwd=path)
+ subprocess.check_call(['git', 'add'] + files, cwd=path)
+ subprocess.check_call(['git', 'commit', '-m="Initial"'], cwd=path)
+
+
+class TestUpdateNode(unittest.TestCase):
+ def setUp(self):
+ self.workdir = tempfile.mkdtemp(prefix='tmp_test_node_')
+
+ def tearDown(self):
+ shutil.rmtree(self.workdir)
+
+ def testUpdate(self):
+ v8_cwd = os.path.join(self.workdir, 'v8')
+ gtest_cwd = os.path.join(self.workdir, 'v8', 'testing', 'gtest')
+ node_cwd = os.path.join(self.workdir, 'node')
+
+ # Set up V8 test fixture.
+ shutil.copytree(src=os.path.join(TEST_DATA, 'v8'), dst=v8_cwd)
+ gitify(v8_cwd)
+ for repository in update_node.SUB_REPOSITORIES:
+ gitify(os.path.join(v8_cwd, *repository))
Yang 2017/03/14 08:26:27 They are gitified here :)
Michael Achenbach 2017/03/14 08:37:26 Ah right, then this nit: Unused variable gtest_cwd
+
+ # Set up node test fixture (no git repo required).
+ shutil.copytree(src=os.path.join(TEST_DATA, 'node'), dst=node_cwd)
+
+ # Run update script.
+ update_node.Main([v8_cwd, node_cwd])
+
+ # Check expectations.
+ with open(os.path.join(node_cwd, 'deps', 'v8', '.gitignore')) as f:
+ actual_gitignore = f.read()
+ self.assertEquals(EXPECTED_GITIGNORE.strip(), actual_gitignore.strip())
+ for f in ADDED_FILES:
+ added_file = os.path.join(node_cwd, 'deps', 'v8', *f.split('/'))
+ self.assertTrue(os.path.exists(added_file))
+ for f in REMOVED_FILES:
+ removed_file = os.path.join(node_cwd, 'deps', 'v8', *f.split('/'))
+ self.assertFalse(os.path.exists(removed_file))
+
+if __name__ == "__main__":
+ unittest.main()
« no previous file with comments | « no previous file | tools/release/testdata/node/deps/v8/.gitignore » ('j') | tools/release/update_node.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698