예제 #1
0
    def setUp(self):
        """Create an svn repository with two revisions."""
        super(SvnFetchTest, self).setUp()

        self.repo = MockSvnRepo()

        spec = Spec('svn-test')
        spec.concretize()
        self.pkg = spack.repo.get(spec, new=True)
예제 #2
0
파일: svn_fetch.py 프로젝트: Exteris/spack
    def setUp(self):
        """Create an svn repository with two revisions."""
        super(SvnFetchTest, self).setUp()

        self.repo = MockSvnRepo()

        spec = Spec('svn-test')
        spec.concretize()
        self.pkg = spack.repo.get(spec, new=True)
예제 #3
0
파일: svn_fetch.py 프로젝트: Exteris/spack
class SvnFetchTest(MockPackagesTest):
    """Tests fetching from a dummy git repository."""

    def setUp(self):
        """Create an svn repository with two revisions."""
        super(SvnFetchTest, self).setUp()

        self.repo = MockSvnRepo()

        spec = Spec('svn-test')
        spec.concretize()
        self.pkg = spack.repo.get(spec, new=True)

    def tearDown(self):
        """Destroy the stage space used by this test."""
        super(SvnFetchTest, self).tearDown()
        self.repo.destroy()

    def assert_rev(self, rev):
        """Check that the current revision is equal to the supplied rev."""
        def get_rev():
            output = svn('info', output=str)
            self.assertTrue("Revision" in output)
            for line in output.split('\n'):
                match = re.match(r'Revision: (\d+)', line)
                if match:
                    return match.group(1)
        self.assertEqual(get_rev(), rev)

    def try_fetch(self, rev, test_file, args):
        """Tries to:
           1. Fetch the repo using a fetch strategy constructed with
              supplied args.
           2. Check if the test_file is in the checked out repository.
           3. Assert that the repository is at the revision supplied.
           4. Add and remove some files, then reset the repo, and
              ensure it's all there again.
        """
        self.pkg.versions[ver('svn')] = args

        with self.pkg.stage:
            self.pkg.do_stage()
            self.assert_rev(rev)

            file_path = join_path(self.pkg.stage.source_path, test_file)
            self.assertTrue(os.path.isdir(self.pkg.stage.source_path))
            self.assertTrue(os.path.isfile(file_path))

            os.unlink(file_path)
            self.assertFalse(os.path.isfile(file_path))

            untracked = 'foobarbaz'
            touch(untracked)
            self.assertTrue(os.path.isfile(untracked))
            self.pkg.do_restage()
            self.assertFalse(os.path.isfile(untracked))

            self.assertTrue(os.path.isdir(self.pkg.stage.source_path))
            self.assertTrue(os.path.isfile(file_path))

            self.assert_rev(rev)


    def test_fetch_default(self):
        """Test a default checkout and make sure it's on rev 1"""
        self.try_fetch(self.repo.r1, self.repo.r1_file, {
            'svn' : self.repo.url
        })


    def test_fetch_r1(self):
        """Test fetching an older revision (0)."""
        self.try_fetch(self.repo.r0, self.repo.r0_file, {
            'svn'      : self.repo.url,
            'revision' : self.repo.r0
        })
예제 #4
0
class SvnFetchTest(MockPackagesTest):
    """Tests fetching from a dummy git repository."""
    def setUp(self):
        """Create an svn repository with two revisions."""
        super(SvnFetchTest, self).setUp()

        self.repo = MockSvnRepo()

        spec = Spec('svn-test')
        spec.concretize()
        self.pkg = spack.repo.get(spec, new=True)

    def tearDown(self):
        """Destroy the stage space used by this test."""
        super(SvnFetchTest, self).tearDown()
        self.repo.destroy()

    def assert_rev(self, rev):
        """Check that the current revision is equal to the supplied rev."""
        def get_rev():
            output = svn('info', output=str)
            self.assertTrue("Revision" in output)
            for line in output.split('\n'):
                match = re.match(r'Revision: (\d+)', line)
                if match:
                    return match.group(1)

        self.assertEqual(get_rev(), rev)

    def try_fetch(self, rev, test_file, args):
        """Tries to:

        1. Fetch the repo using a fetch strategy constructed with
           supplied args.
        2. Check if the test_file is in the checked out repository.
        3. Assert that the repository is at the revision supplied.
        4. Add and remove some files, then reset the repo, and
           ensure it's all there again.
        """
        self.pkg.versions[ver('svn')] = args

        with self.pkg.stage:
            self.pkg.do_stage()
            self.assert_rev(rev)

            file_path = join_path(self.pkg.stage.source_path, test_file)
            self.assertTrue(os.path.isdir(self.pkg.stage.source_path))
            self.assertTrue(os.path.isfile(file_path))

            os.unlink(file_path)
            self.assertFalse(os.path.isfile(file_path))

            untracked = 'foobarbaz'
            touch(untracked)
            self.assertTrue(os.path.isfile(untracked))
            self.pkg.do_restage()
            self.assertFalse(os.path.isfile(untracked))

            self.assertTrue(os.path.isdir(self.pkg.stage.source_path))
            self.assertTrue(os.path.isfile(file_path))

            self.assert_rev(rev)

    def test_fetch_default(self):
        """Test a default checkout and make sure it's on rev 1"""
        self.try_fetch(self.repo.r1, self.repo.r1_file, {'svn': self.repo.url})

    def test_fetch_r1(self):
        """Test fetching an older revision (0)."""
        self.try_fetch(self.repo.r0, self.repo.r0_file, {
            'svn': self.repo.url,
            'revision': self.repo.r0
        })