예제 #1
0
파일: test_repo.py 프로젝트: yzzyx/testfest
    def test_repo_fetch(self):
        r = Repository("test/test_repo")
        r.set_clone_url(self.clone_dir)
        r.initialize()
        self.assertFalse(os.path.exists(os.path.join(r.repo_path, 'new_file.txt')))

        with open(os.path.join(self.clone_dir, "new_file.txt"), "w") as fd:
            fd.write("blah")

        orig_dir = os.getcwd()
        os.chdir(self.clone_dir)

        FNULL = open(os.devnull, 'w')
        subprocess.call(["git", "add", "new_file.txt"], stdout=FNULL, stderr=subprocess.STDOUT)
        subprocess.call(["git", "commit", "-m" "new file"], stdout=FNULL, stderr=subprocess.STDOUT)
        os.chdir(orig_dir)

        r.fetch()

        # We need to switch to the correct branch in order to see the file
        branches = r.get_branches()
        for b in branches:
            if b.name == "master":
                r.set_branch(b)
                break

        self.assertTrue(os.path.exists(os.path.join(r.repo_path, 'new_file.txt')))
예제 #2
0
파일: poll.py 프로젝트: yzzyx/testfest
                }

        repo = Repository(cfg_name)
        repo.set_clone_url(clone_url)
        repo.initialize()

        repo.fetch()
        branches = repo.get_branches()

        for b in branches:

            # Check if we already have this data
            if b.cached_data:
                continue

            repo.set_branch(b)

            # Load configuration file
            if not os.path.isfile(os.path.join(repo.repo_path, '.testfest.yml')):
                b.output_log = '<ERROR>The file .testfest.yml could not be found!</ERROR>'
                b.failed_tests = -1
                b.total_tests = -1
                continue

            repo_config = {}
            with open(os.path.join(repo.repo_path,'.testfest.yml'), 'r') as config_file:
                repo_config = yaml.load(config_file)

            if not 'language' in repo_config:
                b.output_log = '<ERROR>testfest configuration file does not contain a language attribute</ERROR>'
                b.failed_tests = -1