539e907258
This is the V8 equivalent to https://crrev.com/2779193002 and must be landed before //build/secondary/{gtest,gmock} are removed from Chromium. This started out as https://crrev.com/2847693002 The changes in tools/ were authored by yangguo@chromium.org and initially shared in http://crrev.com/2849783003. GoogleTest (gtest) and GoogleMock (gmock) are now hosted into the same googletest repository. In order to cope with this, the googletest repository is now sourced at third_party/googletest. The file/directory layout of Google Test is not yet considered stable. To minimize disruption while Google Test stabilizes, Chromium code will be insulated from third_party/googletest. * testing/gtest/include/gtest/ and testing/gmock/include/gmock have been populated with headers that forward into the appropriate locations of third_party/googletest * testing/BUILD.gn has been populated with the targets //testing/gtest(:gtest_main) and //testing/gmock(:gmock_main), which depend on the appropriate //third_party/googletest targets. All Chromium code should keep depending on the targets and headers in testing/{gtest,gmock} for now. BUG=chromium:630705 Change-Id: I12b07ae78c8039aeff6ada7a3335e4e2b5d308ab Reviewed-on: https://chromium-review.googlesource.com/639953 Reviewed-by: Michael Achenbach <machenbach@chromium.org> Commit-Queue: Victor Costan <pwnall@chromium.org> Cr-Commit-Position: refs/heads/master@{#52170}
126 lines
3.9 KiB
Python
Executable File
126 lines
3.9 KiB
Python
Executable File
#!/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 = """
|
|
/third_party/googletest/*
|
|
!/third_party/googletest/src
|
|
/third_party/googletest/src/*
|
|
!/third_party/googletest/src/googletest
|
|
/third_party/googletest/src/googletest/*
|
|
!/third_party/googletest/src/googletest/include
|
|
/third_party/googletest/src/googletest/include/*
|
|
!/third_party/googletest/src/googletest/include/gtest
|
|
/third_party/googletest/src/googletest/include/gtest/*
|
|
!/third_party/googletest/src/googletest/include/gtest/gtest_prod.h
|
|
!/third_party/jinja2
|
|
!/third_party/markupsafe
|
|
/unrelated
|
|
"""
|
|
|
|
EXPECTED_GIT_DIFF = """
|
|
create mode 100644 deps/v8/base/trace_event/common/common
|
|
rename deps/v8/baz/{delete_me => v8_new} (100%)
|
|
delete mode 100644 deps/v8/include/v8-version.h
|
|
rename deps/v8/{delete_me => new/v8_new} (100%)
|
|
create mode 100644 deps/v8/third_party/googletest/src/googletest/include/gtest/gtest_prod.h
|
|
create mode 100644 deps/v8/third_party/jinja2/jinja2
|
|
create mode 100644 deps/v8/third_party/markupsafe/markupsafe
|
|
create mode 100644 deps/v8/v8_new
|
|
"""
|
|
|
|
ADDED_FILES = [
|
|
'v8_new',
|
|
'new/v8_new',
|
|
'baz/v8_new',
|
|
'/third_party/googletest/src/googletest/include/gtest/gtest_new',
|
|
'/third_party/googletest/src/googletest/include/gtest/new/gtest_new',
|
|
'/third_party/googletest/src/googletest/include/gtest/baz/gtest_new',
|
|
'third_party/jinja2/jinja2',
|
|
'third_party/markupsafe/markupsafe'
|
|
]
|
|
|
|
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')
|
|
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))
|
|
|
|
# Set up node test fixture.
|
|
shutil.copytree(src=os.path.join(TEST_DATA, 'node'), dst=node_cwd)
|
|
gitify(os.path.join(node_cwd))
|
|
|
|
# Add a patch.
|
|
with open(os.path.join(v8_cwd, 'v8_foo'), 'w') as f:
|
|
f.write('zonk')
|
|
subprocess.check_call(['git', 'add', 'v8_foo'], cwd=v8_cwd)
|
|
|
|
# Run update script.
|
|
update_node.Main([v8_cwd, node_cwd, "--commit", "--with-patch"])
|
|
|
|
# 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))
|
|
gitlog = subprocess.check_output(
|
|
['git', 'diff', 'master', '--summary'],
|
|
cwd=node_cwd,
|
|
)
|
|
self.assertEquals(EXPECTED_GIT_DIFF.strip(), gitlog.strip())
|
|
|
|
# Check patch.
|
|
gitlog = subprocess.check_output(
|
|
['git', 'diff', 'master', '--cached', '--', 'deps/v8/v8_foo'],
|
|
cwd=node_cwd,
|
|
)
|
|
self.assertIn('+zonk', gitlog.strip())
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|