diff options
author | Guillaume Rousse <guillomovitch@mandriva.org> | 2010-01-01 22:39:14 +0000 |
---|---|---|
committer | Guillaume Rousse <guillomovitch@mandriva.org> | 2010-01-01 22:39:14 +0000 |
commit | a79ebc0315296dfe78e87230d17b6ecd6574e1c3 (patch) | |
tree | 358419fd72050993791f3128d058bd51f7f20a71 /t/gprintify | |
parent | 6a8041abb31a149c32af13b576a1ebf1ec543cb6 (diff) | |
download | spec-helper-a79ebc0315296dfe78e87230d17b6ecd6574e1c3.tar spec-helper-a79ebc0315296dfe78e87230d17b6ecd6574e1c3.tar.gz spec-helper-a79ebc0315296dfe78e87230d17b6ecd6574e1c3.tar.bz2 spec-helper-a79ebc0315296dfe78e87230d17b6ecd6574e1c3.tar.xz spec-helper-a79ebc0315296dfe78e87230d17b6ecd6574e1c3.zip |
rename test scripts with .t suffix
Diffstat (limited to 't/gprintify')
-rwxr-xr-x | t/gprintify | 151 |
1 files changed, 0 insertions, 151 deletions
diff --git a/t/gprintify b/t/gprintify deleted file mode 100755 index 9069d1d..0000000 --- a/t/gprintify +++ /dev/null @@ -1,151 +0,0 @@ -#!/usr/bin/perl -# $Id: gprintify 257533 2009-05-23 12:45:15Z guillomovitch $ - -use strict; -use warnings; -use Test::More; -use File::Temp qw/tempdir/; -use File::Path qw/make_path/; -use FindBin qw/$Bin/; -use lib "$Bin/../lib"; -use Digest::MD5; - -my @string_results = ( - [ 'result: $foo', 'result: %s', ' "$foo"' ], - [ 'result: $foo,$bar', 'result: %s,%s', ' "$foo" "$bar"' ], - [ 'result: \$foo', 'result: \$foo', '' ], - [ 'result: \$foo,$bar', 'result: \$foo,%s', ' "$bar"' ], - [ 'result: ${foo}', 'result: %s', ' "${foo}"', '' ], - [ 'result: ${foo##*/}', 'result: %s', ' "${foo##*/}"' ], - [ 'result: ${foo%%*/}', 'result: %s', ' "${foo%%*/}"' ], - [ 'result: ${foo#*/}', 'result: %s', ' "${foo#*/}"' ], - [ 'result: ${foo%*/}', 'result: %s', ' "${foo%*/}"' ] -); -my @start_results = ( - [ 'echo "result: $foo"', 'gprintf "', '\n"' ], - [ '# echo "result: $foo"', '# gprintf "', '\n"' ], - [ 'echo -n "result: $foo"', 'gprintf "', '"' ], - [ 'echo -e "result: $foo"', 'gprintf "', '\n"' ], -); - -my @line_results = ( - [ - 'echo "result: $foo"' . "\n", - 'gprintf "result: %s\n" "$foo"' . "\n" - ], - [ - 'echo "result: \"$foo\""' . "\n", - 'gprintf "result: \"%s\"\n" "$foo"' . "\n" - ], - [ - 'test "$foo" != "AB"', - 'test "$foo" != "AB"', - ] -); - -plan tests => - 4 + (@string_results * 2) + (@start_results * 2) + (@line_results); - -# test loading -ok(require("gprintify"), "loading file OK"); - -# test string function -foreach my $result (@string_results) { - my ($new_string, $variables) = process_string($result->[0]); - is($new_string, $result->[1], "new string OK"); - is($variables, $result->[2], "variable OK"); -} - -# test start function -foreach my $result (@start_results) { - my ($new_start, $string_end) = process_start($result->[0]); - is($new_start, $result->[1], "new start OK"); - is($string_end, $result->[2], "string end OK"); -} - -# test line function -foreach my $result (@line_results) { - my ($new_line) = process_line($result->[0]); - is($new_line, $result->[1], "new line OK"); -} - -# test the script itself -my ($buildroot, $script, $before, $after); - -($buildroot, $script) = setup(<<'EOF'); -echo "Usage: $0 {start|stop|status}" -EOF - -$before = get_md5($script); -run($buildroot); -$after = get_md5($script); - -is( - $before, - $after, - 'service not sourcing /etc/init.d/functions should not be modified' -); - -($buildroot, $script) = setup(<<'EOF'); -. /etc/init.d/functions -echo "Usage: $0 {start|stop|status}" -EOF - -$before = get_md5($script); -run($buildroot); -$after = get_md5($script); - -isnt( - $before, - $after, - 'service sourcing /etc/init.d/functions should be modified' -); - -($buildroot, $script) = setup(<<'EOF'); -. /etc/init.d/functions -echo "Usage: $0 {start|stop|status}" -EOF - -$before = get_md5($script); -$ENV{EXCLUDE_FROM_GPRINTIFICATION} = 'test'; -run($buildroot); -$after = get_md5($script); - -is( - $before, - $after, - 'EXCLUDE_FROM_GPRINTIFICATION should prevent service modification' -); - -sub setup { - my ($content) = @_; - - my $buildroot = tempdir(CLEANUP => ($ENV{TEST_DEBUG} ? 0 : 1)); - - my $initrddir = $buildroot . '/etc/rc.d/init.d'; - my $script = $initrddir . '/test'; - - make_path($initrddir); - open(my $out, '>', $script) or die "can't write to $script: $!"; - print $out $content; - close($out); - - return ($buildroot, $script); -} - -sub run { - my ($buildroot) = @_; - - $ENV{RPM_BUILD_ROOT} = $buildroot; - system("$Bin/../gprintify"); -} - -sub get_md5 { - my ($file) = @_; - open(my $in, '<', $file) or die "can't read $file: $!"; - binmode($in); - my $md5 = Digest::MD5->new(); - $md5->addfile($in); - close($in); - return $md5->hexdigest(); -} |