File: test_alien_cancompile.t

package info (click to toggle)
libalien-build-perl 2.84-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,116 kB
  • sloc: perl: 10,350; ansic: 134; sh: 66; makefile: 2
file content (67 lines) | stat: -rw-r--r-- 1,354 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use 5.008004;
use Test2::V0 -no_srand => 1;
use Test::Alien::CanCompile ();
use ExtUtils::CBuilder;
use Capture::Tiny qw( capture_merged );

subtest 'unmocked' => sub {

    my($diag, $ta_cc_skip, $eucb_have_compiler) = capture_merged {
      !!Test::Alien::CanCompile->skip,
      !!ExtUtils::CBuilder->new->have_compiler,
    };
    note $diag;

    is(
      $ta_cc_skip, !$eucb_have_compiler,
      'skip computed by Test::Alien::CanCompile should match ExtUtils::CBuilder#have_compiler'
    );
};

subtest 'skip/import' => sub {

  my $have_compiler;

  my $mock = mock 'ExtUtils::CBuilder' => (
    override => [
      have_compiler => sub { $have_compiler },
    ],
  );

  subtest 'have compiler' => sub {
    $have_compiler = 1;
    is
      [Test::Alien::CanCompile->skip],
      [F()],
      'skip'
    ;
    is
      intercept { Test::Alien::CanCompile->import },
      [],
      'import',
    ;
  };

  subtest 'no compiler' => sub {
    $have_compiler = 0;
    is
      [Test::Alien::CanCompile->skip],
      ['This test requires a compiler.'],
      'skip'
    ;
    is
      intercept { Test::Alien::CanCompile->import },
      array {
        event Plan => sub {
          call directive => 'SKIP';
          call reason => 'This test requires a compiler.';
        };
        end;
      },
      'import',
    ;
  };

};

done_testing;