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

Side by Side Diff: infra/services/gsubtreed/test/gsubtreed_test_definitions.py

Issue 477623003: Add git subtree daemon service. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@add_dtree_support
Patch Set: test multiple runs, fix some logging silliness Created 6 years, 4 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
(Empty)
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
3 # found in the LICENSE file.
4
5 from infra.libs.git2.testing_support import GitEntry
6
7 GSUBTREED_TESTS = {}
8 def test(f):
9 GSUBTREED_TESTS[f.__name__] = f
10 return f
11
12
13 @test
14 def master_mirrored_path(origin, run, checkpoint):
15 master = origin['refs/heads/master']
16 mc = master.make_commit
17 mc('first commit', {'unrelated': 'cowabunga'})
18 mc('next commit', {
19 'mirrored_path': {
20 'mirror_file': 'awesome sauce',
21 'some_other_file': 'neat',
22 },
23 'unrelated': 'other',
24 'unrelated_path': 'not helpful',
25 })
26 master.make_commit('unrelated commit', {
27 'unrelated_path': 'helpful?',
28 })
29
30 checkpoint('repo is set up')
31 run()
32 checkpoint('should see stuff')
33
34 synthed = 'refs/subtree-synthesized/mirrored_path/-/heads/master'
35 assert GitEntry.spec_for(origin, synthed) == {
36 'mirror_file': ('awesome sauce', 0644),
37 'some_other_file': ('neat', 0644),
38 }
39
40
41 @test
42 def multiple_refs(origin, run, checkpoint):
43 master = origin['refs/heads/master']
44 other = origin['refs/heads/other']
45 mc = master.make_commit
46 oc = other.make_commit
47
48 mc('nerd_commit', {'mirrored_path': {'sweet subfile': 'nerds'}})
49 oc('what_commit', {
50 'mirrored_path': {
51 'sweet subfile': 'what',
52 'subpath': {
53 'nested': 'data in a subdir!?'}}})
54
55 checkpoint('all set up')
56 run()
57 checkpoint('lots refs')
58
59 synthed = 'refs/subtree-synthesized/mirrored_path/subpath/-/heads/other'
60 assert GitEntry.spec_for(origin, synthed) == {
61 'nested': ('data in a subdir!?', 0644)
62 }
63
64
65 @test
66 def mirrored_path_is_a_file(origin, run, checkpoint):
67 master = origin['refs/heads/master']
68 mc = master.make_commit
69 mc('first commit', {'unrelated': 'cowabunga'})
70 mc('bad subtree', {'mirrored_path': 'it\'s a file!!'})
71 mc('but now it\'s OK', {'mirrored_path': {'silly': 'data'}})
72 mc('now it\'s a file again', {'mirrored_path': 'fail!'})
73 mc('back to a dir', {'mirrored_path': {'what what': 'datars!'}})
74
75 checkpoint('repo is set up')
76 run()
77 checkpoint('should see 2 commits in synthesized')
78
79 synthed = 'refs/subtree-synthesized/mirrored_path/-/heads/master'
80 assert GitEntry.spec_for(origin, synthed) == {
81 'what what': ('datars!', 0644)
82 }
83
84
85 @test
86 def multiple_runs(origin, run, checkpoint):
87 master = origin['refs/heads/master']
88 other = origin['refs/heads/other']
89 mc = master.make_commit
90 oc = other.make_commit
91
92 mc('nerd_commit', {'mirrored_path': {'sweet subfile': 'nerds'}})
93 oc('what_commit', {
94 'mirrored_path': {
95 'sweet subfile': 'what',
96 'subpath': {
97 'nested': 'data in a subdir!?'}}})
98
99 checkpoint('all set up')
100 run()
101 checkpoint('lots refs')
102
103 synthed = 'refs/subtree-synthesized/mirrored_path/subpath/-/heads/other'
104 assert GitEntry.spec_for(origin, synthed) == {
105 'nested': ('data in a subdir!?', 0644)
106 }
107
108 mc('new_commit', {'mirrored_path': {'whatpath': {'nested': 'datas'}}})
109 checkpoint('added new_commit')
110 run()
111 checkpoint('should gain new synthed commit')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698