diff options
-rw-r--r-- | test/conflicts.test | 28 | ||||
-rw-r--r-- | test/failpop.test | 8 | ||||
-rw-r--r-- | test/half-applies.test | 8 | ||||
-rw-r--r-- | test/no-file-to-patch.test | 2 | ||||
-rwxr-xr-x | test/run | 39 |
5 files changed, 69 insertions, 16 deletions
diff --git a/test/conflicts.test b/test/conflicts.test index bfd66fa..21c8499 100644 --- a/test/conflicts.test +++ b/test/conflicts.test @@ -23,37 +23,53 @@ anymore, then the patch is fixed. $ quilt new a.diff > Patch %{P}a.diff is now on top + $ echo %{?} + > 0 $ quilt add one.txt > File one.txt added to patch %{P}a.diff + $ echo %{?} + > 0 $ mv one.txt one.orig $ sed -e "s/4/4+/" -e 's/d/d+/' one.orig > one.txt $ quilt refresh > Refreshed patch %{P}a.diff + $ echo %{?} + > 0 $ quilt pop -q > Removing patch %{P}a.diff > No patches applied + $ echo %{?} + > 0 $ sed -e "s/^\\([17]\\)\$/\\1-/" one.orig > one.txt $ quilt push -q > Applying patch %{P}a.diff > Now at patch %{P}a.diff + $ echo %{?} + > 0 $ quilt pop -q > Removing patch %{P}a.diff > No patches applied + $ echo %{?} + > 0 $ sed -e "s/^\\([1267]\\)\$/\\1-/" one.orig > one.txt $ quilt push -q > Applying patch %{P}a.diff > Now at patch %{P}a.diff + $ echo %{?} + > 0 $ quilt pop -q > Removing patch %{P}a.diff > No patches applied + $ echo %{?} + > 0 $ sed -e "s/^\\([123567]\\)\$/\\1-/" one.orig > one.txt @@ -61,11 +77,15 @@ anymore, then the patch is fixed. > Applying patch %{P}a.diff > 1 out of 2 hunks FAILED > Patch %{P}a.diff does not apply (enforce with -f) + $ echo %{?} + > 1 $ quilt push -qf > Applying patch %{P}a.diff >~ 1 out of 2 hunks FAILED -- saving rejects to (file )?`?one.txt.rej'? > Applied patch %{P}a.diff (forced; needs refresh) + $ echo %{?} + > 1 $ mv one.txt one.x $ sed -e "s/4/4+/" one.x > one.txt @@ -82,6 +102,8 @@ anymore, then the patch is fixed. > 5- > 6- > 7- + $ echo %{?} + > 0 $ quilt diff | grep -v "^\\(---\\|+++\\)" >~ Index: [^/]+/one\.txt @@ -104,9 +126,13 @@ anymore, then the patch is fixed. > e > f > g + $ echo %{?} + > 0 $ quilt refresh > Refreshed patch %{P}a.diff + $ echo %{?} + > 0 $ cat patches/a.diff | grep -v "^\\(---\\|+++\\)" >~ Index: [^/]+/one\.txt @@ -133,3 +159,5 @@ anymore, then the patch is fixed. $ quilt pop -q > Removing patch %{P}a.diff > No patches applied + $ echo %{?} + > 0 diff --git a/test/failpop.test b/test/failpop.test index 8b566c4..79ea747 100644 --- a/test/failpop.test +++ b/test/failpop.test @@ -5,17 +5,25 @@ $ quilt new test.diff > Patch %{P}test.diff is now on top + $ echo %{?} + > 0 $ quilt add test.txt > File test.txt added to patch %{P}test.diff + $ echo %{?} + > 0 $ cat >> test.txt < Line two. $ quilt refresh > Refreshed patch %{P}test.diff + $ echo %{?} + > 0 $ sed -e "s/ /_/g" patches/test.diff > patches/test.new $ mv patches/test.new patches/test.diff $ quilt pop > Patch %{P}test.diff does not remove cleanly (refresh it or enforce with -f) + $ echo %{?} + > 1 diff --git a/test/half-applies.test b/test/half-applies.test index 1702a03..243f6c3 100644 --- a/test/half-applies.test +++ b/test/half-applies.test @@ -16,6 +16,8 @@ $ quilt push > Hunk #1 FAILED at 1. >~ 1 out of 1 hunk FAILED -- rejects in file `?bar'? > Patch patches/foorab.diff does not apply (enforce with -f) +$ echo %{?} +> 1 $ quilt push > Applying patch patches/foorab.diff @@ -24,11 +26,15 @@ $ quilt push > Hunk #1 FAILED at 1. >~ 1 out of 1 hunk FAILED -- rejects in file `?bar'? > Patch patches/foorab.diff does not apply (enforce with -f) +$ echo %{?} +> 1 $ quilt push -qf > Applying patch patches/foorab.diff >~ 1 out of 1 hunk FAILED( -- saving rejects to( file)? bar.rej)? > Applied patch patches/foorab.diff (forced; needs refresh) +$ echo %{?} +> 1 $ quilt diff > Index: foo @@ -38,3 +44,5 @@ $ quilt diff > @@ -1 +1 @@ > -foo > +foo2 +$ echo %{?} +> 0 diff --git a/test/no-file-to-patch.test b/test/no-file-to-patch.test index 1836e52..d7ffaa4 100644 --- a/test/no-file-to-patch.test +++ b/test/no-file-to-patch.test @@ -21,3 +21,5 @@ $ quilt push -q > No file to patch. Skipping patch. > 1 out of 1 hunk ignored > Patch patches/one.patch does not apply (enforce with -f) +$ echo %{?} +> 1 @@ -62,6 +62,7 @@ sub flush_output($); my ($prog, $in, $out) = ([], [], []); my $prog_line = 0; +my $last_status = 0; my ($tests, $failed) = (0,0); my $lineno; my $width = ($ENV{COLUMNS} || 80) >> 1; @@ -92,13 +93,16 @@ for (;;) { } elsif ($line =~ s/^\s*> ?//) { push @$out, $line; } else { - process_test($prog, $prog_line, $in, $out); + $last_status = process_test($prog, $prog_line, $in, $out) if @$prog; last if $prog_line >= $opt_l; $prog = []; $prog_line = 0; } if ($line =~ s/^\s*\$ ?//) { + # Substitute %{?} with the last command's status. + $line =~ s[%{\?}][$last_status]eg; + $prog = [ map { s/\\(.)/$1/g; $_ } split /(?<!\\)\s+/, $line ]; $prog_line = $lineno; $in = []; @@ -138,7 +142,7 @@ sub process_test($$$$) { my $p = [ @$prog ]; print_body "[$prog_line] \$ ".join(' ', map { s/\s/\\$&/g; $_ } @$p)." -- "; - my $result = exec_test($prog, $in); + my ($exec_status, $result) = exec_test($prog, $in); my @good = (); my $nmax = (@$out > @$result) ? @$out : @$result; for (my $n=0; $n < $nmax; $n++) { @@ -171,6 +175,8 @@ sub process_test($$$$) { $r, $good[$n], $l); } } + + return $exec_status; } @@ -180,10 +186,10 @@ sub su($) { $user ||= "root"; my ($login, $pass, $uid, $gid) = getpwnam($user) - or return [ "su: user $user does not exist\n" ]; + or return 1, [ "su: user $user does not exist\n" ]; my @groups = (); my $fh = new FileHandle("/etc/group") - or return [ "opening /etc/group: $!\n" ]; + or return 1, [ "opening /etc/group: $!\n" ]; while (<$fh>) { chomp; my ($group, $passwd, $gid, $users) = split /:/; @@ -201,17 +207,17 @@ sub su($) { $( = $gid; $) = $groups; if ($!) { - return [ "su: $!\n" ]; + return 1, [ "su: $!\n" ]; } if ($uid != 0) { $> = $uid; #$< = $uid; if ($!) { - return [ "su: $prog->[1]: $!\n" ]; + return 1, [ "su: $prog->[1]: $!\n" ]; } } #print STDERR "[($>,$<)($(,$))]"; - return []; + return 0, []; } @@ -219,7 +225,7 @@ sub sg($) { my ($group) = @_; my $gid = getgrnam($group) - or return [ "sg: group $group does not exist\n" ]; + or return 1, [ "sg: group $group does not exist\n" ]; my %groups = map { $_ eq $gid ? () : ($_ => 1) } (split /\s/, $)); #print STDERR "<<", join("/", keys %groups), ">>\n"; @@ -237,10 +243,10 @@ sub sg($) { $) = $groups; } if ($!) { - return [ "sg: $!\n" ]; + return 1, [ "sg: $!\n" ]; } print STDERR "[($>,$<)($(,$))]"; - return []; + return 0, []; } @@ -251,13 +257,13 @@ sub exec_test($$) { if ($prog->[0] eq "umask") { umask oct $prog->[1]; - return []; + return 0, []; } elsif ($prog->[0] eq "cd") { if (!chdir $prog->[1]) { - return [ "chdir: $prog->[1]: $!\n" ]; + return 1, [ "chdir: $prog->[1]: $!\n" ]; } $ENV{PWD} = getcwd; - return []; + return 0, []; } elsif ($prog->[0] eq "su") { return su($prog->[1]); } elsif ($prog->[0] eq "sg") { @@ -267,10 +273,10 @@ sub exec_test($$) { # FIXME: need to evaluate $value, so that things like this will work: # export dir=$PWD/dir $ENV{$name} = $value; - return []; + return 0, []; } elsif ($prog->[0] eq "unset") { delete $ENV{$prog->[1]}; - return []; + return 0, []; } pipe *IN2, *OUT @@ -320,7 +326,8 @@ sub exec_test($$) { } push @$result, $_; } - return $result; + wait(); + return $? >> 8, $result; } else { # Client $< = $>; |