test/tc/cmdpipe.rb in rio-0.3.7 vs test/tc/cmdpipe.rb in rio-0.3.8

- old
+ new

@@ -10,10 +10,13 @@ class TC_cmdpipe < Test::RIO::TestCase @@once = false @@dname = 'd' @@fnames = ['f0','f1','f2','g0','g1'] + require 'tc/programs_util' + include Test::RIO::Programs + def self.once @@once = true rio(@@dname).rmtree.mkpath.chdir { @@fnames.each { |fn| make_lines_file(20,fn) @@ -24,32 +27,32 @@ super self.class.once unless @@once end def test_cmd_out - ls = rio(?-,'ls d') + ls = rio(?-,PROG['list_dir']+' d') out = rio(?").chomp exp = @@fnames rtn = ls | out assert_equal(exp,out[]) assert_equal(rtn,out) end def test_cmd_cmd_out - ls = rio(?-,'ls d') - grep = rio(?-,'grep f') + ls = rio(?-,PROG['list_dir']+' d') + grep = rio(?-,PROG['find_lines']+' f') out = rio(?").chomp exp = @@fnames.select { |fn| fn =~ /f/ } rtn = ls | grep | out assert_equal(exp,out[]) assert_equal(rtn,out) end def test_cmd_cmd_cmd_out - ls = rio(?-,'ls d') - cmd = rio(?-,'grep f') - cmd2 = rio(?-,'grep 1') + ls = rio(?-,PROG['list_dir']+' d') + cmd = rio(?-,PROG['find_lines']+' f') + cmd2 = rio(?-,PROG['find_lines']+' 1') out = rio(?").chomp exp = @@fnames.select { |fn| fn =~ /f1/ } rtn = ls | cmd | cmd2 | out assert_equal(exp,out[]) assert_equal(rtn,out) @@ -64,33 +67,33 @@ assert_equal(rtn,out) end def test_file_cmd_out inp = rio('d/f2') - cmd = rio(?-,'grep 1') + cmd = rio(?-,PROG['find_lines']+' 1') out = rio(?") rtn = inp | cmd | out exp = inp[/1/] assert_equal(exp,out[]) assert_equal(rtn,out) end def test_file_cmd_cmd_out inp = rio('d/f2') - cmd = rio(?-,'grep 1') - cmd2 = rio(?-,'grep 0') + cmd = rio(?-,PROG['find_lines']+' 1') + cmd2 = rio(?-,PROG['find_lines']+' 0') out = rio(?") rtn = inp | cmd | cmd2 | out exp = inp[/10/] assert_equal(exp,out[]) assert_equal(rtn,out) end def test_file_cmdpipe_out2 inp = rio('d/f2') - cmd = rio(?-,'grep 1') - cmd2 = rio(?-,'grep 0') + cmd = rio(?-,PROG['find_lines']+' 1') + cmd2 = rio(?-,PROG['find_lines']+' 0') cmdpipe = inp | cmd | cmd2 assert_equal('cmdpipe',cmdpipe.scheme) out = rio(?") @@ -106,12 +109,12 @@ assert_equal(rtn,out) end def test_file_cmdpipe_out inp = rio('d/f2') - cmd = rio(?-,'grep 1') - cmd2 = rio(?-,'grep 0') + cmd = rio(?-,PROG['find_lines']+' 1') + cmd2 = rio(?-,PROG['find_lines']+' 0') out = rio(?") cmdpipe = cmd | cmd2 assert_equal('cmdpipe',cmdpipe.scheme) @@ -120,11 +123,11 @@ assert_equal(exp,out[]) assert_equal(rtn,out) end def test_cmdpipe_without - cmd = rio(?-,'grep 1') - cmd2 = rio(?-,'grep 0') + cmd = rio(?-,PROG['find_lines']+' 1') + cmd2 = rio(?-,PROG['find_lines']+' 0') out = rio(?") cmdpipe = rio(?|,cmd,cmd2,out) assert_equal('cmdpipe',cmdpipe.scheme)