Begin conversion to testscenarios

Use testscenarios where possible due to the way parameters within each
scenario can be accessed directly on the object for providing additional
feedback in the case of failed tests.

Moves each searcher test into a separate yaml file to be loaded as a
scenario which helps separate test info and actual code performing the
test.

Change-Id: Ie86561a8a1b80dc66bfc4bd43bda3ba46b0a5a4a
This commit is contained in:
Darragh Bailey
2015-12-16 17:29:39 +00:00
committed by Darragh Bailey
parent dcffac3a9c
commit 5c523d6655
14 changed files with 574 additions and 413 deletions

View File

@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import io
import logging import logging
import os import os
from pprint import pformat from pprint import pformat
@@ -24,6 +25,7 @@ import git
import loremipsum import loremipsum
import testtools import testtools
from testtools.content import text_content from testtools.content import text_content
import yaml
def _get_node_to_pick(node): def _get_node_to_pick(node):
@@ -89,6 +91,22 @@ def reverse_toposort(data):
raise RuntimeError(message) raise RuntimeError(message)
def get_scenarios(scenarios_path):
"""Returns a list of scenarios, each scenario being describe
by it's name, and a dict containing the parameters
"""
scenarios = []
for root, dirs, files in os.walk(scenarios_path):
for f in files:
if f.endswith('.yaml'):
filename = os.path.join(root, f)
with io.open(filename, 'r', encoding='utf-8') as yaml_file:
data = yaml.load(yaml_file)
scenarios.append((filename, data[0]))
return scenarios
class DiveDir(fixtures.Fixture): class DiveDir(fixtures.Fixture):
"""Dive into given directory and return back on cleanup. """Dive into given directory and return back on cleanup.
@@ -296,9 +314,18 @@ class BaseTestCase(testtools.TestCase):
return [self._graph[n] for n in nodes] return [self._graph[n] for n in nodes]
def attach_graph_info(self, exc_info): def attach_graph_info(self, exc_info):
# appears to be an odd bug where this method is called twice
# if registered with addOnException so make sure to guard
# that the path actually exists before running
if not (hasattr(self.testrepo, 'path') and
os.path.exists(self.testrepo.path)):
return
if not self._graph: if not self._graph:
return return
self.addDetail('graph-dict', text_content(pformat(self._graph))) self.addDetail('graph-dict', text_content(pformat(self._graph)))
self.addDetail('git-log-with-graph',
text_content(self.git.log(graph=True, oneline=True, self.addDetail(
decorate=True, all=True))) 'git-log-with-graph',
text_content(self.repo.git.log(graph=True, oneline=True,
decorate=True, all=True)))

View File

View File

@@ -0,0 +1,44 @@
#
# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
- desc: |
Construct a repo layout where previously an additional branch has been
included and validate that locate changes walker can find the expected
changes.
Repository layout being tested
B example/packaging
\
C---D---E master
/
A---F---G upstream/master
tree:
- [A, []]
- [B, []]
- [C, [A, B]]
- [D, [C]]
- [E, [D]]
- [F, [A]]
- [G, [F]]
branches:
head: [master, E]
upstream: [upstream/master, G]
expected_changes: [C, D, E]

View File

@@ -0,0 +1,55 @@
#
# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
- desc: |
Construct a repo layout where previously an additional branch has been
included and validate that locate changes walker can find the right
changes after an additional import.
Repository layout being tested
B-- example/packaging
\ \
C---D---E-------I---J---K master
/ \ /
/ --H---D1--E1 import/next
/ /
A---F---G---L---M upstream/master
tree:
- [A, []]
- [B, []]
- [C, [A, B]]
- [D, [C]]
- [E, [D]]
- [F, [A]]
- [G, [F]]
- [H, [G, B]]
- [D1, [H]]
- [E1, [D1]]
- [I, [E, =E1]]
- [J, [I]]
- [J, [I]]
- [K, [J]]
- [L, [G]]
- [M, [L]]
branches:
head: [master, K]
upstream: [upstream/master, M]
expected_changes: [H, D1, E1, I, J, K]

View File

@@ -0,0 +1,38 @@
#
# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
- desc: |
Construct a basic repo layout and validate that locate changes walker
can find the expected changes.
Repository layout being tested
B master
/
A---C---D upstream/master
tree:
- [A, []]
- [B, [A]]
- [C, [A]]
- [D, [C]]
branches:
head: [master, B]
upstream: [upstream/master, D]
expected_changes: [B]

View File

@@ -0,0 +1,63 @@
#
# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
- desc: |
Construct a repo layout where using a complex layout where a previous
import from upstream having been completed, test that if a change was
created on before the previous import was created, and merged to the
target branch and then the previous import merge commit was merged
with it, can we find the change correctly.
i.e. will the searcher also include commit 'O' in the diagram below.
Repository layout being tested
O----
/ \
B---C---D---H---I---J---K master
/ \ /
/ ----G
/ /
/ B1--C1--D1 import/next
/ /
A---E---F---L---M upstream/master
tree:
- [A, []]
- [B, [A]]
- [C, [B]]
- [D, [C]]
- [E, [A]]
- [F, [E]]
- [B1, [F]]
- [C1, [B1]]
- [D1, [C1]]
- [G, [D, =D1]]
- [O, [C]]
- [H, [D, O]]
- [I, [H, G]]
- [J, [I]]
- [K, [J]]
- [L, [F]]
- [M, [L]]
branches:
head: [master, K]
upstream: [upstream/master, M]
expected_changes: [O, H, B1, C1, D1, G, I, J, K]

View File

@@ -0,0 +1,63 @@
#
# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
- desc: |
Construct a repo layout where using a complex layout involving additional
branches having been included, and a previous import from upstream having
been completed, test that if a change was created on before the previous
import, and this change was merged to the target branch after the previous
import was merged, can we find it correctly.
i.e. will the strategy also include commit 'O' in the diagram below.
Repository layout being tested
B--
\ \
\ \ O----------------
\ \ / \
C---D---E-------I---J---K---P---Q master
/ \ /
/ --H---D1--E1
/ /
A---F---G---L---M upstream/master
tree:
- [A, []]
- [B, []]
- [C, [A, B]]
- [D, [C]]
- [E, [D]]
- [F, [A]]
- [G, [F]]
- [H, [G, B]]
- [D1, [H]]
- [E1, [D1]]
- [I, [E, =E1]]
- [J, [I]]
- [K, [J]]
- [L, [G]]
- [M, [L]]
- [O, [E]]
- [P, [K, O]]
- [Q, [P]]
branches:
head: [master, Q]
upstream: [upstream/master, M]
expected_changes: [H, D1, E1, I, J, K, O, P, Q]

View File

@@ -0,0 +1,62 @@
#
# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
- desc: |
Construct a repo layout where using a complex layout involving an additional
branch having been included, and a previous import from upstream completed
completed, test that if multiple changes were created on the mainline branch
before the previous import was created, and merged to the target branch
after the previous import, that we can find them correctly.
i.e. will the strategy also include commits 'L' and 'J' from the diagram.
Repository layout being tested
B-- L-------------
\ \ / \
\ \ / J--------- \
\ \ / / \ \
C---D---E-------I---K---M---O---P master
/ \ /
/ --H---D1--E1
/ /
A---F---G---Q---R upstream/master
tree:
- [A, []]
- [B, []]
- [C, [A, B]]
- [D, [C]]
- [E, [D]]
- [F, [A]]
- [G, [F]]
- [H, [G, B]]
- [D1, [H]]
- [E1, [D1]]
- [I, [E, =E1]]
- [J, [E]]
- [K, [I, J]]
- [L, [D]]
- [M, [K, L]]
- [O, [M]]
- [P, [O]]
- [Q, [G]]
- [R, [Q]]
branches:
head: [master, P]
upstream: [upstream/master, R]
expected_changes: [H, D1, E1, I, J, K, L, M, O, P]

View File

@@ -0,0 +1,52 @@
#
# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
- desc: |
Construct a repo layout using an old approach where the mainline would
be replaced with the upstream and then local changes replayed on top.
Check to see if we can correctly convert from this approach.
Repository layout being tested
B-----------G packaging
\ \
C---D---E---H--D1--E1 master
/ /
/ /
/ /
A---F-----------I---J upstream/master
tree:
- [A, []]
- [B, []]
- [C, [A, B]]
- [D, [C]]
- [E, [D]]
- [F, [A]]
- [G, [B]]
- [H, [E, =F, =G]]
- [D1, [H]]
- [E1, [D1]]
- [I, [F]]
- [J, [I]]
branches:
head: [master, E1]
upstream: [upstream/master, I]
packaging: [packaging, B]
expected_changes: [H, D1, E1]

View File

@@ -0,0 +1,54 @@
#
# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
- desc: |
Construct a repository layout where the upstream branch is switched,
after one import, and test that changes from the previous branch used,
'upstream/stable', are not listed. This tests usage of the pattern
attribute.
Repository layout being tested
B-----------J master
/ /
/ B1
/ /
/ E---I upstream/stable
/ /
A---C---D---F---G---H upstream/master
tree:
- [A, []]
- [B, [A]]
- [C, [A]]
- [D, [C]]
- [E, [D]]
- [F, [D]]
- [G, [F]]
- [H, [G]]
- [I, [E]]
- [B1, [I]]
- [J, [B, =B1]]
branches:
head: [master, J]
stable: [upstream/stable, I]
upstream: [upstream/master, H]
expected_changes: [B1, J]
pattern: upstream/*

View File

@@ -0,0 +1,57 @@
#
# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
- desc: |
Construct a repository layout where the upstream branch is switched
after an initial import, from 'upstream/stable' to 'upstream/master'.
Test that using the new branch as the search pattern forces changes
from 'upstream/stable' to be included. This is in contrast to the
test in `switch_tracked_branches`.
This shows the additional changes that are picked up.
Repository layout being tested
B-----------J master
/ /
/ B1
/ /
/ E---I upstream/stable
/ /
A---C---D---F---G---H upstream/master
tree:
- [A, []]
- [B, [A]]
- [C, [A]]
- [D, [C]]
- [E, [D]]
- [F, [D]]
- [G, [F]]
- [H, [G]]
- [I, [E]]
- [B1, [I]]
- [J, [B, =B1]]
branches:
head: [master, J]
stable: [upstream/stable, I]
upstream: [upstream/master, H]
expected_changes: [E, I, B1, J]
pattern: upstream/master

View File

@@ -0,0 +1,54 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import os
from pprint import pformat
from testscenarios import TestWithScenarios
from testtools.content import text_content
from git_upstream.lib.searchers import UpstreamMergeBaseSearcher
from git_upstream.tests.base import BaseTestCase
from git_upstream.tests.base import get_scenarios
class TestUpstreamMergeBaseSearcher(TestWithScenarios, BaseTestCase):
scenarios = get_scenarios(os.path.join(os.path.dirname(__file__),
"scenarios"))
def setUp(self):
super(TestUpstreamMergeBaseSearcher, self).setUp()
self.addDetail('description', text_content(self.desc))
self._build_git_tree(self.tree, self.branches.values())
# need the tree built at this point
self.addDetail('expected-changes',
text_content(pformat(
list((c, self._graph[c].hexsha)
for c in self.expected_changes))))
def test_search_changes(self):
if getattr(self, 'pattern', None):
pattern = [self.pattern]
else:
pattern = None
searcher = UpstreamMergeBaseSearcher(branch=self.branches['head'][0],
patterns=pattern, repo=self.repo)
self.assertEqual(
self._commits_from_nodes(reversed(self.expected_changes)),
searcher.list())

View File

@@ -1,410 +0,0 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from git_upstream.lib.searchers import UpstreamMergeBaseSearcher
from base import BaseTestCase
class TestUpstreamMergeBaseSearcher(BaseTestCase):
def _verify_expected(self, tree, branches, expected_nodes, pattern=None):
self._build_git_tree(tree, branches.values())
if pattern:
pattern = [pattern]
searcher = UpstreamMergeBaseSearcher(branch=branches['head'][0],
patterns=pattern, repo=self.repo)
self.assertEqual(self._commits_from_nodes(reversed(expected_nodes)),
searcher.list())
def test_search_basic(self):
"""Construct a basic repo layout and validate that locate changes
walker can find the expected changes.
Repository layout being tested
B master
/
A---C---D upstream/master
"""
tree = [
('A', []),
('B', ['A']),
('C', ['A']),
('D', ['C'])
]
branches = {
'head': ('master', 'B'),
'upstream': ('upstream/master', 'D'),
}
expected_changes = ["B"]
self._verify_expected(tree, branches, expected_changes)
def test_search_additional_branch(self):
"""Construct a repo layout where previously an additional branch has
been included and validate that locate changes walker can find the
expected changes
Repository layout being tested
B example/packaging
\
C---D---E master
/
A---F---G upstream/master
"""
tree = [
('A', []),
('B', []),
('C', ['A', 'B']),
('D', ['C']),
('E', ['D']),
('F', ['A']),
('G', ['F'])
]
branches = {
'head': ('master', 'E'),
'upstream': ('upstream/master', 'G'),
}
expected_changes = ["C", "D", "E"]
self._verify_expected(tree, branches, expected_changes)
def test_search_old_style_merge_replace_first(self):
"""Construct a repo layout using an old approach where the mainline
would be replaced with the upstream and then local changes replayed
on top. Check to see if we can correctly convert from this approach.
Repository layout being tested
B-----------G packaging
\ \
C---D---E---H--D1--E1 master
/ /
/ /
/ /
A---F-----------I---J upstream/master
"""
tree = [
('A', []),
('B', []),
('C', ['A', 'B']),
('D', ['C']),
('E', ['D']),
('F', ['A']),
('G', ['B']),
('H', ['E', '=F', '=G']),
('D1', ['H']),
('E1', ['D1']),
('I', ['F']),
('J', ['I']),
]
branches = {
'head': ('master', 'E1'),
'upstream': ('upstream/master', 'I'),
'packaging': ('packaging', 'B')
}
expected_changes = ["H", "D1", "E1"]
self._verify_expected(tree, branches, expected_changes)
def test_search_additional_branch_multiple_imports(self):
"""Construct a repo layout where previously an additional branch has
been included and validate that locate changes walker can find the
right changes after an additional import
Repository layout being tested
B-- example/packaging
\ \
C---D---E-------I---J---K master
/ \ /
/ --H---D1--E1 import/next
/ /
A---F---G---L---M upstream/master
"""
tree = [
('A', []),
('B', []),
('C', ['A', 'B']),
('D', ['C']),
('E', ['D']),
('F', ['A']),
('G', ['F']),
('H', ['G', 'B']),
('D1', ['H']),
('E1', ['D1']),
('I', ['E', '=E1']),
('J', ['I']),
('K', ['J']),
('L', ['G']),
('M', ['L'])
]
branches = {
'head': ('master', 'K'),
'upstream': ('upstream/master', 'M'),
}
expected_changes = ["H", "D1", "E1", "I", "J", "K"]
self._verify_expected(tree, branches, expected_changes)
def test_search_changes_upload_prior_to_import(self):
"""Construct a repo layout where using a complex layout involving
additional branches having been included, and a previous import from
upstream having been completed, test that if a change was created on
another branch before the previous import was created, and merged to
the target branch after the previous import, can we find it correctly.
i.e. will the strategy also include commit 'O' in the diagram below.
Repository layout being tested
B--
\ \
\ \ O----------------
\ \ / \
C---D---E-------I---J---K---P---Q master
/ \ /
/ --H---D1--E1
/ /
A---F---G---L---M upstream/master
"""
tree = [
('A', []),
('B', []),
('C', ['A', 'B']),
('D', ['C']),
('E', ['D']),
('F', ['A']),
('G', ['F']),
('H', ['G', 'B']),
('D1', ['H']),
('E1', ['D1']),
('I', ['E', '=E1']),
('J', ['I']),
('K', ['J']),
('L', ['G']),
('M', ['L']),
('O', ['E']),
('P', ['K', 'O']),
('Q', ['P'])
]
branches = {
'head': ('master', 'Q'),
'upstream': ('upstream/master', 'M'),
}
expected_changes = ["H", "D1", "E1", "I", "J", "K", "O", "P", "Q"]
self._verify_expected(tree, branches, expected_changes)
def test_search_multi_changes_upload_prior_to_import(self):
"""Construct a repo layout where using a complex layout involving
additional branches having been included, and a previous import from
upstream having been completed, test that if a change was created on
another branch before the previous import was created, and merged to
the target branch after the previous import, can we find it correctly.
i.e. will the strategy also include commit 'O' in the diagram below.
Repository layout being tested
B-- L-------------
\ \ / \
\ \ / J--------- \
\ \ / / \ \
C---D---E-------I---K---M---O---P master
/ \ /
/ --H---D1--E1
/ /
A---F---G---Q---R upstream/master
"""
tree = [
('A', []),
('B', []),
('C', ['A', 'B']),
('D', ['C']),
('E', ['D']),
('F', ['A']),
('G', ['F']),
('H', ['G', 'B']),
('D1', ['H']),
('E1', ['D1']),
('I', ['E', '=E1']),
('J', ['E']),
('K', ['I', 'J']),
('L', ['D']),
('M', ['K', 'L']),
('O', ['M']),
('P', ['O']),
('Q', ['G']),
('R', ['Q'])
]
branches = {
'head': ('master', 'P'),
'upstream': ('upstream/master', 'R'),
}
expected_changes = ["H", "D1", "E1", "I", "J", "K", "L", "M", "O", "P"]
self._verify_expected(tree, branches, expected_changes)
def test_search_switch_tracked_branches(self):
"""Search a repository layout where previously was tracking a
difference branch to the one that the user now wishes to import
Repository layout being tested
B-----------J master
/ /
/ B1
/ /
/ E---I upstream/stable
/ /
A---C---D---F---G---H upstream/master
"""
tree = [
('A', []),
('B', ['A']),
('C', ['A']),
('D', ['C']),
('E', ['D']),
('F', ['D']),
('G', ['F']),
('H', ['G']),
('I', ['E']),
('B1', ['I']),
('J', ['B', '=B1'])
]
branches = {
'head': ('master', 'J'),
'stable': ('upstream/stable', 'I'),
'upstream': ('upstream/master', 'H')
}
expected_changes = ['B1', 'J']
self._verify_expected(tree, branches, expected_changes,
pattern="upstream/*")
def test_search_switch_tracked_branches_incorrect(self):
"""Search a repository layout where previously was tracking a
difference branch to the one that the user now wishes to import based
on using the new branch as the basis to search on.
This shows the additional changes that are picked up by mistake
Repository layout being tested
B-----------J master
/ /
/ B1
/ /
/ E---I upstream/stable
/ /
A---C---D---F---G---H upstream/master
"""
tree = [
('A', []),
('B', ['A']),
('C', ['A']),
('D', ['C']),
('E', ['D']),
('F', ['D']),
('G', ['F']),
('H', ['G']),
('I', ['E']),
('B1', ['I']),
('J', ['B', '=B1'])
]
branches = {
'head': ('master', 'J'),
'stable': ('upstream/stable', 'I'),
'upstream': ('upstream/master', 'H')
}
expected_changes = ['E', 'I', 'B1', 'J']
self._verify_expected(tree, branches, expected_changes,
pattern='upstream/master')
def test_search_changes_approved_after_import_merge(self):
"""Construct a repo layout where using a complex layout involving
additional branches having been included, and a previous import from
upstream having been completed, test that if a change was created on
another branch before the previous import was created, and merged to
the target branch before the previous import was merged, can we find
it correctly.
i.e. will the searcher also include commit 'O' in the diagram below.
Repository layout being tested
O----
/ \
B---C---D---H---I---J---K master
/ \ /
/ ----G
/ /
/ B1--C1--D1 import/next
/ /
A---E---F---L---M upstream/master
"""
tree = [
('A', []),
('B', ['A']),
('C', ['B']),
('D', ['C']),
('E', ['A']),
('F', ['E']),
('B1', ['F']),
('C1', ['B1']),
('D1', ['C1']),
('G', ['D', '=D1']),
('O', ['C']),
('H', ['D', 'O']),
('I', ['H', 'G']),
('J', ['I']),
('K', ['J']),
('L', ['F']),
('M', ['L'])
]
branches = {
'head': ('master', 'K'),
'upstream': ('upstream/master', 'M'),
}
expected_changes = ["O", "H", "B1", "C1", "D1", "G", "I", "J", "K"]
self._verify_expected(tree, branches, expected_changes)

View File

@@ -6,5 +6,7 @@ discover
fixtures>=0.3.14 fixtures>=0.3.14
python-subunit python-subunit
testrepository>=0.0.17 testrepository>=0.0.17
testscenarios>=0.4
testtools>=0.9.32 testtools>=0.9.32
sphinxcontrib-programoutput sphinxcontrib-programoutput
PyYAML>=3.1.0