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

Side by Side Diff: scripts/slave/slave_utils_unittest.py

Issue 10035003: Split up Each Swarm Test into Two Steps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Adding tests to presubmit Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6
7 import os
8 import sys
9 import unittest
10
11 here = os.path.dirname(sys.argv[0])
12 sys.path.insert(0, os.path.join(here, '..', '..', 'site_config'))
13 sys.path.insert(0, os.path.join(here, '..'))
14 sys.path.insert(0, here)
15
16 import slave.slave_utils as slave_utils
17
18
19 class TestGypFlags(unittest.TestCase):
20
21 # So that python 2.6 can test this.
22 def AssertIsNone(self, x, msg=None):
23 self.assertTrue(x is None, msg=msg)
24
25 def test_single_gyp_flag_one(self):
26 self.assertEqual(
27 slave_utils.GetGypFlag({'factory_properties': {
28 'gclient_env': { 'GYP_DEFINES' : 'chromeos=1' },
29 'trigger': 'chromiumos_dbg_trigger',
30 'window_manager': False,
31 }}, 'chromeos'), '1')
32
33 def test_single_gyp_flag_zero(self):
34 self.assertEqual(
35 slave_utils.GetGypFlag({'factory_properties': {
36 'gclient_env': { 'GYP_DEFINES' : 'chromeos=0' },
37 'trigger': 'chromiumos_dbg_trigger',
38 'window_manager': False,
39 }}, 'chromeos'), '0')
40
41 def test_triple_gyp_flag_center(self):
42 self.assertEqual(
43 slave_utils.GetGypFlag({'factory_properties': {
44 'gclient_env': { 'GYP_DEFINES' : 'bull tiger=x03 frog' },
45 }}, 'tiger'), 'x03')
46
47 def test_gyp_flag_not_present(self):
48 self.AssertIsNone(
49 slave_utils.GetGypFlag({'factory_properties': {
50 'gclient_env': { 'GYP_DEFINES' : 'tiger=1' },
51 }}, 'chromeos'))
52
53 def test_triple_gyp_flag_last(self):
54 self.assertTrue(
55 slave_utils.GetGypFlag({'factory_properties': {
56 'gclient_env': { 'GYP_DEFINES' : 'tiger=1 buffalo giraffe' }}},
57 'giraffe'))
58
59 def test_no_gyp_flags_with_other(self):
60 self.AssertIsNone(
61 slave_utils.GetGypFlag({'factory_properties': {
62 'gclient_env': { 'OTHER_DEFINES' : 'tiger=1' }}},
63 'tiger'))
64
65 def test_no_gyp_flags(self):
66 self.AssertIsNone(
67 slave_utils.GetGypFlag({'factory_properties': {}}, 'chromeos'))
68
69 def test_no_properties_flags(self):
70 self.AssertIsNone(slave_utils.GetGypFlag({}, 'chromeos'))
71
72
73
74 class TestGypFlagIsOn(unittest.TestCase):
75
76 def testSample(self):
77 sample = {'factory_properties': {'gclient_env': { 'GYP_DEFINES' :
78 'tiger=1 buffalo=0 giraffe' }}}
79 self.assertTrue(slave_utils.GypFlagIsOn(sample, 'tiger'))
80 self.assertFalse(slave_utils.GypFlagIsOn(sample, 'buffalo'))
81 self.assertTrue(slave_utils.GypFlagIsOn(sample, 'giraffe'))
82 self.assertFalse(slave_utils.GypFlagIsOn(sample, 'monkey'))
83
84
85 if __name__ == '__main__':
86 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698