OSDN Git Service

*** empty log message ***
[lha/lha.git] / tests / lha-test9
1 # -*- shell-script -*-
2 message 'testing extracting to existent 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         # p [\$!, \$!.status, \$?]
26         exit \$!.status >> 8
27       end
28     }
29 EOF
30 }
31
32 mkdir test-tmp &&
33 echo foo > test-tmp/test-a &&
34 echo bar > test-tmp/test-b &&
35 echo baz > test-tmp/test-c &&
36 cp -pr test-tmp test-tmp2  &&
37 $lha c test-tmp.lzh test-tmp
38                                                         check $?
39 $lha v test-tmp.lzh &&
40 $lha v test-1.lzh
41                                                         check $?
42
43 # skip file
44 pty 3 n  $lha xw=test-tmp test-1.lzh
45                                                         check $?
46 diff -r test-tmp test-tmp2
47                                                         check $?
48 # overwrite
49 pty 3 y  $lha xw=test-tmp test-1.lzh
50                                                         check $?
51 diff -r test-1 test-tmp
52                                                         check $?
53 # overwrite all
54 pty 1 a  $lha x test-tmp.lzh
55                                                         check $?
56 diff -r test-tmp test-tmp2
57                                                         check $?
58 # skip all
59 pty 1 s  $lha xw=test-tmp test-1.lzh
60                                                         check $?
61 diff -r test-tmp test-tmp2
62                                                         check $?