Commit b552dda5 authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

mac: Fix signing scripts and tests running with Python 3.

The order of the get_parts() dict is different between 2 and 3, which
causes entitlements to be copied in different order. Fix this by sorting
the entitlements before processing.

Also fixes a bytes vs str issue and a set() stringification difference.

Change-Id: If3e5594ce1e9d505a2ce2e3042c35a257f121daf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2320414Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791939}
parent 6ba624b1
......@@ -33,7 +33,7 @@ def copy_dir_overwrite_and_count_changes(source, dest, dry_run=False):
]
if dry_run:
command.append('--dry-run')
output = subprocess.check_output(command)
output = subprocess.check_output(command).decode('utf-8')
# --itemize-changes will print a '.' in the first column if the item is not
# being updated, created, or deleted. This happens if only attributes
......
......@@ -148,7 +148,7 @@ def _process_entitlements(paths, dist, config):
for part in parts.get_parts(config).values()
if part.entitlements
]
for entitlements_name in entitlements_names:
for entitlements_name in sorted(entitlements_names):
entitlements_file = os.path.join(paths.work, entitlements_name)
commands.copy_files(
os.path.join(packaging_dir, entitlements_name), entitlements_file)
......
......@@ -101,11 +101,11 @@ class TestModification(unittest.TestCase):
'/$W/app-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-gpu-entitlements.plist',
'/$W/helper-gpu-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-plugin-entitlements.plist',
'/$W/helper-plugin-entitlements.plist'),
mock.call(
'/$I/Product Packaging/helper-renderer-entitlements.plist',
'/$W/helper-renderer-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-plugin-entitlements.plist',
'/$W/helper-plugin-entitlements.plist')
])
self.assertEqual(0, kwargs['move_file'].call_count)
self.assertEqual(0, kwargs['write_file'].call_count)
......@@ -135,11 +135,11 @@ class TestModification(unittest.TestCase):
'/$W/app-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-gpu-entitlements.plist',
'/$W/helper-gpu-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-plugin-entitlements.plist',
'/$W/helper-plugin-entitlements.plist'),
mock.call(
'/$I/Product Packaging/helper-renderer-entitlements.plist',
'/$W/helper-renderer-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-plugin-entitlements.plist',
'/$W/helper-plugin-entitlements.plist')
])
self.assertEqual(0, kwargs['move_file'].call_count)
......@@ -168,11 +168,11 @@ class TestModification(unittest.TestCase):
'/$W/app-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-gpu-entitlements.plist',
'/$W/helper-gpu-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-plugin-entitlements.plist',
'/$W/helper-plugin-entitlements.plist'),
mock.call(
'/$I/Product Packaging/helper-renderer-entitlements.plist',
'/$W/helper-renderer-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-plugin-entitlements.plist',
'/$W/helper-plugin-entitlements.plist')
])
self.assertEqual(0, kwargs['move_file'].call_count)
self.assertEqual(0, kwargs['write_file'].call_count)
......@@ -202,11 +202,11 @@ class TestModification(unittest.TestCase):
'/$W/app-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-gpu-entitlements.plist',
'/$W/helper-gpu-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-plugin-entitlements.plist',
'/$W/helper-plugin-entitlements.plist'),
mock.call(
'/$I/Product Packaging/helper-renderer-entitlements.plist',
'/$W/helper-renderer-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-plugin-entitlements.plist',
'/$W/helper-plugin-entitlements.plist')
])
self.assertEqual(0, kwargs['move_file'].call_count)
self.assertEqual(0, kwargs['write_file'].call_count)
......@@ -236,11 +236,11 @@ class TestModification(unittest.TestCase):
'/$W/app-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-gpu-entitlements.plist',
'/$W/helper-gpu-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-plugin-entitlements.plist',
'/$W/helper-plugin-entitlements.plist'),
mock.call(
'/$I/Product Packaging/helper-renderer-entitlements.plist',
'/$W/helper-renderer-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-plugin-entitlements.plist',
'/$W/helper-plugin-entitlements.plist')
])
kwargs['write_file'].assert_called_once_with(
'/$W/App Product.app/Contents/PkgInfo', 'APPLMooo')
......@@ -270,11 +270,11 @@ class TestModification(unittest.TestCase):
'/$W/app-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-gpu-entitlements.plist',
'/$W/helper-gpu-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-plugin-entitlements.plist',
'/$W/helper-plugin-entitlements.plist'),
mock.call(
'/$I/Product Packaging/helper-renderer-entitlements.plist',
'/$W/helper-renderer-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-plugin-entitlements.plist',
'/$W/helper-plugin-entitlements.plist')
])
self.assertEqual(0, kwargs['move_file'].call_count)
self.assertEqual(0, kwargs['write_file'].call_count)
......@@ -312,11 +312,11 @@ class TestModification(unittest.TestCase):
'/$W/app-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-gpu-entitlements.plist',
'/$W/helper-gpu-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-plugin-entitlements.plist',
'/$W/helper-plugin-entitlements.plist'),
mock.call(
'/$I/Product Packaging/helper-renderer-entitlements.plist',
'/$W/helper-renderer-entitlements.plist'),
mock.call('/$I/Product Packaging/helper-plugin-entitlements.plist',
'/$W/helper-plugin-entitlements.plist'),
mock.call('/$I/Product Packaging/app_canary.icns',
'/$W/App Product Canary.app/Contents/Resources/app.icns'),
mock.call(
......@@ -351,8 +351,8 @@ class TestModification(unittest.TestCase):
'test.signing.bundle_id.canary'
}, '/$W/app-entitlements.plist'),
mock.call({}, '/$W/helper-gpu-entitlements.plist'),
mock.call({}, '/$W/helper-renderer-entitlements.plist'),
mock.call({}, '/$W/helper-plugin-entitlements.plist'),
mock.call({}, '/$W/helper-renderer-entitlements.plist'),
mock.call({
'pfm_domain': 'test.signing.bundle_id.canary'
}, '/$W/App Product Canary.app/Contents/Resources/test.signing.bundle_id.canary.manifest/Contents/Resources/test.signing.bundle_id.canary.manifest'
......
......@@ -200,9 +200,12 @@ class TestWaitForResults(unittest.TestCase):
with self.assertRaises(notarize.NotarizationError) as cm:
list(notarize.wait_for_results(uuids, test_config.TestConfig()))
self.assertEqual(
"Timed out waiting for notarization requests: set(['0c652bb4-7d44-4904-8c59-1ee86a376ece'])",
str(cm.exception))
# Python 2 and 3 stringify set() differently.
self.assertIn(
str(cm.exception), [
"Timed out waiting for notarization requests: set(['0c652bb4-7d44-4904-8c59-1ee86a376ece'])",
"Timed out waiting for notarization requests: {'0c652bb4-7d44-4904-8c59-1ee86a376ece'}"
])
for call in kwargs['run_command_output'].mock_calls:
self.assertEqual(
......
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