Commit 6a737f27 authored by Boxiang Sun's avatar Boxiang Sun

testnode: Add submodule check when checking revision

parent 77a84720
......@@ -186,6 +186,11 @@ class ERP5TestNode(TestCase):
# ['4f1d14de1b04b4f878a442ee859791fa337bcf85', 'first_commit']]}
return commit_dict
def setUpSubmodule(self):
repository_path = self.remote_repository1
call = self.getCaller(cwd=repository_path)
call(['git', 'submodule', 'add', self.remote_repository2 + '/.git', 'repo2'])
def test_01_getDelNodeTestSuite(self):
"""
We should be able to get/delete NodeTestSuite objects inside test_node
......@@ -293,22 +298,37 @@ shared = true
"""
Check if we clone correctly repositories and get right revisions
"""
commit_dict = self.generateTestRepositoryList()
commit_dict = self.generateTestRepositoryList(add_third_repository=True)
self.setUpSubmodule()
test_node = self.getTestNode()
node_test_suite = test_node.getNodeTestSuite('foo')
# just add the third repository, but not set the vcs_repository_list
# because it is invisible to the buildout
# the submodule was set up in setUpSubmodule function
self.updateNodeTestSuiteData(node_test_suite)
rev_list = self.getAndUpdateFullRevisionList(test_node, node_test_suite)
self.assertEquals(2, len(rev_list))
self.assertEquals(rev_list[0], 'rep0=2-%s' % commit_dict['rep0'][0][0])
self.assertEquals(rev_list[1], 'rep1=2-%s' % commit_dict['rep1'][0][0])
call = self.getCaller(cwd=self.remote_repository0)
submodule_revision0 = call("git rev-parse HEAD".split())
submodule_file = open(os.path.join(self.remote_repository1, '.gitmodules'), 'r')
submodule_line = submodule_file.readline()
submodule_file.close()
self.assertEquals('[submodule "repo2"]\n', submodule_line)
submodule_commit_file = open(os.path.join(self.remote_repository2, 'first_file'), 'w')
submodule_commit_file.write("next_content")
submodule_commit_file.close()
my_file = open(os.path.join(self.remote_repository1, 'first_file'), 'w')
my_file.write("next_content")
my_file.close()
call = self.getCaller(cwd=self.remote_repository1)
call("git commit -av -m new_commit".split())
rev_list = self.getAndUpdateFullRevisionList(test_node, node_test_suite)
submodule_revision1 = call("git rev-parse HEAD".split())
self.assertTrue(rev_list[0].startswith('rep0=2-'))
self.assertTrue(rev_list[1].startswith('rep1=3-'))
self.assertNotEquals(submodule_revision0, submodule_revision1)
self.assertEquals(2, len(node_test_suite.vcs_repository_list))
for vcs_repository in node_test_suite.vcs_repository_list:
self.assertTrue(os.path.exists(vcs_repository['repository_path']))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment