• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import os
6import unittest
7
8from catapult_build import build_steps
9
10
11class BuildStepsTest(unittest.TestCase):
12
13  def testCatapultTestList(self):
14    catapult_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
15    for test in build_steps._CATAPULT_TESTS:
16      self.assertIn('name', test, msg=(
17          'All tests in build_steps._CATAPULT_TESTS must have a name;'
18          ' error in:\n %s' % test))
19      self.assertIsInstance(test['name'], str, msg=(
20          'Test name %s in build_steps._CATAPULT_TESTS must be a string.'
21          % test['name']))
22      self.assertIn('path', test, msg=(
23          'All tests in build_steps._CATAPULT_TESTS must have a path '
24          'relative to catapult/; error in:\n %s' % test))
25      abs_path = os.path.join(catapult_dir, test['path'])
26      self.assertTrue(os.path.exists(abs_path), msg=(
27          'Bad path %s in build_steps._CATAPULT_TESTS; '
28          ' should be relative to catapult/' % test['path']))
29      if test.get('additional_args'):
30        self.assertIsInstance(test['additional_args'], list, msg=(
31            'additional_args %s in build_steps._CATAPULT_TESTS %s not a list'
32            % (test['additional_args'], test['name'])
33        ))
34      if test.get('disabled'):
35        self.assertIsInstance(test['disabled'], list, msg=(
36            'disabled %s in build_steps._CATAPULT_TESTS for %s not a list'
37            % (test['disabled'], test['name'])
38        ))
39        for platform in test['disabled']:
40          self.assertIn(platform, ['win', 'mac', 'linux'], msg=(
41              'Bad platform %s in build_steps._CATAPULT_TESTS for %s;'
42              'should be one of "linux", "win", "mac"' % (
43                  platform, test['name'])
44          ))
45