tap_out 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in tap_out.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,3 @@
1
+ module TapOut
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,29 @@
1
+ require 'test/tap/test_suite'
2
+
3
+ module Test
4
+ module PHPUnit
5
+
6
+ def phpunit(file, opts={})
7
+ (class << self; self end).instance_eval do
8
+ define_method :suite do
9
+ Test::PHPUnit::TestSuite.new file, opts
10
+ end
11
+ end
12
+ end
13
+
14
+ class TestSuite < Test::Unit::TestSuite
15
+ include Test::TAP::TestSuite
16
+
17
+ def initialize(php_file, opts={})
18
+ @php_file = php_file
19
+ @php_opt_string = opts.collect { |k,v| "--#{k} '#{v}'" }.join " "
20
+ super 'Dummy'
21
+ end
22
+
23
+ def shell_cmd
24
+ "phpunit --tap #{@php_opt_string} #{@php_file}"
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,46 @@
1
+ require 'yaml'
2
+
3
+ module Test
4
+ module TAP
5
+ class TestCase
6
+
7
+ def initialize(line)
8
+ @tap_line = line
9
+ end
10
+
11
+ def run(result)
12
+ dummy, ok, failure, case_name, test_name = /^(ok|not ok) \d+ - ((?:\w+: )?)(\w+)::(.+)$/.match(@tap_line).to_a
13
+ name = "#{sanitize_test_name test_name}(#{case_name})"
14
+ yield(Test::Unit::TestCase::STARTED, name)
15
+ if ok == 'not ok'
16
+ if failure.chomp(': ') == 'Failure'
17
+ # If PHPUnit would return more info, we could fill this out
18
+ result.add_failure(Test::Unit::Failure.new(name, [], failure_message))
19
+ else
20
+ #TODO add_error
21
+ end
22
+ end
23
+ result.add_run
24
+ yield(Test::Unit::TestCase::FINISHED, name)
25
+ end
26
+
27
+ def parse_details yaml
28
+ @details = YAML::load( yaml )
29
+ end
30
+
31
+ private
32
+ def sanitize_test_name(test_name)
33
+ /(.* with data set #\d+).*/.match(test_name).to_a[1] or test_name
34
+ end
35
+
36
+ def failure_message
37
+ return 'Test failed' if @details.nil?
38
+ message = @details["message"]
39
+ if data = @details["data"]
40
+ message += "\nGot: #{data["got"].inspect}"
41
+ message += "\nExpected: #{data["expected"].inspect}"
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,32 @@
1
+ require 'test/tap/test_case'
2
+
3
+ module Test
4
+ module TAP
5
+ module TestSuite
6
+
7
+ def run(result, &progress_block)
8
+ yield(Test::Unit::TestSuite::STARTED, '')
9
+ phpunit = IO.popen shell_cmd
10
+ while line = phpunit.gets
11
+ if line =~ /\ATAP version \d+\Z/ || line =~ /\A1..\d+\Z/
12
+ next
13
+ elsif line =~ /\A\s*---\Z/
14
+ yaml_content = line
15
+ yaml_content += line until (line=phpunit.gets) =~ /\A\s*\.\.\.\Z/
16
+ @current_case.parse_details yaml_content
17
+ else
18
+ @current_case.run(result, &progress_block) if @current_case.present?
19
+ @current_case = TestCase.new(line)
20
+ end
21
+ end
22
+ @current_case.run(result, &progress_block)
23
+ yield(Test::Unit::TestSuite::FINISHED, '')
24
+ end
25
+
26
+ def size
27
+ # We can't give an accurate count without running phpunit, so punt
28
+ 1
29
+ end
30
+ end
31
+ end
32
+ end
data/tap_out.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "tap_out/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "tap_out"
7
+ s.version = TapOut::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Ian Young"]
10
+ s.email = ["ian.greenleaf@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{TAP harness for Test::Unit}
13
+ s.description = %q{Use Test::Unit to run anything that uses the Test Anything Protocol.}
14
+
15
+ s.rubyforge_project = "tap_out"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tap_out
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Ian Young
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-10-04 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Use Test::Unit to run anything that uses the Test Anything Protocol.
23
+ email:
24
+ - ian.greenleaf@gmail.com
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - Gemfile
33
+ - Rakefile
34
+ - lib/tap_out/version.rb
35
+ - lib/test/phpunit.rb
36
+ - lib/test/tap/test_case.rb
37
+ - lib/test/tap/test_suite.rb
38
+ - tap_out.gemspec
39
+ has_rdoc: true
40
+ homepage: ""
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project: tap_out
69
+ rubygems_version: 1.6.2
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: TAP harness for Test::Unit
73
+ test_files: []
74
+