• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

gugod / App-perlbrew / 5162889645

pending completion
5162889645

Pull #776

github

Pull Request #776: New command: make shim

69 of 69 new or added lines in 3 files covered. (100.0%)

3117 of 3939 relevant lines covered (79.13%)

79.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.89
/t/command-make-shim.t
1
#!/usr/bin/env perl
2
use Test2::V0;
1✔
3
use Test2::Tools::Spec;
1✔
4
use File::Temp qw( tempdir );
1✔
5

1✔
6
use FindBin;
1✔
7
use lib $FindBin::Bin;
8

9
use App::perlbrew;
1✔
10
require "test2_helpers.pl";
1✔
11
use PerlbrewTestHelpers qw(read_file write_file);
12

1✔
13
mock_perlbrew_install("perl-5.36.1");
×
14

15
describe "App::perlbrew->make_shim()" => sub {
×
16
    it "should show usage", sub {
17
        mock_perlbrew_use("perl-5.36.1");
18

19
        my $called = 0;
20
        my $mock = mock 'App::perlbrew',
1✔
21
            override => [
22
                run_command_help => sub { $called++; "" }
1✔
23
            ];
1✔
24

25
        ok(
26
            lives {
1✔
27
                my $app = $mock->class->new("make-shim");
1✔
28
                $app->run;
1✔
29
            },
30
            "`make-shim` should not trigger any exceptions"
1✔
31
        ) or note($@);
1✔
32
        is $called, 1, "`help` command should be running.";
33
    };
34
};
1✔
35

1✔
36
describe "App::perlbrew->make_shim('foo')" => sub {
1✔
37
    it "should err when perlbrew is off" => sub {
1✔
38
        mock_perlbrew_off();
39

40
        my $dir = tempdir();
1✔
41
        chdir($dir);
1✔
42

1✔
43
        ok dies {
1✔
44
            my $app = App::perlbrew->new("make-shim", "foo");
45
            $app->run();
46
        }, qr(^ERROR:);
1✔
47

1✔
48
        ok ! -f "foo", "foo is not produced";
1✔
49
    };
50

1✔
51
    it "should err when 'foo' already exists" => sub {
1✔
52
        mock_perlbrew_use("perl-5.36.1");
53
        my $dir = tempdir();
1✔
54
        chdir($dir);
1✔
55
        write_file ("foo", "hello");
1✔
56

1✔
57
        ok dies {
×
58
            my $app = App::perlbrew->new("make-shim", "foo");
59
            $app->run();
1✔
60
        }, qr(^ERROR:);
61

62
        ok dies {
63
            my $app = App::perlbrew->new("make-shim", "-o", "foo", "bar");
64
           $app->run();
65
        }, qr(^ERROR:);
66
    };
67

68
    it "should produce 'foo' in the current dir" => sub {
69
        mock_perlbrew_use("perl-5.36.1");
70
        my $dir = tempdir();
71
        chdir($dir);
72

73
        my $app = App::perlbrew->new("make-shim", "foo");
74
        $app->run();
75

76
        ok -f "foo", "foo is produced under current directory.";
77
        my $shim_content = read_file("foo");
78
        diag "\nThe content of shim:\n----\n$shim_content\n----\n";
79
    };
80

81
    it "should produce 'foo' in the current dir" => sub {
82
        mock_perlbrew_use("perl-5.36.1");
83
        my $dir = tempdir();
84
        chdir($dir);
85

86
        my $app = App::perlbrew->new("make-shim", "-o", "foo", "bar");
87
        $app->run();
88

89
        ok -f "foo", "foo is produced under current directory.";
90
        my $shim_content = read_file("foo");
91
        diag "\nThe content of shim:\n----\n$shim_content\n----\n";
92
    };
93
};
94

95
done_testing;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc