File: alien_build_plugin_build_make.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 (100 lines) | stat: -rw-r--r-- 2,300 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
use 5.008004;
use Test2::V0 -no_srand => 1;
use Test::Alien::Build;
use Alien::Build::Plugin::Build::Make;
use Path::Tiny qw( path );

subtest 'compile' => sub {
  foreach my $type (qw( nmake dmake gmake umake ))
  {
    subtest $type => sub {
      my $build = alienfile_ok qq{
        use alienfile;
        plugin 'Build::Make' => '$type';
      };

      if($type =~ /nmake|dmake/)
      {

        is(
          $build->meta->interpolator->interpolate('%{make}'),
          $type,
        );
      }

    };
  }
};

subtest 'gmake' => sub {

  my $build = alienfile q{
    use alienfile;
    use Path::Tiny qw( path );
    plugin 'Build::Make' => 'gmake';

    probe sub { 'share' };

    share {
      download sub { path('file1')->touch };
      extract sub {

        # simple portable makefile that uses gmake specific
        # automatic variables
        path('Makefile')->spew(
          "%.exe:%.c\n",
          "\t$^X build.pl \$< \$@\n",
          "\n",
          "install:foo.exe\n",
          "\t$^X install.pl foo.exe \$(PREFIX)/bin/foo.exe\n",
        );

        path('build.pl')->spew("#!$^X\n", q{
          use strict;
          use warnings;
          use Path::Tiny qw( path );
          my($from, $to) = map { path($_) } @ARGV;
          $to->spew('[' . $from->slurp . ']');
        });

        path('install.pl')->spew("#!$^X\n", q{
          use strict;
          use warnings;
          use Path::Tiny qw( path );
          my($from, $to) = map { path($_) } @ARGV;
          $to->parent->mkpath;
          $from->copy($to);
          print "copy $from $to\n";
        });

        path('foo.c')->spew(
          "something",
        );

      };
      build [
        '%{make} foo.exe',
        '%{make} install PREFIX=%{.install.prefix}',
      ];
    };
  };

  eval {
    $Alien::Build::Plugin::Build::Make::VERSION = '0.01';
    $build->load_requires('configure');
    $build->load_requires($build->install_type);
  };
  skip_all 'test requires GNU Make or Alien::gmake' if $@;

  note "make = @{[ $build->meta->interpolator->interpolate('%{make}') ]}";

  my $alien = alien_build_ok;

  my $foo_exe = path($alien->bin_dir)->child('foo.exe');
  note "foo_exe = $foo_exe";
  note "content = ", $foo_exe->slurp;
  is($foo_exe->slurp, '[something]');

};

done_testing