File: 02_test_binaries.t

package info (click to toggle)
mysql-sandbox 3.2.05-1.1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 916 kB
  • sloc: perl: 9,878; sh: 191; makefile: 8
file content (109 lines) | stat: -rw-r--r-- 2,683 bytes parent folder | download | duplicates (2)
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
BEGIN {
    $ENV{PERL5LIB}="$ENV{PWD}/lib";
    $ENV{PATH}="$ENV{PWD}/bin:$ENV{PATH}";
};

use strict;
use warnings;
use lib './t';
use Test_Helper;
use Test::More;

BEGIN {
    if ($^O =~ /^(?:mswin|win)/i) {
            plan skip_all => 'This module is not for Windows'
        }
        else {
            plan tests => 36;
        }
}
# 7 tests
ok_shell_result( "msandbox",
            ['available',
            'low_level_make_sandbox', 
            'make_sandbox',
            'make_replication_sandbox',
            'make_multiple_sandbox',
            'make_multiple_custom_sandbox'],
            "msandbox");

# 5 tests
ok_shell_result( "msb",
        ['shortcut',
        'single',
        'replication',
        'multiple'
        ],
        "msb"
);

# 3 tests
ok_shell_result( "low_level_make_sandbox --help", 
            ['low_level_make_sandbox',
            '-d --sandbox_directory = name'], 
            "low_level_make_sandbox");

# 3 tests
# my @time_items = localtime(time);
# my $year = $time_items[5] + 1900;
ok_shell_result( "make_sandbox --help", 
            ['make_sandbox', 
            'version',
            # "2006-$year"
            ], 
            "make_sandbox");

# 3 tests
ok_shell_result( "make_replication_sandbox --help", 
            ['make_replication_sandbox', 
            '--sandbox_base_port = number'],
            "make_replication_sandbox");

# 3 tests
ok_shell_result( "make_multiple_sandbox --help", 
            ['make_multiple_sandbox',
            '--sandbox_base_port = number'], 
            "make_multiple_sandbox");

# 3 tests
ok_shell_result( "make_multiple_custom_sandbox --help", 
            ['make_multiple_custom_sandbox',
            '--sandbox_base_port = number'],
            "make_multiple_custom_sandbox");

# 3 tests
ok_shell_result( "sbtool --help", 
            ['sbtool',
            '--operation'],
            "sbtool");

# 3 tests
ok_shell_result( "test_sandbox  --help",
            ['test_sandbox',
            '--tarball=/path/to/tarball'],
            "test_sandbox");

# 3 tests
ok_shell_result( "make_sandbox_from_source",
            ['make_sandbox_from_source',
            'configure && make'],
            "make_sandbox_from_source");

sub ok_shell {
    my ($command , $description) = @_;
    my $result = system($command);
    # warn "\n<$?><$result>\n";
    return ok($? >=0 , $description);
}

sub ok_shell_result {
    my ($command, $search_items, $description) = @_;
    $? = 0;
    $! = undef;
    my $result = qx($command); 
    # diag ">>$result\n";
    ok($? >= 0 , $description);
    for my $item (@{ $search_items}) {
        ok( $result =~ /$item/ , "$description - $item" );
    }
}