summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--native_client_sdk/src/build_tools/sdk_tools/command/update.py18
-rwxr-xr-xnative_client_sdk/src/build_tools/tests/sdktools_commands_test.py24
2 files changed, 32 insertions, 10 deletions
diff --git a/native_client_sdk/src/build_tools/sdk_tools/command/update.py b/native_client_sdk/src/build_tools/sdk_tools/command/update.py
index 674c6e9..c8fb943 100644
--- a/native_client_sdk/src/build_tools/sdk_tools/command/update.py
+++ b/native_client_sdk/src/build_tools/sdk_tools/command/update.py
@@ -131,8 +131,8 @@ class RealUpdateDelegate(UpdateDelegate):
def Update(delegate, remote_manifest, local_manifest, bundle_names, force):
valid_bundles = set([bundle.name for bundle in remote_manifest.GetBundles()])
- requested_bundles = _GetRequestedBundlesFromArgs(remote_manifest,
- bundle_names)
+ requested_bundles = _GetRequestedBundleNamesFromArgs(remote_manifest,
+ bundle_names)
invalid_bundles = requested_bundles - valid_bundles
if invalid_bundles:
logging.warn('Ignoring unknown bundle(s): %s' % (
@@ -175,17 +175,17 @@ def UpdateBundleIfNeeded(delegate, remote_manifest, local_manifest,
logging.error('Bundle %s does not exist.' % (bundle_name,))
-def _GetRequestedBundlesFromArgs(remote_manifest, requested_bundles):
+def _GetRequestedBundleNamesFromArgs(remote_manifest, requested_bundles):
requested_bundles = set(requested_bundles)
if RECOMMENDED in requested_bundles:
requested_bundles.discard(RECOMMENDED)
- requested_bundles |= set(_GetRecommendedBundles(remote_manifest))
+ requested_bundles |= set(_GetRecommendedBundleNames(remote_manifest))
return requested_bundles
-def _GetRecommendedBundles(remote_manifest):
- return [bundle for bundle in remote_manifest.GetBundles() if
+def _GetRecommendedBundleNames(remote_manifest):
+ return [bundle.name for bundle in remote_manifest.GetBundles() if
bundle.recommended]
@@ -217,15 +217,15 @@ def _UpdateBundle(delegate, bundle, local_manifest):
if repath_dir:
# If repath is specified:
# The files are extracted to nacl_sdk/<bundle.name>_update/<repath>/...
- # The destination directory is nacl_sdk/<repath>/...
+ # The destination directory is nacl_sdk/<bundle.name>/...
rename_from_dir = os.path.join(extract_dir, repath_dir)
- rename_to_dir = repath_dir
else:
# If no repath is specified:
# The files are extracted to nacl_sdk/<bundle.name>_update/...
# The destination directory is nacl_sdk/<bundle.name>/...
rename_from_dir = extract_dir
- rename_to_dir = bundle.name
+
+ rename_to_dir = bundle.name
delegate.ExtractArchive(dest_filename, extract_dir, rename_from_dir,
rename_to_dir)
diff --git a/native_client_sdk/src/build_tools/tests/sdktools_commands_test.py b/native_client_sdk/src/build_tools/tests/sdktools_commands_test.py
index 113ec9d..25c10a0 100755
--- a/native_client_sdk/src/build_tools/tests/sdktools_commands_test.py
+++ b/native_client_sdk/src/build_tools/tests/sdktools_commands_test.py
@@ -222,6 +222,28 @@ class TestCommands(SdkToolsTestCase):
output = self._Run(['update', 'foobar'])
self.assertTrue('unknown bundle' in output)
+ def testUpdateRecommended(self):
+ """The update command should update only recommended bundles when run
+ without args.
+ """
+ bundle = self._AddDummyBundle(self.manifest, 'pepper_26')
+ bundle.recommended = 'yes'
+ self._WriteManifest()
+ output = self._Run(['update'])
+ self.assertTrue(os.path.exists(
+ os.path.join(self.basedir, 'nacl_sdk', 'pepper_26', 'dummy.txt')))
+
+ def testUpdateCanary(self):
+ """The update command should create the correct directory name for repath'd
+ bundles.
+ """
+ bundle = self._AddDummyBundle(self.manifest, 'pepper_26')
+ bundle.name = 'pepper_canary'
+ self._WriteManifest()
+ output = self._Run(['update'])
+ self.assertTrue(os.path.exists(
+ os.path.join(self.basedir, 'nacl_sdk', 'pepper_canary', 'dummy.txt')))
+
if __name__ == '__main__':
- sys.exit(unittest.main())
+ unittest.main()