| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,69 @@ | |||
| 1 | + from __future__ import annotations | ||
| 2 | + | ||
| 3 | + from pre_commit.languages import perl | ||
| 4 | + from pre_commit.store import _make_local_repo | ||
| 5 | + from pre_commit.util import make_executable | ||
| 6 | + from testing.language_helpers import run_language | ||
| 7 | + | ||
| 8 | + | ||
| 9 | + def test_perl_install(tmp_path): | ||
| 10 | + makefile_pl = '''\ | ||
| 11 | + use strict; | ||
| 12 | + use warnings; | ||
| 13 | + | ||
| 14 | + use ExtUtils::MakeMaker; | ||
| 15 | + | ||
| 16 | + WriteMakefile( | ||
| 17 | + NAME => "PreCommitHello", | ||
| 18 | + VERSION_FROM => "lib/PreCommitHello.pm", | ||
| 19 | + EXE_FILES => [qw(bin/pre-commit-perl-hello)], | ||
| 20 | + ); | ||
| 21 | + ''' | ||
| 22 | + bin_perl_hello = '''\ | ||
| 23 | + #!/usr/bin/env perl | ||
| 24 | + | ||
| 25 | + use strict; | ||
| 26 | + use warnings; | ||
| 27 | + use PreCommitHello; | ||
| 28 | + | ||
| 29 | + PreCommitHello::hello(); | ||
| 30 | + ''' | ||
| 31 | + lib_hello_pm = '''\ | ||
| 32 | + package PreCommitHello; | ||
| 33 | + | ||
| 34 | + use strict; | ||
| 35 | + use warnings; | ||
| 36 | + | ||
| 37 | + our $VERSION = "0.1.0"; | ||
| 38 | + | ||
| 39 | + sub hello { | ||
| 40 | + print "Hello from perl-commit Perl!\n"; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + 1; | ||
| 44 | + ''' | ||
| 45 | + tmp_path.joinpath('Makefile.PL').write_text(makefile_pl) | ||
| 46 | + bin_dir = tmp_path.joinpath('bin') | ||
| 47 | + bin_dir.mkdir() | ||
| 48 | + exe = bin_dir.joinpath('pre-commit-perl-hello') | ||
| 49 | + exe.write_text(bin_perl_hello) | ||
| 50 | + make_executable(exe) | ||
| 51 | + lib_dir = tmp_path.joinpath('lib') | ||
| 52 | + lib_dir.mkdir() | ||
| 53 | + lib_dir.joinpath('PreCommitHello.pm').write_text(lib_hello_pm) | ||
| 54 | + | ||
| 55 | + ret = run_language(tmp_path, perl, 'pre-commit-perl-hello') | ||
| 56 | + assert ret == (0, b'Hello from perl-commit Perl!\n') | ||
| 57 | + | ||
| 58 | + | ||
| 59 | + def test_perl_additional_dependencies(tmp_path): | ||
| 60 | + _make_local_repo(str(tmp_path)) | ||
| 61 | + | ||
| 62 | + ret, out = run_language( | ||
| 63 | + tmp_path, | ||
| 64 | + perl, | ||
| 65 | + 'perltidy --version', | ||
| 66 | + deps=('SHANCOCK/Perl-Tidy-20211029.tar.gz',), | ||
| 67 | + ) | ||
| 68 | + assert ret == 0 | ||
| 69 | + assert out.startswith(b'This is perltidy, v20211029') | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -981,30 +981,6 @@ def test_manifest_hooks(tempdir_factory, store): | |||
| 981 | 981 | ) | |
| 982 | 982 | ||
| 983 | 983 | ||
| 984 | - def test_perl_hook(tempdir_factory, store): | ||
| 985 | - _test_hook_repo( | ||
| 986 | - tempdir_factory, store, 'perl_hooks_repo', | ||
| 987 | - 'perl-hook', [], b'Hello from perl-commit Perl!\n', | ||
| 988 | - ) | ||
| 989 | - | ||
| 990 | - | ||
| 991 | - def test_local_perl_additional_dependencies(store): | ||
| 992 | - config = { | ||
| 993 | - 'repo': 'local', | ||
| 994 | - 'hooks': [{ | ||
| 995 | - 'id': 'hello', | ||
| 996 | - 'name': 'hello', | ||
| 997 | - 'entry': 'perltidy --version', | ||
| 998 | - 'language': 'perl', | ||
| 999 | - 'additional_dependencies': ['SHANCOCK/Perl-Tidy-20211029.tar.gz'], | ||
| 1000 | - }], | ||
| 1001 | - } | ||
| 1002 | - hook = _get_hook(config, store, 'hello') | ||
| 1003 | - ret, out = _hook_run(hook, (), color=False) | ||
| 1004 | - assert ret == 0 | ||
| 1005 | - assert _norm_out(out).startswith(b'This is perltidy, v20211029') | ||
| 1006 | - | ||
| 1007 | - | ||
| 1008 | 984 | @pytest.mark.parametrize( | |
| 1009 | 985 | 'repo', | |
| 1010 | 986 | ( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments