def tag_component(comp, tag, sb): aspects = get_vcs_component_aspects(comp, sb) for a in aspects: path = sb.get_component_path(comp, a) vcs.tag(tag, path)
def test_dependencies(self): tmpdir = tempfile.mkdtemp() #print('running test in temporary repo %s' % tmpdir) cwd = os.getcwd() try: template1 = '[%s]' % metadata.DEPENDENCIES_SECTION template2 = template1 + ''' %s: code,%s.trunk.1.1 use: reusable %s: code,%s.trunk.1.1 use: reusable ''' template3 = template1 + ''' %s: code,%s.trunk.2.1 use: reusable %s: code,%s.trunk.1.1 use: reusable ''' files = { 'a': template2 % ('b', 'b', 'c', 'c'), 'b': template1, 'c': template3 % ('b', 'b', 'd', 'd'), 'd': template1 } testRepos = ['a', 'b', 'c', 'd'] for t in testRepos: repoPath = os.path.join(tmpdir, 'trunk', t) os.makedirs(os.path.join(tmpdir, 'trunk', t)) branchPath = repoPath + '/code' #print('init %s' % branchPath) vcs.init(branchPath, False) filePath = branchPath + '/' + metadata.METADATA_FILE save(filePath, files[t]) os.chdir(branchPath) #print('adding %s' % filePath) vcs.add(filePath) #print('checking in %s' % filePath) vcs.checkin(filePath, 'Test', True) vcs.tag('%s.trunk.1.1 use: reusable' % t) if t == 'b': #subprocess.Popen(['bzr', 'tag', 'first'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) filePath = branchPath + '/dependencies2.txt' save(filePath, files[t]) vcs.add(filePath) vcs.checkin(filePath, 'Test', True) vcs.tag('%s.trunk.2.1 use: reusable' % t) #subprocess.Popen(['bzr', 'tags']) working_repo = vcs.WorkingRepository() working_repo._init(tmpdir, tmpdir, tmpdir) prob = metadata.get_components_inv_dep_order( working_repo, 'win_x64', 'a', tmpdir, 'trunk', '') comp = [ component.Component('b', 'trunk', 'b.trunk.1.1 use: reusable', 'code'), component.Component('d', 'trunk', 'd.trunk.1.1 use: reusable', 'code'), component.Component('c', 'trunk', 'c.trunk.1.1 use: reusable', 'code'), component.Component('a', 'trunk', 'a.trunk.1.1 use: reusable', 'code') ] if False: for c in comp: print("comp = " + str(c)) for c in prob: print("prob = " + str(c)) # prob will have buildscripts; comp doesn't prob = [p for p in prob if p.name != 'buildscripts'] self.assertEquals(len(comp), len(prob)) for i in range(len(comp)): self.assertEquals(comp[i].name, prob[i].name) finally: os.chdir(cwd) shutil.rmtree(tmpdir)
def test_dependencies(self): tmpdir = tempfile.mkdtemp() #print('running test in temporary repo %s' % tmpdir) cwd = os.getcwd() try: template1 = '[%s]' % metadata.DEPENDENCIES_SECTION template2 = template1 + ''' %s: code,%s.trunk.1.1 use: reusable %s: code,%s.trunk.1.1 use: reusable ''' template3 = template1 + ''' %s: code,%s.trunk.2.1 use: reusable %s: code,%s.trunk.1.1 use: reusable ''' files = { 'a': template2 % ('b', 'b', 'c', 'c'), 'b': template1, 'c': template3 % ('b', 'b', 'd', 'd'), 'd': template1 } testRepos = ['a', 'b', 'c', 'd'] for t in testRepos: repoPath = os.path.join(tmpdir, 'trunk', t) os.makedirs(os.path.join(tmpdir, 'trunk', t)) branchPath = repoPath + '/code' #print('init %s' % branchPath) vcs.init(branchPath, False) filePath = branchPath + '/' + metadata.METADATA_FILE save(filePath, files[t]) os.chdir(branchPath) #print('adding %s' % filePath) vcs.add(filePath) #print('checking in %s' % filePath) vcs.checkin(filePath, 'Test', True) vcs.tag('%s.trunk.1.1 use: reusable' % t) if t == 'b': #subprocess.Popen(['bzr', 'tag', 'first'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) filePath = branchPath + '/dependencies2.txt' save(filePath, files[t]) vcs.add(filePath) vcs.checkin(filePath, 'Test', True) vcs.tag('%s.trunk.2.1 use: reusable' % t) #subprocess.Popen(['bzr', 'tags']) working_repo = vcs.WorkingRepository() working_repo._init(tmpdir, tmpdir, tmpdir) prob = metadata.get_components_inv_dep_order(working_repo, 'win_x64', 'a', tmpdir, 'trunk', '') comp = [ component.Component('b', 'trunk', 'b.trunk.1.1 use: reusable', 'code'), component.Component('d', 'trunk', 'd.trunk.1.1 use: reusable', 'code'), component.Component('c', 'trunk', 'c.trunk.1.1 use: reusable', 'code'), component.Component('a', 'trunk', 'a.trunk.1.1 use: reusable', 'code') ] if False: for c in comp: print("comp = " + str(c)) for c in prob: print("prob = " + str(c)) # prob will have buildscripts; comp doesn't prob = [p for p in prob if p.name != 'buildscripts'] self.assertEquals(len(comp), len(prob)) for i in range(len(comp)): self.assertEquals(comp[i].name, prob[i].name) finally: os.chdir(cwd) shutil.rmtree(tmpdir)