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: unittests/override_test.py

Issue 2664223002: Add unit tests for overrides in multi-repo workflow (Closed)
Patch Set: reverts Created 3 years, 10 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 | « recipes.py ('k') | unittests/repo_test_util.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2017 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file.
5
6 import subprocess
7 import sys
8 import unittest
9
10 import repo_test_util
11
12
13 class TestOverride(repo_test_util.RepoTest):
14 def test_simple(self):
15 repos = self.repo_setup({
16 'a': [],
17 'a1': [],
18 'b': ['a'],
19 })
20
21 a_c1 = self.update_recipe_module(repos['a'], 'a_module', {'foo': ['bar']})
22 b_c1_rev = self.update_recipes_cfg(
23 'b', self.updated_package_spec_pb(repos['b'], 'a', a_c1['revision']))
24 b_c2 = self.update_recipe(
25 repos['b'], 'b_recipe', ['a/a_module'], [('a_module', 'foo')])
26
27 # Training the recipes should work.
28 self.train_recipes(repos['b'])
29
30 # Using a no-op override should also work.
31 self.train_recipes(repos['b'], overrides=[('a', repos['a']['root'])])
32
33 # Using an override pointing to empty repo should fail.
34 with self.assertRaises(subprocess.CalledProcessError) as cm:
35 self.train_recipes(repos['b'], overrides=[('a', repos['a1']['root'])])
36 self.assertIn(
37 'Exception: While generating results for \'b_recipe\': ImportError: '
38 'No module named a_module',
39 cm.exception.output)
40
41 def test_dependency_conflict(self):
42 repos = self.repo_setup({
43 'a': [],
44 'b': ['a'],
45 'b1': ['a'],
46 'c': ['a', 'b'],
47 })
48
49 a_c1 = self.update_recipe_module(repos['a'], 'a_module', {'foo': ['bar']})
50 b_c1_rev = self.update_recipes_cfg(
51 'b', self.updated_package_spec_pb(repos['b'], 'a', a_c1['revision']))
52 b1_c1_rev = self.update_recipes_cfg(
53 'b1', self.updated_package_spec_pb(repos['b1'], 'a', a_c1['revision']))
54
55 a_c2 = self.update_recipe_module(repos['a'], 'a_module', {'foo': ['baz']})
56 b_c2_rev = self.update_recipes_cfg(
57 'b', self.updated_package_spec_pb(repos['b'], 'a', a_c2['revision']))
58
59 c_spec = self.get_package_spec(repos['c'])
60 c_spec.deps['a'].revision = a_c2['revision']
61 c_spec.deps['b'].revision = b_c2_rev
62 c_c1 = self.update_recipes_cfg('c', c_spec.dump())
63
64 c_c2 = self.update_recipe(
65 repos['c'], 'c_recipe', ['a/a_module'], [('a_module', 'foo')])
66
67 # Training the recipes should work.
68 self.train_recipes(repos['c'])
69
70 # Trying to override just the b repo should fail (conflicting revisions
71 # of the a repo).
72 with self.assertRaises(subprocess.CalledProcessError) as cm:
73 self.train_recipes(repos['c'], overrides=[('b', repos['b1']['root'])])
74 # TODO(phajdan.jr): assert on full message after making exception printable.
75 self.assertIn('InconsistentDependencyGraphError', cm.exception.output)
76
77 # The solution is to also override the a repo to make it clear what revision
78 # should be used.
79 self.train_recipes(
80 repos['c'],
81 overrides=[('b', repos['b1']['root']), ('a', repos['a']['root'])])
82
83
84 if __name__ == '__main__':
85 sys.exit(unittest.main())
OLDNEW
« no previous file with comments | « recipes.py ('k') | unittests/repo_test_util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698