Permalink
Browse files

use test helpers

  • Loading branch information...
adamv committed May 4, 2014
1 parent 283f6ad commit 1d9631c423c4b0034eeaab1ce4fdf167651eed81
Showing with 167 additions and 346 deletions.
  1. +2 βˆ’5 Formula/aamath.rb
  2. +3 βˆ’11 Formula/aardvark_shell_utils.rb
  3. +2 βˆ’5 Formula/ack.rb
  4. +2 βˆ’5 Formula/aha.rb
  5. +1 βˆ’3 Formula/algol68g.rb
  6. +1 βˆ’5 Formula/align.rb
  7. +1 βˆ’3 Formula/ansifilter.rb
  8. +1 βˆ’3 Formula/ascii.rb
  9. +1 βˆ’3 Formula/ats2-postiats.rb
  10. +2 βˆ’2 Formula/autopano-sift-c.rb
  11. +1 βˆ’1 Formula/avian.rb
  12. +1 βˆ’2 Formula/avra.rb
  13. +1 βˆ’4 Formula/base64.rb
  14. +1 βˆ’4 Formula/basex.rb
  15. +1 βˆ’3 Formula/bash.rb
  16. +4 βˆ’6 Formula/bgrep.rb
  17. +1 βˆ’3 Formula/calc.rb
  18. +3 βˆ’12 Formula/cayley.rb
  19. +1 βˆ’5 Formula/cbmbasic.rb
  20. +1 βˆ’2 Formula/ccal.rb
  21. +2 βˆ’3 Formula/cdecl.rb
  22. +1 βˆ’2 Formula/check_postgres.rb
  23. +1 βˆ’3 Formula/chicken.rb
  24. +2 βˆ’1 Formula/chkrootkit.rb
  25. +1 βˆ’3 Formula/cksfv.rb
  26. +2 βˆ’6 Formula/cloog.rb
  27. +1 βˆ’2 Formula/cowsay.rb
  28. +1 βˆ’2 Formula/cpmtools.rb
  29. +1 βˆ’3 Formula/css-crush.rb
  30. +2 βˆ’5 Formula/csv-fix.rb
  31. +2 βˆ’5 Formula/csvprintf.rb
  32. +1 βˆ’1 Formula/dart.rb
  33. +1 βˆ’1 Formula/dasm.rb
  34. +2 βˆ’3 Formula/ddate.rb
  35. +2 βˆ’4 Formula/disktype.rb
  36. +2 βˆ’1 Formula/djvulibre.rb
  37. +1 βˆ’1 Formula/dockutil.rb
  38. +2 βˆ’1 Formula/elinks.rb
  39. +1 βˆ’3 Formula/emacs.rb
  40. +2 βˆ’4 Formula/enscript.rb
  41. +1 βˆ’1 Formula/fakeroot.rb
  42. +1 βˆ’2 Formula/fdupes.rb
  43. +1 βˆ’1 Formula/fzf.rb
  44. +6 βˆ’7 Formula/gawk.rb
  45. +2 βˆ’5 Formula/git-tracker.rb
  46. +2 βˆ’4 Formula/gptfdisk.rb
  47. +1 βˆ’4 Formula/htmlcleaner.rb
  48. +1 βˆ’1 Formula/hub.rb
  49. +1 βˆ’4 Formula/iozone.rb
  50. +1 βˆ’5 Formula/javarepl.rb
  51. +1 βˆ’5 Formula/jq.rb
  52. +1 βˆ’6 Formula/jshon.rb
  53. +8 βˆ’10 Formula/jslint4java.rb
  54. +1 βˆ’5 Formula/jsmin.rb
  55. +7 βˆ’10 Formula/jsonpp.rb
  56. +2 βˆ’6 Formula/libvbucket.rb
  57. +1 βˆ’3 Formula/lorem.rb
  58. +1 βˆ’5 Formula/markdown.rb
  59. +2 βˆ’4 Formula/mp3fs.rb
  60. +1 βˆ’4 Formula/msitools.rb
  61. +1 βˆ’5 Formula/multimarkdown.rb
  62. +2 βˆ’7 Formula/newick-utils.rb
  63. +6 βˆ’8 Formula/newlisp.rb
  64. +1 βˆ’4 Formula/nodebrew.rb
  65. +1 βˆ’3 Formula/phantomjs.rb
  66. +1 βˆ’4 Formula/picolisp.rb
  67. +7 βˆ’8 Formula/pidcat.rb
  68. +1 βˆ’3 Formula/pike.rb
  69. +7 βˆ’10 Formula/q.rb
  70. +1 βˆ’3 Formula/scala.rb
  71. +1 βˆ’4 Formula/spidermonkey.rb
  72. +1 βˆ’1 Formula/tpp.rb
  73. +7 βˆ’8 Formula/ucspi-tcp.rb
  74. +1 βˆ’5 Formula/udis86.rb
  75. +1 βˆ’4 Formula/unac.rb
  76. +1 βˆ’3 Formula/vala.rb
  77. +13 βˆ’13 Formula/vera++.rb
  78. +2 βˆ’3 Formula/wdiff.rb
  79. +1 βˆ’1 Formula/wireshark.rb
  80. +2 βˆ’3 Formula/xmlsh.rb
  81. +2 βˆ’3 Formula/yajl.rb
  82. +1 βˆ’3 Formula/yara.rb
  83. +1 βˆ’1 Formula/yle-dl.rb
  84. +1 βˆ’3 Formula/z80dasm.rb
  85. +1 βˆ’3 Formula/zxcc.rb
View
@@ -19,11 +19,8 @@ def install
end
test do
IO.popen("#{bin}/aamath", "w+") do |pipe|
pipe.write((prefix/"testcases").read)
pipe.close_write
assert_match /#{Regexp.escape("f(x + h) = f(x) + h f'(x)")}/, pipe.read
end
s = pipe_output("#{bin}/aamath", (prefix/"testcases").read)
assert_match /#{Regexp.escape("f(x + h) = f(x) + h f'(x)")}/, s
end
end
@@ -14,16 +14,8 @@ def install
end
test do
output = `#{bin}/filebase movcpm.com`
assert_equal "movcpm\n", output
assert_equal 0, $?.exitstatus
output = `#{bin}/fileext movcpm.com`
assert_equal "com\n", output
assert_equal 0, $?.exitstatus
output = `#{bin}/realpath .`
assert_equal "#{testpath}\n", output
assert_equal 0, $?.exitstatus
assert_equal "movcpm", shell_output("#{bin}/filebase movcpm.com").strip
assert_equal "com", shell_output("#{bin}/fileext movcpm.com").strip
assert_equal testpath.to_s, shell_output("#{bin}/realpath .").strip
end
end
View
@@ -13,10 +13,7 @@ def install
end
test do
IO.popen("#{bin}/ack --noenv --nocolor bar -", "w+") do |pipe|
pipe.write "foo\nfoo bar\nbaz"
pipe.close_write
assert_equal "foo bar\n", pipe.read
end
assert_equal "foo bar\n", pipe_output("#{bin}/ack --noenv --nocolor bar -",
"foo\nfoo bar\nbaz")
end
end
View
@@ -11,10 +11,7 @@ def install
end
test do
IO.popen("#{bin}/aha", "w+") do |pipe|
pipe.write("rainpill")
pipe.close_write
assert_match /color:purple;">rain.*color:blue;">pill/, pipe.read
end
out = pipe_output(bin/"aha", "rainpill")
assert_match /color:purple;">rain.*color:blue;">pill/, out
end
end
View
@@ -18,8 +18,6 @@ def install
print("Hello World")
EOS
output = `#{bin}/a68g #{path}`.strip
assert_equal "Hello World", output
assert_equal 0, $?.exitstatus
assert_equal "Hello World", shell_output("#{bin}/a68g #{path}").strip
end
end
View
@@ -17,10 +17,6 @@ def install
end
test do
IO.popen(bin/"align", "w+") do |pipe|
pipe.write "1 1\n12 12\n"
pipe.close_write
assert_equal " 1 1\n12 12\n", pipe.read
end
assert_equal " 1 1\n12 12\n", pipe_output(bin/"align", "1 1\n12 12\n")
end
end
View
@@ -22,8 +22,6 @@ def install
path = testpath/"ansi.txt"
path.write "f\x1b[31moo"
output = `#{bin}/ansifilter #{path}`.strip
assert_equal "foo", output
assert_equal 0, $?.exitstatus
assert_equal "foo", shell_output("#{bin}/ansifilter #{path}").strip
end
end
View
@@ -12,8 +12,6 @@ def install
end
test do
output = `#{bin}/ascii 0x0a`
assert output.include?("Official name: Line Feed")
assert_equal 0, $?.exitstatus
assert shell_output(bin/"ascii 0x0a").include?("Official name: Line Feed")
end
end
View
@@ -31,8 +31,6 @@ def install
implement main0 () = ()
EOS
system "#{bin}/patscc hello.dats -o hello"
IO.popen("./hello", "r") do |pipe|
assert_match "Hello, world!", pipe.read
end
assert_match "Hello, world!", shell_output(testpath/"hello")
end
end
@@ -14,7 +14,7 @@ def install
end
test do
pipe = IO.popen("#{bin}/autopano-sift-c")
assert_match /Version #{Regexp.escape(version)}/, pipe.read
assert_match /Version #{Regexp.escape(version)}/,
pipe_output("#{bin}/autopano-sift-c")
end
end
View
@@ -29,6 +29,6 @@ def install
}
EOS
system 'javac', 'Test.java'
assert_equal 'OK', `avian Test`.strip
assert_equal 'OK', shell_output("#{bin}/avian Test")
end
end
View
@@ -21,9 +21,8 @@ def install
test do
(testpath/"test.asm").write " .device attiny10\n ldi r16,0x42\n"
output = `#{bin}/avra -l test.lst test.asm`
output = shell_output("#{bin}/avra -l test.lst test.asm")
assert output.include?("Assembly complete with no errors.")
assert_equal 0, $?.exitstatus
assert File.exist?("test.hex")
assert File.read("test.lst").include?("ldi r16,0x42")
end
View
@@ -15,9 +15,6 @@ def install
test do
path = testpath/"a.txt"
path.write "hello"
output = `#{bin}/base64 #{path}`.strip
assert_equal "aGVsbG8=", output
assert_equal 0, $?.exitstatus
assert_equal "aGVsbG8=", shell_output("#{bin}/base64 #{path}").strip
end
end
View
@@ -17,9 +17,6 @@ def install
end
test do
require 'open3'
Open3.popen3("#{bin}/basex", "1 to 10") do |_, stdout, _|
assert_equal "1 2 3 4 5 6 7 8 9 10", stdout.read
end
assert_equal "1 2 3 4 5 6 7 8 9 10", shell_output("#{bin}/basex '1 to 10'")
end
end
View
@@ -42,8 +42,6 @@ def caveats; <<-EOS.undent
end
test do
output = `#{bin}/bash -c "echo hello"`.strip
assert_equal "hello", output
assert_equal 0, $?.exitstatus
assert_equal "hello", shell_output("#{bin}/bash -c \"echo hello\"").strip
end
end
View
@@ -12,12 +12,10 @@ def install
test do
path = testpath/"hi.prg"
code = [0x00, 0xc0, 0xa9, 0x48, 0x20, 0xd2, 0xff,
0xa9, 0x49, 0x20, 0xd2, 0xff, 0x60].pack("C*")
path.open("wb") { |f| f.write code }
path.binwrite [0x00, 0xc0, 0xa9, 0x48, 0x20, 0xd2, 0xff,
0xa9, 0x49, 0x20, 0xd2, 0xff, 0x60].pack("C*")
lines = `#{bin}/bgrep 20d2ff #{path}`.strip.split("\n")
assert_equal ["#{path}: 00000004", "#{path}: 00000009"], lines
assert_equal 0, $?.exitstatus
assert_equal ["#{path}: 00000004", "#{path}: 00000009"],
shell_output("#{bin}/bgrep 20d2ff #{path}").split("\n")
end
end
View
@@ -43,8 +43,6 @@ def install
end
test do
output = `#{bin}/calc 0xA + 1`.strip
assert_equal "11", output
assert_equal 0, $?.exitstatus
assert_equal "11", shell_output("#{bin}/calc 0xA + 1").strip
end
end
View
@@ -117,18 +117,9 @@ def plist; <<-EOS.undent
end
test do
require 'open3'
touch "test.nt"
Open3.popen3("#{bin}/cayley", "repl", "--dbpath=#{testpath}/test.nt") do |stdin, stdout, _|
stdin.write "graph.Vertex().All()"
stdin.close
result = stdout.read.strip
assert !result.include?("Error:")
assert result.include?("Elapsed time:")
end
result = pipe_output("#{bin}/cayley repl --dbpath=#{testpath}/test.nt", "graph.Vertex().All()")
assert !result.include?("Error:")
assert result.include?("Elapsed time:")
end
end
View
@@ -11,10 +11,6 @@ def install
end
test do
IO.popen("#{bin}/cbmbasic", "w+") do |pipe|
pipe.write("PRINT 1\n")
pipe.close_write
assert_match /READY.\r\n 1/, pipe.read
end
assert_match /READY.\r\n 1/, pipe_output("#{bin}/cbmbasic", "PRINT 1\n")
end
end
View
@@ -11,8 +11,7 @@ def install
end
test do
output = `#{bin}/ccal 2 2014`
output = shell_output("#{bin}/ccal 2 2014")
assert output.include?("Year JiaWu, Month 1X")
assert_equal 0, $?.exitstatus
end
end
View
@@ -23,8 +23,7 @@ def install
end
test do
output = `#{bin}/cdecl explain int *a`.strip
assert_equal "declare a as pointer to int", output
assert_equal 0, $?.exitstatus
assert_equal "declare a as pointer to int",
shell_output("#{bin}/cdecl explain int *a").strip
end
end
@@ -28,8 +28,7 @@ def install
test do
# This test verifies that check_postgres fails correctly, assuming
# that no server is running at that port.
output = `#{bin}/check_postgres --action=connection --port=65432`
output = shell_output("#{bin}/check_postgres --action=connection --port=65432", 2)
assert output.include? "POSTGRES_CONNECTION CRITICAL"
assert_equal 2, $?.exitstatus
end
end
View
@@ -27,8 +27,6 @@ def install
end
test do
output = `'#{bin}/csi' -e '(print (* 5 5))'`
assert_equal "25", output.strip
assert $?.success?
assert_equal "25", shell_output("#{bin}/csi -e '(print (* 5 5))'").strip
end
end
View
@@ -18,6 +18,7 @@ def install
end
test do
assert_equal "chkrootkit version #{version}", `#{bin}/chkrootkit -V 2>&1`.strip
assert_equal "chkrootkit version #{version}",
shell_output("#{bin}/chkrootkit -V 2>&1", 1).strip
end
end
View
@@ -14,8 +14,6 @@ def install
path = testpath/"foo"
path.write "abcd"
lines = `#{bin}/cksfv #{path}`.split("\n")
assert lines.include?("#{path} ED82CD11")
assert_equal 0, $?.exitstatus
assert shell_output("#{bin}/cksfv #{path}").include?("#{path} ED82CD11")
end
end
View
@@ -61,11 +61,7 @@ def install
0
EOS
require 'open3'
Open3.popen3("#{bin}/cloog", "/dev/stdin") do |stdin, stdout, _|
stdin.write(cloog_source)
stdin.close
assert_match /Generated from \/dev\/stdin by CLooG/, stdout.read
end
output = pipe_output("#{bin}/cloog /dev/stdin", cloog_source)
assert_match /Generated from \/dev\/stdin by CLooG/, output
end
end
View
@@ -14,9 +14,8 @@ def install
end
test do
output = `#{bin}/cowsay moo`
output = shell_output("#{bin}/cowsay moo")
assert output.include?("moo") # bubble
assert output.include?("^__^") # cow
assert_equal 0, $?.exitstatus
end
end
View
@@ -26,8 +26,7 @@ def install
system "#{bin}/cpmcp -f ibm-3740 #{image} #{src} 0:foo"
# check for the file in the cp/m directory
assert `#{bin}/cpmls -f ibm-3740 #{image}`.include?("foo")
assert_equal 0, $?.exitstatus
assert shell_output("#{bin}/cpmls -f ibm-3740 #{image}").include?("foo")
# copy the file back out of the image
dest = testpath/"bar"
View
@@ -20,8 +20,6 @@ def install
p { color: $(foo); }
EOS
output = `#{bin}/csscrush #{path}`.strip
assert_equal "p{color:#123456}", output
assert_equal 0, $?.exitstatus
assert_equal "p{color:#123456}", shell_output("#{bin}/csscrush #{path}").strip
end
end
View
@@ -17,10 +17,7 @@ def install
end
test do
IO.popen("#{bin}/csvfix trim", "w+") do |pipe|
pipe.write "foo , bar \n"
pipe.close_write
assert_equal %{"foo","bar"\n}, pipe.read
end
assert_equal %{"foo","bar"\n},
pipe_output("#{bin}/csvfix trim", "foo , bar \n")
end
end
View
@@ -13,10 +13,7 @@ def install
end
test do
IO.popen("#{bin}/csvprintf -i '%2$s %1$s\n'", "w+") do |pipe|
pipe.write "Last,First\nSmith,Fred\n"
pipe.close_write
assert_equal "Fred Smith\n", pipe.read
end
assert_equal "Fred Smith\n",
pipe_output("#{bin}/csvprintf -i '%2$s %1$s\n'", "Last,First\nSmith,Fred\n")
end
end
View
@@ -32,6 +32,6 @@ def caveats; <<-EOS.undent
}
EOS
assert_equal "test message\n", `#{bin}/dart sample.dart`
assert_equal "test message\n", shell_output("#{bin}/dart sample.dart")
end
end
View
@@ -27,7 +27,7 @@ def install
EOS
system bin/"dasm", path
code = File.open(testpath/"a.out", "rb") { |f| f.read.unpack("C*") }
code = (testpath/"a.out").binread.unpack("C*")
assert_equal [0x00, 0xc0, 0x4c, 0xe2, 0xfc], code
end
end
View
@@ -19,8 +19,7 @@ def install
end
test do
out = `#{bin}/ddate 20 6 2014`
assert_equal "Sweetmorn, Confusion 25, 3180 YOLD\n", out
assert_equal 0, $?.exitstatus
output = shell_output("#{bin}/ddate 20 6 2014").strip
assert_equal "Sweetmorn, Confusion 25, 3180 YOLD", output
end
end
Oops, something went wrong.

0 comments on commit 1d9631c

Please sign in to comment.