Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: scripts/common/archive_utils_unittest.py

Issue 2407183003: Revert of Enable saving the same file in multiple archives (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « scripts/common/archive_utils.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import optparse 6 import optparse
7 import os 7 import os
8 import shutil 8 import shutil
9 import sys 9 import sys
10 import tempfile 10 import tempfile
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 'buildtype': ['dev'], 103 'buildtype': ['dev'],
104 'archive': 'renamed_direct_archive.txt', 104 'archive': 'renamed_direct_archive.txt',
105 'direct_archive': 1, 105 'direct_archive': 1,
106 }, 106 },
107 { 107 {
108 'filename': 'dev64_implied_direct_archive.txt', 108 'filename': 'dev64_implied_direct_archive.txt',
109 'arch': ['64bit'], 109 'arch': ['64bit'],
110 'buildtype': ['dev'], 110 'buildtype': ['dev'],
111 'archive': 'dev64_implied_direct_archive.txt', 111 'archive': 'dev64_implied_direct_archive.txt',
112 }, 112 },
113 {
114 'filename': 'archive_1.txt',
115 'buildtype': ['dev'],
116 'archive': 'archive_1.zip',
117 },
118 {
119 'filename': 'archive_2.txt',
120 'buildtype': ['dev'],
121 'archive': 'archive_2.zip',
122 },
123 {
124 'filename': 'multiple_archive.txt',
125 'buildtype': ['dev'],
126 'archive': 'archive_1.zip',
127 },
128 {
129 'filename': 'multiple_archive.txt',
130 'buildtype': ['dev'],
131 'archive': 'archive_2.zip',
132 },
133 ] 113 ]
134 114
135 115
136 def CreateTestFilesCfg(path): 116 def CreateTestFilesCfg(path):
137 files_cfg = os.path.join(path, archive_utils.FILES_FILENAME) 117 files_cfg = os.path.join(path, archive_utils.FILES_FILENAME)
138 f = open(files_cfg, 'w') 118 f = open(files_cfg, 'w')
139 f.write('FILES = %s' % str(TEST_FILES_CFG)) 119 f.write('FILES = %s' % str(TEST_FILES_CFG))
140 f.close() 120 f.close()
141 return files_cfg 121 return files_cfg
142 122
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 self.assertNotIn(i['filename'], files_list) 324 self.assertNotIn(i['filename'], files_list)
345 else: 325 else:
346 self.assertIn(i['filename'], files_list) 326 self.assertIn(i['filename'], files_list)
347 files_list.remove(i['filename']) 327 files_list.remove(i['filename'])
348 # No duplicate files. 328 # No duplicate files.
349 self.assertEqual(files_list.count(i['filename']), 0) 329 self.assertEqual(files_list.count(i['filename']), 0)
350 # No unexpected files. 330 # No unexpected files.
351 self.assertEqual(len(files_list), 0) 331 self.assertEqual(len(files_list), 0)
352 332
353 def testParseArchiveLists(self): 333 def testParseArchiveLists(self):
354 STATIC_ARCHIVE = 'static_archive.zip' 334 ARCHIVENAME = 'static_archive.zip'
355 ARCHIVE_1 = 'archive_1.zip'
356 ARCHIVE_2 = 'archive_2.zip'
357 ARCHIVENAMES = [STATIC_ARCHIVE, ARCHIVE_1, ARCHIVE_2]
358 files_cfg = CreateTestFilesCfg(self.temp_dir) 335 files_cfg = CreateTestFilesCfg(self.temp_dir)
359 arch = '64bit' 336 arch = '64bit'
360 buildtype = 'official' 337 buildtype = 'official'
361 fparser = archive_utils.FilesCfgParser(files_cfg, buildtype, arch) 338 fparser = archive_utils.FilesCfgParser(files_cfg, buildtype, arch)
362 archives = fparser.ParseArchiveLists() 339 archives = fparser.ParseArchiveLists()
363 self.assertEqual(archives.keys(), [STATIC_ARCHIVE]) 340 self.assertEqual(archives.keys(), [ARCHIVENAME])
364 self.assertItemsEqual([x['filename'] for x in archives[STATIC_ARCHIVE]], 341 self.assertEqual([x['filename'] for x in archives[ARCHIVENAME]],
365 ['archive_allany.txt', 'subdirectory/archive_allany.txt']) 342 ['archive_allany.txt', 'subdirectory/archive_allany.txt'])
366 343
367 # 32bit dev has additional files under the same archive name. 344 # 32bit dev has additional files under the same archive name.
368 arch = '32bit' 345 arch = '32bit'
369 buildtype = 'dev' 346 buildtype = 'dev'
370 fparser = archive_utils.FilesCfgParser(files_cfg, buildtype, arch) 347 fparser = archive_utils.FilesCfgParser(files_cfg, buildtype, arch)
371 archives = fparser.ParseArchiveLists() 348 archives = fparser.ParseArchiveLists()
372 self.assertEqual(archives.keys(), ARCHIVENAMES) 349 self.assertEqual(archives.keys(), [ARCHIVENAME])
373 self.assertItemsEqual([x['filename'] for x in archives[STATIC_ARCHIVE]], 350 self.assertEqual([x['filename'] for x in archives[ARCHIVENAME]],
374 ['archive_allany.txt', 'subdirectory/archive_allany.txt', 351 ['archive_allany.txt', 'subdirectory/archive_allany.txt',
375 'subdirectory/archive_dev32.txt']) 352 'subdirectory/archive_dev32.txt'])
376 self.assertItemsEqual([x['filename'] for x in archives[ARCHIVE_1]],
377 ['multiple_archive.txt', 'archive_1.txt'])
378 self.assertItemsEqual([x['filename'] for x in archives[ARCHIVE_2]],
379 ['multiple_archive.txt', 'archive_2.txt'])
380 353
381 def testOptionalFiles(self): 354 def testOptionalFiles(self):
382 files_cfg = CreateTestFilesCfg(self.temp_dir) 355 files_cfg = CreateTestFilesCfg(self.temp_dir)
383 optional_fn = 'allany_dev_optional.txt' 356 optional_fn = 'allany_dev_optional.txt'
384 arch = '64bit' 357 arch = '64bit'
385 buildtype = 'dev' 358 buildtype = 'dev'
386 fparser = archive_utils.FilesCfgParser(files_cfg, buildtype, arch) 359 fparser = archive_utils.FilesCfgParser(files_cfg, buildtype, arch)
387 self.assertTrue(fparser.IsOptional(optional_fn)) 360 self.assertTrue(fparser.IsOptional(optional_fn))
388 non_existent_fn = 'non_existent_fn.txt'
389 self.assertFalse(fparser.IsOptional(non_existent_fn))
390 361
391 # It's only optional for 'dev' builds. 362 # It's only optional for 'dev' builds.
392 buildtype = 'official' 363 buildtype = 'official'
393 fparser = archive_utils.FilesCfgParser(files_cfg, buildtype, arch) 364 fparser = archive_utils.FilesCfgParser(files_cfg, buildtype, arch)
394 self.assertFalse(fparser.IsOptional(optional_fn)) 365 self.assertFalse(fparser.IsOptional(optional_fn))
395 366
396 def testDirectArchive(self): 367 def testDirectArchive(self):
397 files_cfg = CreateTestFilesCfg(self.temp_dir) 368 files_cfg = CreateTestFilesCfg(self.temp_dir)
398 arch = '64bit' 369 arch = '64bit'
399 buildtype = 'dev' 370 buildtype = 'dev'
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) 604 sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
634 svn_client = pysvn.Client() 605 svn_client = pysvn.Client()
635 DiffFilesCfg(RealFilesCfgTest.WIN_PATH, svn_client) 606 DiffFilesCfg(RealFilesCfgTest.WIN_PATH, svn_client)
636 DiffFilesCfg(RealFilesCfgTest.LINUX_PATH, svn_client) 607 DiffFilesCfg(RealFilesCfgTest.LINUX_PATH, svn_client)
637 DiffFilesCfg(RealFilesCfgTest.MAC_PATH, svn_client) 608 DiffFilesCfg(RealFilesCfgTest.MAC_PATH, svn_client)
638 DiffFilesCfg(RealFilesCfgTest.CROS_PATH, svn_client) 609 DiffFilesCfg(RealFilesCfgTest.CROS_PATH, svn_client)
639 610
640 # Specify error return so caller (e.g. shell script) can easily detect 611 # Specify error return so caller (e.g. shell script) can easily detect
641 # failures. 612 # failures.
642 sys.exit(errors) 613 sys.exit(errors)
OLDNEW
« no previous file with comments | « scripts/common/archive_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698