summaryrefslogtreecommitdiff
path: root/t/dist/commands.t
blob: cbd29c37421ad72785d49dff6c01b9b5f652b9a2 (plain)
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/perl
#
# Tests for App::DocKnot::Dist command selection to generate a distribution.
#
# Copyright 2019-2021 Russ Allbery <rra@cpan.org>
#
# SPDX-License-Identifier: MIT

use 5.024;
use autodie;
use warnings;

use File::Spec;

use Test::More tests => 7;

# Isolate from the environment.
local $ENV{XDG_CONFIG_HOME} = '/nonexistent';
local $ENV{XDG_CONFIG_DIRS} = '/nonexistent';

# Load the module.
BEGIN { use_ok('App::DocKnot::Dist') }

# Use the same test cases that we use for generate, since they represent the
# same variety of build systems.
my $dataroot = File::Spec->catfile('t', 'data', 'generate');

# Module::Build distribution (use App::DocKnot itself and default paths).
my $docknot = App::DocKnot::Dist->new({ distdir => q{.} });
#<<<
my @expected = (
    ['perl', 'Build.PL'],
    ['./Build', 'disttest'],
    ['./Build', 'dist'],
);
#>>>
my @seen = $docknot->commands();
is_deeply(\@seen, \@expected, 'Module::Build');

# Test configuring an alternate path to Perl.
$docknot = App::DocKnot::Dist->new({ distdir => q{.}, perl => '/a/perl' });
#<<<
@expected = (
    ['/a/perl', 'Build.PL'],
    ['./Build', 'disttest'],
    ['./Build', 'dist'],
);
#>>>
@seen = $docknot->commands();
is_deeply(\@seen, \@expected, 'Module::Build');

# ExtUtils::MakeMaker distribution.
my $metadata_path
  = File::Spec->catfile($dataroot, 'ansicolor', 'docknot.yaml');
$docknot
  = App::DocKnot::Dist->new({ distdir => q{.}, metadata => $metadata_path });
#<<<
@expected = (
    ['perl', 'Makefile.PL'],
    ['make', 'disttest'],
    ['make', 'dist'],
);
#>>>
@seen = $docknot->commands();
is_deeply(\@seen, \@expected, 'ExtUtils::MakeMaker');

# Autoconf distribution.
$metadata_path = File::Spec->catfile($dataroot, 'lbcd', 'docknot.yaml');
$docknot
  = App::DocKnot::Dist->new({ distdir => q{.}, metadata => $metadata_path });
#<<<
@expected = (
    ['./bootstrap'],
    ['./configure', 'CC=clang'],
    ['make', 'warnings'],
    ['make', 'check'],
    ['make', 'clean'],
    ['./configure', 'CC=gcc'],
    ['make', 'warnings'],
    ['make', 'check'],
    ['make', 'clean'],
    ['make', 'check-cppcheck'],
    ['make', 'distcheck'],
);
#>>>
@seen = $docknot->commands();
is_deeply(\@seen, \@expected, 'Autoconf');

# Autoconf distribution with C++ and valgrind.
$metadata_path
  = File::Spec->catfile($dataroot, 'c-tap-harness', 'docknot.yaml');
$docknot
  = App::DocKnot::Dist->new({ distdir => q{.}, metadata => $metadata_path });
#<<<
@expected = (
    ['./bootstrap'],
    ['./configure', 'CC=g++'],
    ['make', 'check'],
    ['make', 'clean'],
    ['./configure', 'CC=clang'],
    ['make', 'warnings'],
    ['make', 'check'],
    ['make', 'clean'],
    ['./configure', 'CC=gcc'],
    ['make', 'warnings'],
    ['make', 'check'],
    ['make', 'check-valgrind'],
    ['make', 'clean'],
    ['make', 'check-cppcheck'],
    ['make', 'distcheck'],
);
#>>>
@seen = $docknot->commands();
is_deeply(\@seen, \@expected, 'Autoconf with C++');

# Makefile only distribution (make).
$metadata_path
  = File::Spec->catfile($dataroot, 'control-archive', 'docknot.yaml');
$docknot
  = App::DocKnot::Dist->new({ distdir => q{.}, metadata => $metadata_path });
@expected = (['make', 'dist']);
@seen     = $docknot->commands();
is_deeply(\@seen, \@expected, 'make');