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

Side by Side Diff: tools/perf/page_sets/page_set_unittest.py

Issue 274773002: [telemetry] Prototype for specifying page sets using Python imports and Telemetry discovery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import os 6 import os
7 import unittest 7 import unittest
8 8
9 from telemetry.core import discover 9 from telemetry.core import discover
10 from telemetry.page import page_set as page_set_module 10 from telemetry.page import page_set
11 from telemetry.page import page_set_archive_info 11 from telemetry.page import page_set_archive_info
12 12
13 13
14 class PageSetUnitTest(unittest.TestCase): 14 class PageSetUnitTest(unittest.TestCase):
15 15
16 def testSmoke(self): 16 def testSmoke(self):
17 # Instantiate all page sets and verify that all URLs have an associated 17 # Instantiate all page sets and verify that all URLs have an associated
18 # archive. 18 # archive.
19 page_sets_dir = os.path.dirname(__file__) 19 page_sets_dir = os.path.dirname(os.path.realpath(__file__))
20 page_sets = discover.GetAllPageSetFilenames(page_sets_dir) 20 top_level_dir = os.path.dirname(page_sets_dir)
21 for path in page_sets: 21 page_sets = discover.DiscoverClasses(
22 page_set = page_set_module.PageSet.FromFile(path) 22 page_sets_dir, top_level_dir, page_set.PageSet).values()
23 for page_set_class in page_sets:
24 page_set_file = page_set_class.__module__
25 ps = page_set_class()
23 26
24 # TODO: Eventually these should be fatal. 27 # TODO: Eventually these should be fatal.
25 if not page_set.archive_data_file: 28 if not ps.archive_data_file:
26 logging.warning('Skipping %s: missing archive data file', path) 29 logging.warning('Skipping %s: missing archive data file', page_set_file)
27 continue 30 continue
28 if not os.path.exists(os.path.join(page_sets_dir, 31 if not os.path.exists(os.path.join(page_sets_dir, ps.archive_data_file)):
29 page_set.archive_data_file)): 32 logging.warning('Skipping %s: archive data file not found',
30 logging.warning('Skipping %s: archive data file not found', path) 33 page_set_file)
31 continue 34 continue
32 35
33 wpr_archive_info = page_set_archive_info.PageSetArchiveInfo.FromFile( 36 wpr_archive_info = page_set_archive_info.PageSetArchiveInfo.FromFile(
34 os.path.join(page_sets_dir, page_set.archive_data_file), 37 os.path.join(page_sets_dir, ps.archive_data_file),
35 ignore_archive=True) 38 ignore_archive=True)
36 39
37 logging.info('Testing %s', path) 40 logging.info('Testing %s', page_set_file)
38 for page in page_set.pages: 41 for page in ps.pages:
39 if not page.url.startswith('http'): 42 if not page.url.startswith('http'):
40 continue 43 continue
41 self.assertTrue(wpr_archive_info.WprFilePathForPage(page), 44 self.assertTrue(wpr_archive_info.WprFilePathForPage(page),
42 msg='No archive found for %s in %s' % ( 45 msg='No archive found for %s in %s' % (
43 page.url, page_set.archive_data_file)) 46 page.url, ps.archive_data_file))
OLDNEW
« no previous file with comments | « tools/perf/page_sets/__init__.py ('k') | tools/perf/profile_creators/extensions_profile_creator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698