diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2018-07-18 17:11:57 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-08-27 23:35:29 +0300 |
commit | fb770e1e3d17d548c34817001733f2a13f24ce9f (patch) | |
tree | 7e9bf40d6ff7cc23256ec913fb831b35be126906 /run_unittests.py | |
parent | 1ffc8de5e8cc79dbaa54fd1ac02b6b4c5edac7a1 (diff) | |
download | meson-fb770e1e3d17d548c34817001733f2a13f24ce9f.zip meson-fb770e1e3d17d548c34817001733f2a13f24ce9f.tar.gz meson-fb770e1e3d17d548c34817001733f2a13f24ce9f.tar.bz2 |
Add support for custom dist scripts.
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-x | run_unittests.py | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/run_unittests.py b/run_unittests.py index ebead66..c1aa8de 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -85,6 +85,17 @@ def is_ci(): return True return False +def _git_init(project_dir): + subprocess.check_call(['git', 'init'], cwd=project_dir, stdout=subprocess.DEVNULL) + subprocess.check_call(['git', 'config', + 'user.name', 'Author Person'], cwd=project_dir) + subprocess.check_call(['git', 'config', + 'user.email', 'teh_coderz@example.com'], cwd=project_dir) + subprocess.check_call('git add *', cwd=project_dir, shell=True, + stdout=subprocess.DEVNULL) + subprocess.check_call(['git', 'commit', '-a', '-m', 'I am a project'], cwd=project_dir, + stdout=subprocess.DEVNULL) + def skipIfNoPkgconfig(f): ''' Skip this test if no pkg-config is found, unless we're on Travis or @@ -690,11 +701,19 @@ class DataTests(unittest.TestCase): if f.parts[-1].endswith('~'): continue if f.suffix == '.md': + in_code_block = False with f.open() as snippet: for line in snippet: + if line.startswith(' '): + continue + if line.startswith('```'): + in_code_block = not in_code_block + if in_code_block: + continue m = re.match(hashcounter, line) if m: self.assertEqual(len(m.group(0)), 2, 'All headings in snippets must have two hash symbols: ' + f.name) + self.assertFalse(in_code_block, 'Unclosed code block.') else: if f.name != 'add_release_note_snippets_here': self.assertTrue(False, 'A file without .md suffix in snippets dir: ' + f.name) @@ -1712,19 +1731,8 @@ class AllPlatformTests(BasePlatformTests): if not shutil.which('git'): raise unittest.SkipTest('Git not found') - def git_init(project_dir): - subprocess.check_call(['git', 'init'], cwd=project_dir, stdout=subprocess.DEVNULL) - subprocess.check_call(['git', 'config', - 'user.name', 'Author Person'], cwd=project_dir) - subprocess.check_call(['git', 'config', - 'user.email', 'teh_coderz@example.com'], cwd=project_dir) - subprocess.check_call(['git', 'add', 'meson.build', 'distexe.c'], cwd=project_dir, - stdout=subprocess.DEVNULL) - subprocess.check_call(['git', 'commit', '-a', '-m', 'I am a project'], cwd=project_dir, - stdout=subprocess.DEVNULL) - try: - self.dist_impl(git_init) + self.dist_impl(_git_init) except PermissionError: # When run under Windows CI, something (virus scanner?) # holds on to the git files so cleaning up the dir @@ -1753,6 +1761,24 @@ class AllPlatformTests(BasePlatformTests): # fails sometimes. pass + def test_dist_git_script(self): + if not shutil.which('git'): + raise unittest.SkipTest('Git not found') + + try: + with tempfile.TemporaryDirectory() as tmpdir: + project_dir = os.path.join(tmpdir, 'a') + shutil.copytree(os.path.join(self.unit_test_dir, '35 dist script'), + project_dir) + _git_init(project_dir) + self.init(project_dir) + self.build('dist') + except PermissionError: + # When run under Windows CI, something (virus scanner?) + # holds on to the git files so cleaning up the dir + # fails sometimes. + pass + def dist_impl(self, vcs_init): # Create this on the fly because having rogue .git directories inside # the source tree leads to all kinds of trouble. |