OSDN Git Service

Merge branch 'master' of github.com:jca02266/lha
[lha/lha.git] / tests / lha-test9
1 # -*- shell-script -*-
2 message 'testing overriding existing files (this test need the Ruby interpreter http://www.ruby-lang.org/)'
3
4 pty()
5 {
6   count=$1; shift
7   input=$1; shift  # y, n, a or s
8
9   ruby <<EOF
10     require 'pty'
11
12     inp, out, fd = PTY.getpty("$*")
13
14     th = Thread.start {
15       $count.times {
16         out.puts "$input"
17       }
18     }
19
20     loop {
21       begin
22         print inp.gets
23       rescue Errno::EIO
24       rescue PTY::ChildExited
25         if \$!.status & 0xff != 0
26           STDERR.puts [\$!, \$!.status, \$?].inspect
27         end
28         exit \$!.status >> 8
29       end
30     }
31 EOF
32 }
33
34 mkdir test-tmp &&
35 echo foo > test-tmp/test-a &&
36 echo bar > test-tmp/test-b &&
37 echo baz > test-tmp/test-c &&
38 cp -pr test-tmp test-tmp2  &&
39 $lha c test-tmp.lzh test-tmp
40                                                         check $? $LINENO
41 $lha v test-tmp.lzh &&
42 $lha v test-1.lzh
43                                                         check $? $LINENO
44
45 # skip file
46 rm -rf test-tmp &&
47 cp -pr test-tmp2 test-tmp &&
48 pty 3 n  $lha xw=test-tmp test-1.lzh
49                                                         check $? $LINENO
50 diff -r test-tmp test-tmp2
51                                                         check $? $LINENO
52 # overwrite
53 rm -rf test-tmp &&
54 cp -pr test-tmp2 test-tmp &&
55 pty 3 y  $lha xw=test-tmp test-1.lzh
56                                                         check $? $LINENO
57 diff -r test-1 test-tmp
58                                                         check $? $LINENO
59 # overwrite all
60 rm -rf test-tmp &&
61 cp -pr test-1 test-tmp &&
62 pty 1 a  $lha x test-tmp.lzh
63                                                         check $? $LINENO
64 diff -r test-tmp test-tmp2
65                                                         check $? $LINENO
66 # skip all
67 rm -rf test-tmp &&
68 cp -pr test-tmp2 test-tmp &&
69 pty 1 s  $lha xw=test-tmp test-1.lzh
70                                                         check $? $LINENO
71 diff -r test-tmp test-tmp2
72                                                         check $? $LINENO