Commit 06b7bad4 authored by Robert Ma's avatar Robert Ma Committed by Commit Bot

[wpt-import] Set the executable bit for .bat files

Originally, I tried to use shutil.copy to preserve the mode of the
files, but I found out there were tons of permission violations in the
upstream, so I filed a bug * and tweaked the existing workaround.

* https://github.com/web-platform-tests/wpt/issues/23997

Bug: 1091205
Change-Id: Id54c466192d671c758f04fcdf81b51eb9ebdf070
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2231264
Commit-Queue: Robert Ma <robertma@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Auto-Submit: Robert Ma <robertma@chromium.org>
Reviewed-by: default avatarStephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775246}
parent 6052791a
......@@ -155,14 +155,14 @@ class TestCopier(object):
w3c_import_expectations_path):
if line.is_glob:
_log.warning(
'W3CImportExpectations:%d Globs are not allowed in this file.'
% line.lineno)
'W3CImportExpectations:%d Globs are not allowed in this file.',
line.lineno)
continue
if ResultType.Skip in line.results:
if line.tags:
_log.warning(
'W3CImportExpectations:%d should not have any specifiers'
% line.lineno)
'W3CImportExpectations:%d should not have any specifiers',
line.lineno)
paths_to_skip.add(line.test)
return paths_to_skip
......@@ -235,5 +235,7 @@ class TestCopier(object):
if not self.import_in_place:
self.filesystem.copyfile(source_path, dest_path)
if self.filesystem.read_binary_file(source_path)[:2] == '#!':
# Fix perms: https://github.com/web-platform-tests/wpt/issues/23997
if self.filesystem.read_binary_file(source_path)[:2] == '#!' or \
self.filesystem.splitext(source_path)[1].lower() == '.bat':
self.filesystem.make_executable(dest_path)
......@@ -38,6 +38,7 @@ FAKE_SOURCE_REPO_DIR = '/blink'
FAKE_FILES = {
MOCK_WEB_TESTS + 'external/OWNERS': '',
'/blink/w3c/dir/run.bat': '',
'/blink/w3c/dir/has_shebang.txt': '#!',
'/blink/w3c/dir/README.txt': '',
'/blink/w3c/dir/OWNERS': '',
......@@ -62,6 +63,9 @@ class TestCopierTest(LoggingTestCase):
copier.find_importable_tests()
self.assertEqual(copier.import_list, [{
'copy_list': [{
'dest': 'run.bat',
'src': '/blink/w3c/dir/run.bat'
}, {
'dest': 'has_shebang.txt',
'src': '/blink/w3c/dir/has_shebang.txt'
}, {
......@@ -79,6 +83,9 @@ class TestCopierTest(LoggingTestCase):
copier.find_importable_tests()
self.assertEqual(copier.import_list, [{
'copy_list': [{
'dest': 'run.bat',
'src': '/blink/w3c/dir/run.bat'
}, {
'dest': 'has_shebang.txt',
'src': '/blink/w3c/dir/has_shebang.txt'
}, {
......@@ -89,14 +96,17 @@ class TestCopierTest(LoggingTestCase):
'/blink/w3c/dir',
}])
def test_files_with_shebang_are_made_executable(self):
def test_executable_files(self):
# Files with shebangs or .bat files need to be made executable.
host = MockHost()
host.filesystem = MockFileSystem(files=FAKE_FILES)
copier = TestCopier(host, FAKE_SOURCE_REPO_DIR)
copier.do_import()
self.assertEqual(
host.filesystem.executable_files,
set([MOCK_WEB_TESTS + 'external/blink/w3c/dir/has_shebang.txt']))
host.filesystem.executable_files, {
MOCK_WEB_TESTS + 'external/blink/w3c/dir/run.bat',
MOCK_WEB_TESTS + 'external/blink/w3c/dir/has_shebang.txt'
})
def test_ref_test_with_ref_is_copied(self):
host = MockHost()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment