def testAddNewProject(self):
        """Add new project to the repo.

    Check local_manifest.xml is created and valid.
    """
        new_project = 'project'
        self.git_mock.AddCmdResult([
            'config', '-f',
            os.path.join(self.tempdir, '.repo', 'manifests.git', 'config'),
            'manifest.groups',
            'minilayout,platform-linux,group1,group2,name:%s' % (new_project, )
        ], )
        cmd = ['add', new_project, 'path', '-r', 'remote']
        with self.OutputCapturer():
            self.assertEqual(loman.main(cmd), 0)
        expected_local_manifest_nodes = ElementTree.fromstring("""
<manifest>
  <project name="project" path="path" remote="remote" workon="False" />
</manifest>""")
        with open(os.path.join('.repo', 'local_manifest.xml')) as f:
            local_manifest_nodes = ElementTree.fromstring(f.read())

        # Read project, check for failure.
        self.assertEqual(ElementTree.tostring(expected_local_manifest_nodes),
                         ElementTree.tostring(local_manifest_nodes))

        # Check that re-adding triggers error.
        cmd = ['add', new_project, 'path', '-r', 'remote']
        with self.OutputCapturer() as output:
            self.assertRaises(SystemExit, loman.main, cmd)
            self.assertIn('conflicts with', '\n'.join(output.GetStderrLines()))
 def testAddExistingProject(self):
     """Add an existing project, check no local_manifest.xml are created."""
     self.git_mock.AddCmdResult([
         'config', '-f',
         os.path.join(self.tempdir, '.repo', 'manifests.git',
                      'config'), 'manifest.groups',
         'minilayout,platform-linux,group1,group2,name:%s' %
         (self.PROJECT, )
     ])
     cmd = ['add', '-w', self.PROJECT]
     with self.OutputCapturer():
         self.assertEqual(loman.main(cmd), 0)
     self.assertNotExists(os.path.join('.repo', 'local_manifest.xml'))
示例#3
0
 def testNoUpgradeNeeded(self):
   """Don't run update when it isn't needed."""
   with self.OutputCapturer():
     self.PatchObject(loman, '_UpgradeMinilayout', side_effect=Exception)
     loman.main(['upgrade-minilayout'])