1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
Testing SystemU do
##
#
testing 'that simple usage works' do
status, stdout, stderr = assert{ systemu :bin/:ls }
assert{ status == 0 }
assert{ stdout['lib'] }
assert{ stderr.strip.empty? }
end
testing 'program with stdin' do
stdin = '42'
status, stdout, stderr = assert{ systemu :bin/:cat, :stdin => stdin }
assert{ status == 0 }
assert{ stdout == stdin }
end
end
BEGIN {
# silly hax to build commands we can shell out to on any platform. since
# tests might run on windoze we assume only that 'ruby' is available and build
# other command-line programs from it.
#
module Kernel
private
def bin(which, options = {}, &block)
case which.to_s
when 'ls'
%| ruby -e'puts Dir.glob("*").sort' |
when 'cat'
%| ruby -e'STDOUT.write(ARGF.read)' |
when 'find'
%| ruby -e'puts Dir.glob("**/**").sort' |
end
end
end
# just let's us write: :bin/:ls
#
class Symbol
def / other, options = {}, &block
eval "#{ self }(:#{ other }, options, &block)"
end
end
testdir = File.dirname(File.expand_path(__FILE__))
rootdir = File.dirname(testdir)
libdir = File.join(rootdir, 'lib')
require File.join(libdir, 'systemu')
require File.join(testdir, 'testing')
Dir.chdir(rootdir)
}
|