diff options
author | Jean Delvare <jdelvare@suse.de> | 2014-02-12 21:03:03 +0100 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2014-02-12 21:03:03 +0100 |
commit | 424447abd18d3aebef5e30fd854bca34da619ef3 (patch) | |
tree | af4576d43b0c6aab98cd24c6dcf2a6fbb6d4dd96 | |
parent | 1d390ac9a36679d634bd5b4085cf3af3f43f1939 (diff) | |
download | quilt-424447abd18d3aebef5e30fd854bca34da619ef3.tar.gz |
test/run: Massive reindentation
Code indentation in this file is inconsistent, this makes editing it
difficult. Use tabulations everywhere.
-rw-r--r-- | quilt.changes | 1 | ||||
-rwxr-xr-x | test/run | 307 |
2 files changed, 153 insertions, 155 deletions
diff --git a/quilt.changes b/quilt.changes index ffba039..41e9a0a 100644 --- a/quilt.changes +++ b/quilt.changes @@ -4,6 +4,7 @@ Wed Feb 12 20:57:35 CET 2014 - jdelvare@suse.de - test/run: Delay command line splitting. - test/run: Use perl module Text::ParseWords. - test/run: Drop support for su and sg. +- test/run: Massive reindentation. ------------------------------------------------------------------- Mon Feb 10 13:07:14 CET 2014 - jdelvare@suse.de @@ -150,180 +150,177 @@ print_footer "$status\n"; flush_output $failed; exit $failed ? 1 : 0; - sub process_test($$$$) { - my ($prog, $prog_line, $in, $out) = @_; - - print_body "[$prog_line] \$ $prog -- "; - my ($exec_status, $result) = exec_test($prog, $in); - my @good = (); - my $nmax = (@$out > @$result) ? @$out : @$result; - for (my $n=0; $n < $nmax; $n++) { - my $use_re; - if (defined $out->[$n] && $out->[$n] =~ /^~ /) { - $use_re = 1; - $out->[$n] =~ s/^~ //g; - } - - if (!defined($out->[$n]) || !defined($result->[$n]) || - (!$use_re && $result->[$n] ne $out->[$n]) || - ( $use_re && $result->[$n] !~ /^$out->[$n]/)) { - push @good, ($use_re ? '!~' : '!='); - } - else { - push @good, ($use_re ? '=~' : '=='); - } - } - my $good = !grep(/!/, @good); - $tests++; - $failed++ unless $good; - print_body(($good ? $OK : $FAILED)."\n"); - if (!$good || $opt_v) { - for (my $n=0; $n < $nmax; $n++) { - my $l = defined($out->[$n]) ? $out->[$n] : "~"; - chomp $l; - my $r = defined($result->[$n]) ? $result->[$n] : "~"; - chomp $r; - print_body sprintf("%-" . ($width-3) . "s %s %s\n", - $r, $good[$n], $l); - } - } - - return $exec_status; -} + my ($prog, $prog_line, $in, $out) = @_; + + print_body "[$prog_line] \$ $prog -- "; + my ($exec_status, $result) = exec_test($prog, $in); + my @good = (); + my $nmax = (@$out > @$result) ? @$out : @$result; + for (my $n = 0; $n < $nmax; $n++) { + my $use_re; + if (defined $out->[$n] && $out->[$n] =~ /^~ /) { + $use_re = 1; + $out->[$n] =~ s/^~ //g; + } + + if (!defined($out->[$n]) || !defined($result->[$n]) || + (!$use_re && $result->[$n] ne $out->[$n]) || + ( $use_re && $result->[$n] !~ /^$out->[$n]/)) { + push @good, ($use_re ? '!~' : '!='); + } else { + push @good, ($use_re ? '=~' : '=='); + } + } + my $good = !grep(/!/, @good); + $tests++; + $failed++ unless $good; + print_body(($good ? $OK : $FAILED)."\n"); + if (!$good || $opt_v) { + for (my $n = 0; $n < $nmax; $n++) { + my $l = defined($out->[$n]) ? $out->[$n] : "~"; + chomp $l; + my $r = defined($result->[$n]) ? $result->[$n] : "~"; + chomp $r; + print_body sprintf("%-" . ($width - 3) . "s %s %s\n", + $r, $good[$n], $l); + } + } + return $exec_status; +} sub exec_test($$) { - my ($raw_prog, $in) = @_; - local (*IN, *IN_DUP, *IN2, *OUT_DUP, *OUT, *OUT2); - my $prog = [ shellwords($raw_prog) ]; - my $needs_shell = ($raw_prog =~ /[][|<>;`\$\*\?]/); - - if ($prog->[0] eq "umask") { - umask oct $prog->[1]; - return 0, []; - } elsif ($prog->[0] eq "cd") { - if (!chdir $prog->[1]) { - return 1, [ "chdir: $prog->[1]: $!\n" ]; - } - $ENV{PWD} = getcwd; - return 0, []; - } elsif ($prog->[0] eq "export") { - my ($name, $value) = split /=/, $prog->[1]; - $ENV{$name} = $value; - return 0, []; - } elsif ($prog->[0] eq "unset") { - delete $ENV{$prog->[1]}; - return 0, []; - } - - pipe *IN2, *OUT - or die "Can't create pipe for reading: $!"; - open *IN_DUP, "<&STDIN" - or *IN_DUP = undef; - open *STDIN, "<&IN2" - or die "Can't duplicate pipe for reading: $!"; - close *IN2; - - open *OUT_DUP, ">&STDOUT" - or die "Can't duplicate STDOUT: $!"; - pipe *IN, *OUT2 - or die "Can't create pipe for writing: $!"; - open *STDOUT, ">&OUT2" - or die "Can't duplicate pipe for writing: $!"; - close *OUT2; - - *STDOUT->autoflush(); - *OUT->autoflush(); - - if (fork()) { - # Server - if (*IN_DUP) { - open *STDIN, "<&IN_DUP" - or die "Can't duplicate STDIN: $!"; - close *IN_DUP - or die "Can't close STDIN duplicate: $!"; - } - open *STDOUT, ">&OUT_DUP" - or die "Can't duplicate STDOUT: $!"; - close *OUT_DUP - or die "Can't close STDOUT duplicate: $!"; - - foreach my $line (@$in) { - #print "> $line"; - print OUT $line; - } - close *OUT - or die "Can't close pipe for writing: $!"; - - my $result = []; - while (<IN>) { - #print "< $_"; - if ($needs_shell) { - s#^/bin/sh: line \d+: ##; - } - push @$result, $_; - } - wait(); - return $? >> 8, $result; - } else { - # Client - $< = $>; - close IN - or die "Can't close read end for input pipe: $!"; - close OUT - or die "Can't close write end for output pipe: $!"; - close OUT_DUP - or die "Can't close STDOUT duplicate: $!"; - local *ERR_DUP; - open ERR_DUP, ">&STDERR" - or die "Can't duplicate STDERR: $!"; - open STDERR, ">&STDOUT" - or die "Can't join STDOUT and STDERR: $!"; - - if ($needs_shell) { - exec ('/bin/sh', '-c', $raw_prog); - } else { - exec @$prog; - } - print STDERR $prog->[0], ": $!\n"; - exit; - } + my ($raw_prog, $in) = @_; + local (*IN, *IN_DUP, *IN2, *OUT_DUP, *OUT, *OUT2); + my $prog = [ shellwords($raw_prog) ]; + my $needs_shell = ($raw_prog =~ /[][|<>;`\$\*\?]/); + + if ($prog->[0] eq "umask") { + umask oct $prog->[1]; + return 0, []; + } elsif ($prog->[0] eq "cd") { + if (!chdir $prog->[1]) { + return 1, [ "chdir: $prog->[1]: $!\n" ]; + } + $ENV{PWD} = getcwd; + return 0, []; + } elsif ($prog->[0] eq "export") { + my ($name, $value) = split /=/, $prog->[1]; + $ENV{$name} = $value; + return 0, []; + } elsif ($prog->[0] eq "unset") { + delete $ENV{$prog->[1]}; + return 0, []; + } + + pipe *IN2, *OUT + or die "Can't create pipe for reading: $!"; + open *IN_DUP, "<&STDIN" + or *IN_DUP = undef; + open *STDIN, "<&IN2" + or die "Can't duplicate pipe for reading: $!"; + close *IN2; + + open *OUT_DUP, ">&STDOUT" + or die "Can't duplicate STDOUT: $!"; + pipe *IN, *OUT2 + or die "Can't create pipe for writing: $!"; + open *STDOUT, ">&OUT2" + or die "Can't duplicate pipe for writing: $!"; + close *OUT2; + + *STDOUT->autoflush(); + *OUT->autoflush(); + + if (fork()) { + # Server + if (*IN_DUP) { + open *STDIN, "<&IN_DUP" + or die "Can't duplicate STDIN: $!"; + close *IN_DUP + or die "Can't close STDIN duplicate: $!"; + } + open *STDOUT, ">&OUT_DUP" + or die "Can't duplicate STDOUT: $!"; + close *OUT_DUP + or die "Can't close STDOUT duplicate: $!"; + + foreach my $line (@$in) { + #print "> $line"; + print OUT $line; + } + close *OUT + or die "Can't close pipe for writing: $!"; + + my $result = []; + while (<IN>) { + #print "< $_"; + if ($needs_shell) { + s#^/bin/sh: line \d+: ##; + } + push @$result, $_; + } + wait(); + return $? >> 8, $result; + } else { + # Client + $< = $>; + close IN + or die "Can't close read end for input pipe: $!"; + close OUT + or die "Can't close write end for output pipe: $!"; + close OUT_DUP + or die "Can't close STDOUT duplicate: $!"; + local *ERR_DUP; + open ERR_DUP, ">&STDERR" + or die "Can't duplicate STDERR: $!"; + open STDERR, ">&STDOUT" + or die "Can't join STDOUT and STDERR: $!"; + + if ($needs_shell) { + exec ('/bin/sh', '-c', $raw_prog); + } else { + exec @$prog; + } + print STDERR $prog->[0], ": $!\n"; + exit; + } } sub print_header($) { - if ($opt_q) { - $output{header} = $_[0]; - } else { - print $_[0]; - } + if ($opt_q) { + $output{header} = $_[0]; + } else { + print $_[0]; + } } sub print_body($) { - if ($opt_q) { - $output{body} .= $_[0]; - } else { - print $_[0]; - } + if ($opt_q) { + $output{body} .= $_[0]; + } else { + print $_[0]; + } } sub print_footer($) { - if ($opt_q) { - $output{footer} .= $_[0]; - } else { - print $_[0]; - } + if ($opt_q) { + $output{footer} .= $_[0]; + } else { + print $_[0]; + } } sub flush_output($) { - my $failed = shift; - return unless $opt_q; + my $failed = shift; + return unless $opt_q; - print $output{header} || "", - $failed ? $output{body} : "", - $output{footer} || ""; + print $output{header} || "", + $failed ? $output{body} : "", + $output{footer} || ""; } |