Class: Xcode::Test::Parsers::OCUnitParser

Inherits:
Object
  • Object
show all
Defined in:
lib/xcode/test/parsers/ocunit_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(report = Xcode::Test::Report.new) {|_self| ... } ⇒ OCUnitParser

Returns a new instance of OCUnitParser.

Yields:

  • (_self)

Yield Parameters:



11
12
13
14
# File 'lib/xcode/test/parsers/ocunit_parser.rb', line 11

def initialize(report = Xcode::Test::Report.new)
  @report = report          
  yield self if block_given?
end

Instance Attribute Details

#builderObject

Returns the value of attribute builder.



9
10
11
# File 'lib/xcode/test/parsers/ocunit_parser.rb', line 9

def builder
  @builder
end

#reportObject

Returns the value of attribute report.



9
10
11
# File 'lib/xcode/test/parsers/ocunit_parser.rb', line 9

def report
  @report
end

Instance Method Details

#<<(piped_row) ⇒ Object



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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/xcode/test/parsers/ocunit_parser.rb', line 20

def << piped_row
  case piped_row.force_encoding("UTF-8")
    
    when /Test Suite '(\S+)'.*started at\s+(.*)/
      name = $1
      time = Time.parse($2)
      if name=~/\//
        @report.start
      else
        @report.add_suite name, time
      end
    
    when /Test Suite '(\S+)'.*finished at\s+(.*)./
      time = Time.parse($2)
      name = $1
      if name=~/\//
        @report.finish
      else
        @report.in_current_suite do |suite|
          suite.finish(time)
        end
      end

    when /Test Case '-\[\S+\s+(\S+)\]' started./
      name = $1
      @report.in_current_suite do |suite|
        suite.add_test_case name
      end

    when /Test Case '-\[\S+\s+(\S+)\]' passed \((.*) seconds\)/
      duration = $2.to_f
      @report.in_current_test do |test|
        test.passed(duration)
      end

    when /(.*): error: -\[(\S+) (\S+)\] : (.*)/
      message = $4
      location = $1
      @report.in_current_test do |test|
        test.add_error(message, location)
      end
    
    when /Test Case '-\[\S+ (\S+)\]' failed \((\S+) seconds\)/
      duration = $2.to_f
      @report.in_current_test do |test|
        test.failed(duration)
      end
    
    # when /failed with exit code (\d+)/, 
    when /BUILD FAILED/
      @report.finish
    
    when /Segmentation fault/
      @report.abort
    
    when /Run test case (\w+)/
      # ignore
    when /Run test suite (\w+)/
      # ignore
    when /Executed (\d+) test, with (\d+) failures \((\d+) unexpected\) in (\S+) \((\S+)\) seconds/
      # ignore
    when /the iPhoneSimulator platform does not currently support application-hosted tests/
      raise "Application tests are not currently supported by the iphone simulator.  If these are logic tests, try unsetting TEST_HOST in your project config"
    else
      @report.in_current_test do |test|
        test << piped_row
      end
  end # case

end

#closeObject



16
17
18
# File 'lib/xcode/test/parsers/ocunit_parser.rb', line 16

def close
  @report.finish
end