MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / test_perl_install

Function test_perl_install

tests/languages/perl_test.py:9–56  ·  view source on GitHub ↗
(tmp_path)

Source from the content-addressed store, hash-verified

7
8
9def test_perl_install(tmp_path):
10 makefile_pl = '''\
11use strict;
12use warnings;
13
14use ExtUtils::MakeMaker;
15
16WriteMakefile(
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
25use strict;
26use warnings;
27use PreCommitHello;
28
29PreCommitHello::hello();
30'''
31 lib_hello_pm = '''\
32package PreCommitHello;
33
34use strict;
35use warnings;
36
37our $VERSION = "0.1.0";
38
39sub hello {
40 print "Hello from perl-commit Perl!\n";
41}
42
431;
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
59def test_perl_additional_dependencies(tmp_path):

Callers

nothing calls this directly

Calls 2

make_executableFunction · 0.90
run_languageFunction · 0.90

Tested by

no test coverage detected