Index: native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py |
diff --git a/native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py b/native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py |
index 8820b692b3042dfd16884c2d3584e20294f57644..c2ef9da8006facfa890d3946059b28d935898f3f 100755 |
--- a/native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py |
+++ b/native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py |
@@ -202,11 +202,10 @@ class MakeFiles(dict): |
class TestDelegate(update_nacl_manifest.Delegate): |
- def __init__(self, manifest, history, files, version_mapping): |
+ def __init__(self, manifest, history, files): |
self.manifest = manifest |
self.history = history |
self.files = files |
- self.version_mapping = version_mapping |
self.dryrun = 0 |
self.called_gsutil_cp = False |
self.called_sendmail = False |
@@ -217,16 +216,25 @@ class TestDelegate(update_nacl_manifest.Delegate): |
def GetHistory(self): |
return self.history |
- def GetTrunkRevision(self, version): |
- return self.version_mapping[version] |
- |
def GsUtil_ls(self, url): |
path = GetPathFromGsUrl(url) |
result = [] |
- for filename, _ in self.files.iteritems(): |
- if filename.startswith(path): |
- result.append(MakeGsUrl(filename)) |
- return result |
+ for filename in self.files.iterkeys(): |
+ if not filename.startswith(path): |
+ continue |
+ |
+ # Find the first slash after the prefix (path). |
+ # +1, because if the slash is directly after path, then we want to find |
+ # the following slash anyway. |
+ slash = filename.find('/', len(path) + 1) |
+ |
+ if slash != -1: |
+ filename = filename[:slash] |
+ |
+ result.append(MakeGsUrl(filename)) |
+ |
+ # Remove dupes. |
+ return list(set(result)) |
def GsUtil_cat(self, url): |
path = GetPathFromGsUrl(url) |
@@ -291,12 +299,10 @@ class TestUpdateManifest(unittest.TestCase): |
self.delegate = None |
self.uploaded_manifest = None |
self.manifest = None |
- # Ignore logging warnings, etc. |
- logging.getLogger('update_nacl_manifest').setLevel(logging.INFO) |
def _MakeDelegate(self): |
self.delegate = TestDelegate(self.manifest, self.history.history, |
- self.files, self.version_mapping) |
+ self.files) |
def _Run(self, host_oses, extra_archives=None, fixed_bundle_versions=None): |
update_nacl_manifest.Run(self.delegate, host_oses, extra_archives, |
@@ -479,47 +485,12 @@ class TestUpdateManifest(unittest.TestCase): |
self.assertEqual(uploaded_bundle.version, 18) |
def testUpdateCanary(self): |
- # Note that the bundle in naclsdk_manifest2.json will be called |
- # CANARY_BUNDLE_NAME, whereas the bundle in the manifest "snippet" will be |
- # called "pepper_21". |
- canary_bundle = copy.deepcopy(BCANARY_NONE) |
- self.manifest = MakeManifest(canary_bundle) |
- self.history.Add(OS_MW, CANARY, V21_0_1145_0) |
- self.files.Add(B21_0_1145_0_MLW) |
- self._MakeDelegate() |
- self._Run(OS_MLW) |
- self._ReadUploadedManifest() |
- self._AssertUploadedManifestHasBundle(B21_0_1145_0_MLW, CANARY, |
- bundle_name=CANARY_BUNDLE_NAME) |
- |
- def testUpdateCanaryUseTrunkArchives(self): |
- canary_bundle = copy.deepcopy(BCANARY_NONE) |
- self.manifest = MakeManifest(canary_bundle) |
- self.history.Add(OS_MW, CANARY, V21_0_1166_0) |
- self.files.Add(B21_0_1166_0_MW) |
- self.files.Add(BTRUNK_140819_MLW) |
- self.version_mapping[V21_0_1166_0] = VTRUNK_140819 |
- self._MakeDelegate() |
- self._Run(OS_MLW) |
- self._ReadUploadedManifest() |
- |
- test_bundle = copy.deepcopy(B21_0_1166_0_MW) |
- test_bundle.AddArchive(BTRUNK_140819_MLW.GetArchive('linux')) |
- self._AssertUploadedManifestHasBundle(test_bundle, CANARY, |
- bundle_name=CANARY_BUNDLE_NAME) |
- |
- def testCanaryUseOnlyTrunkArchives(self): |
self.manifest = MakeManifest(copy.deepcopy(BCANARY_NONE)) |
- history = """win,canary,21.0.1163.0,2012-06-04 12:35:44.784446 |
-mac,canary,21.0.1163.0,2012-06-04 11:54:09.433166""" |
- self._AddCsvHistory(history) |
- self.version_mapping['21.0.1163.0'] = 'trunk.140240' |
- my_bundle = MakePlatformBundle(21, 140240, '21.0.1163.0', OS_MLW) |
- self.files.Add(my_bundle) |
+ self.files.Add(BTRUNK_140819_MLW) |
self._MakeDelegate() |
self._Run(OS_MLW) |
self._ReadUploadedManifest() |
- self._AssertUploadedManifestHasBundle(my_bundle, CANARY, |
+ self._AssertUploadedManifestHasBundle(BTRUNK_140819_MLW, CANARY, |
bundle_name=CANARY_BUNDLE_NAME) |
def testCanaryShouldOnlyUseCanaryVersions(self): |
@@ -532,42 +503,6 @@ mac,canary,21.0.1163.0,2012-06-04 11:54:09.433166""" |
self._MakeDelegate() |
self.assertRaises(Exception, self._Run, OS_MLW) |
- def testMissingCanaryFollowedByStableShouldWork(self): |
- history = """win,canary,21.0.1160.0,2012-06-01 19:44:35.936109 |
-mac,canary,21.0.1160.0,2012-06-01 18:20:02.003123 |
-mac,stable,19.0.1084.52,2012-06-01 17:59:21.559710 |
-win,canary,21.0.1159.2,2012-06-01 02:31:43.877688 |
-mac,stable,19.0.1084.53,2012-06-01 01:39:57.549149 |
-win,canary,21.0.1158.0,2012-05-31 20:16:55.615236 |
-win,canary,21.0.1157.0,2012-05-31 17:41:29.516013 |
-mac,canary,21.0.1158.0,2012-05-31 17:41:27.591354 |
-mac,beta,20.0.1132.21,2012-05-30 23:45:38.535586 |
-linux,beta,20.0.1132.21,2012-05-30 23:45:37.025015 |
-cf,beta,20.0.1132.21,2012-05-30 23:45:36.767529 |
-win,beta,20.0.1132.21,2012-05-30 23:44:56.675123 |
-win,canary,21.0.1156.1,2012-05-30 22:28:01.872056 |
-mac,canary,21.0.1156.1,2012-05-30 21:20:29.920390 |
-win,canary,21.0.1156.0,2012-05-30 12:46:48.046627 |
-mac,canary,21.0.1156.0,2012-05-30 12:14:21.305090""" |
- self.manifest = MakeManifest(copy.deepcopy(BCANARY_NONE)) |
- self._AddCsvHistory(history) |
- self.version_mapping = { |
- '21.0.1160.0': 'trunk.139984', |
- '21.0.1159.2': 'trunk.139890', |
- '21.0.1158.0': 'trunk.139740', |
- '21.0.1157.0': 'unknown', |
- '21.0.1156.1': 'trunk.139576', |
- '21.0.1156.0': 'trunk.139984'} |
- self.files.Add(MakePlatformBundle(21, 139890, '21.0.1159.2', OS_MLW)) |
- self.files.Add(MakePlatformBundle(21, 0, '21.0.1157.1', ('linux', 'win'))) |
- my_bundle = MakePlatformBundle(21, 139576, '21.0.1156.1', OS_MLW) |
- self.files.Add(my_bundle) |
- self._MakeDelegate() |
- self._Run(OS_MLW) |
- self._ReadUploadedManifest() |
- self._AssertUploadedManifestHasBundle(my_bundle, CANARY, |
- bundle_name=CANARY_BUNDLE_NAME) |
- |
def testExtensionWorksAsBz2(self): |
# Allow old bundles with just .bz2 extension to work |
self.manifest = MakeManifest(B18_NONE) |
@@ -734,46 +669,6 @@ mac,canary,21.0.1156.0,2012-05-30 12:14:21.305090""" |
self.assertRaises(update_nacl_manifest.UnknownLockedBundleException, |
self._Run, OS_MLW) |
- def testIgnoreLastDigitOnCanary(self): |
- # The final number in a canary build does not include any different |
- # changes, it is just a different experiment (e.g. using ASAN, or using |
- # aura). We should not compare these versions differently. |
- # |
- # Note that the version mapping will show that 31.0.1608.0 is different |
- # from 31.0.1608.1 -- this is because 31.0.1608.1 is built from the branch, |
- # not from trunk. Inspecting the branch would show that there are no |
- # changes (why would there be? No one has any reason to merge changes to a |
- # canary branch.) |
- self.manifest = MakeManifest(copy.deepcopy(BCANARY_NONE)) |
- history = """win,canary,31.0.1608.1,2013-08-22 09:33:24.469760 |
-mac,canary,31.0.1608.0,2013-08-22 07:18:09.762600""" |
- self._AddCsvHistory(history) |
- self.version_mapping['31.0.1608.1'] = 'trunk.218914' |
- self.version_mapping['31.0.1608.0'] = 'trunk.218872' |
- my_bundle = MakePlatformBundle(31, 218872, '31.0.1608.0', OS_MLW) |
- self.files.Add(my_bundle) |
- self._MakeDelegate() |
- self._Run(OS_MLW) |
- self._ReadUploadedManifest() |
- self._AssertUploadedManifestHasBundle(my_bundle, CANARY, |
- bundle_name=CANARY_BUNDLE_NAME) |
- |
- def testDontIgnoreLastDigitForNonCanary(self): |
- self.manifest = MakeManifest(B26_NONE) |
- self.history.Add(OS_M, BETA, V26_0_1386_1) # Only Mac |
- self.history.Add(OS_LW, BETA, V26_0_1386_0) # Only Linux, Windows. |
- self.files.Add(B26_0_1386_0_MLW) |
- |
- self._MakeDelegate() |
- # This raises because pepper_26 is not found in the history, and therefore |
- # "locked", but it also doesn't have an online version, therefore there is |
- # no good version number to upload. |
- # |
- # Basically we're asserting that 26.0.1386.1 != 26.0.1386.0, which would be |
- # true if it were canary. |
- self.assertRaises(update_nacl_manifest.UnknownLockedBundleException, |
- self._Run, OS_MLW) |
- |
def testUpdateBionic(self): |
bionic_bundle = copy.deepcopy(BBIONIC_NONE) |
self.manifest = MakeManifest(bionic_bundle) |
@@ -825,21 +720,9 @@ class TestUpdateVitals(unittest.TestCase): |
self.assertEqual(archive['checksum']['sha1'], self.sha1) |
-class TestRealDelegate(unittest.TestCase): |
- def setUp(self): |
- self.delegate = update_nacl_manifest.RealDelegate() |
- |
- def testGetTrunkRevision(self): |
- revision_dict = { |
- '21.0.1180.80': '151582', |
- '23.0.1271.89': '167132', |
- '24.0.1305.4': '164971', |
- } |
- for version, revision in revision_dict.iteritems(): |
- self.assertEqual('trunk.%s' % revision, |
- self.delegate.GetTrunkRevision(version)) |
- |
- |
if __name__ == '__main__': |
- logging.basicConfig(level=logging.INFO) |
+ logging.basicConfig(level=logging.CRITICAL) |
+ # Uncomment the following line to enable more debugging info. |
+ # logging.getLogger('update_nacl_manifest').setLevel(logging.INFO) |
+ |
sys.exit(unittest.main()) |