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
|
#!/usr/bin/perl
# $Id: gprintify 257533 2009-05-23 12:45:15Z guillomovitch $
use strict;
use warnings;
use Utils qw/run get_md5/;
use Test::More;
use File::Temp qw/tempdir/;
use File::Path qw/make_path/;
plan tests => 2;
# test the script itself
my ($buildroot, $test, $before, $after);
($buildroot, $test) = setup(<<EOF);
foo\r
EOF
$before = get_md5($test);
run($buildroot, 'fix_eol');
$after = get_md5($test);
isnt(
$before,
$after,
'script should be modified'
);
($buildroot, $test) = setup(<<EOF);
foo\r
EOF
$before = get_md5($test);
$ENV{EXCLUDE_FROM_EOL_CONVERSION} = 'test';
run($buildroot, 'fix_eol');
$after = get_md5($test);
is(
$before,
$after,
'EXCLUDE_FROM_EOL_CONVERSION should prevent end-of-line conversion'
);
sub setup {
my ($content) = @_;
my $buildroot = tempdir(CLEANUP => ($ENV{TEST_DEBUG} ? 0 : 1));
my $initrddir = $buildroot . '/etc/rc.d/init.d';
my $datadir = $buildroot . '/usr/share';
my $test = $datadir . '/test';
make_path($datadir);
open(my $out, '>', $test) or die "can't write to $test: $!";
print $out $content;
close($out);
return ($buildroot, $test);
}
|