xcpretty 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7cd373202b87a02b86dcb442fc772f3b8a2aeec7
4
- data.tar.gz: 8e5c493eaedb98e1814aec0a3e7e93315a5ece76
3
+ metadata.gz: 50b91a1ee68864cc0c7f42210ff068b9f0ac4fbd
4
+ data.tar.gz: 183872807da2eafa43b7e938d3d00c99d9a7575d
5
5
  SHA512:
6
- metadata.gz: 030ef974bc44f69886e39c4579e712183fa0aa44e7910577479779d945af76d1ac3606996b1d29fbe591dc21f362f37154c81f9953e443b7bfc8d6b2e79dc73c
7
- data.tar.gz: ea349222ec2cc5c1b661168be29aeb2977973399088930b820c7a83d7daa333009c94d5437718f2116f4a09636a8c3ba41a398dbe02f0ce79c93d59107919886
6
+ metadata.gz: 9a81e3342d8eae995237e34a33849e35d894da2cd8853a4e87f63f7f7e40417062f2a5ef4b3dccce30425a445769a39b6e92bbfae5e13feb199dac555f59a979
7
+ data.tar.gz: 8aa6375079a878afe70a2532f40b441ff70836eea40afaca914f9c7620cb7bc9067b924052b01b9c0cf955e9a0e5e662f50feae5423d8f1d5a65aaf54de9f18e
data/CHANGELOG.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ###### Bug Fixes
6
6
 
7
- * --no-utf was set uncorrectly. now it works
7
+ * `--no-utf` was set incorrectly. now it works as expected.
8
8
 
9
9
 
10
10
  ## 0.0.4
@@ -20,7 +20,7 @@
20
20
 
21
21
  * Added example of running tests continuously
22
22
 
23
- * Support for not using Unicode (--no-utf)
23
+ * Support for not using Unicode (`--no-utf`)
24
24
 
25
25
  ###### Bug Fixes
26
26
 
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,60 @@
1
+ ## Pull requests
2
+
3
+ XCPretty is tested with [Cucumber](http://cukes.info) and [RSpec](http://rspec.info).
4
+ If you're planning to contribute, please do write tests.
5
+
6
+ Here's an example workflow for a contribution:
7
+
8
+ #### 1. Write a failing feature
9
+
10
+ - These are a full-stack end to end tests
11
+ - You can find features in `features/`. You'll need to write a `feature` and implement it's `steps`.
12
+ - Try to reuse as many matchers as possible
13
+ - This tests are slower because they're executing `xcpretty` command for each test
14
+
15
+ Here's an example feature for adding output without UTF8:
16
+
17
+ ``` gherkin
18
+ Scenario: Running tests without UTF-8 support
19
+ Given I have a passing test in my suite
20
+ And I pipe to xcpretty with "--no-utf"
21
+ Then I should see a non-utf prefixed output
22
+ ```
23
+
24
+ And the steps:
25
+
26
+ - `Given I have a passing test in my suite`
27
+
28
+ ``` ruby
29
+ Given(/^I have a passing test in my suite$/) do
30
+ add_run_input SAMPLE_OCUNIT_TEST
31
+ end
32
+ ```
33
+
34
+ - `And I pipe to xcpretty with "--no-utf"`
35
+
36
+ ``` ruby
37
+ When(/^I pipe to xcpretty with "(.*?)"$/) do |flags|
38
+ run_xcpretty(flags)
39
+ end
40
+ ```
41
+
42
+ - `Then I should see a non-utf prefixed output`
43
+
44
+ ``` ruby
45
+ Then(/^I should see a non-utf prefixed output$/) do
46
+ run_output.should start_with(".")
47
+ end
48
+ ```
49
+
50
+
51
+ #### 2. Write a failing BDD test
52
+
53
+ - These are unit tests, and they're very fast (below 200ms for the entire suite)
54
+ - You should be running them continuously with `kicker`, or your awesome Vim binding
55
+
56
+
57
+ #### 3. Implement your awesome contribution
58
+
59
+ - This should fix unit tests one-by-one, and finally your `feature` will be passing
60
+
data/README.md CHANGED
@@ -17,15 +17,19 @@ It's even a bit faster than `xcodebuild` only, since it saves your terminal some
17
17
 
18
18
  ## Formats
19
19
 
20
- - --color, -c (you can add it to any format)
21
- - --simple, -s (default)
20
+ - `--color`, `-c` (you can add it to any format)
21
+ - `--simple`, `-s` (default)
22
22
  ![xcpretty --simple](http://i.imgur.com/LdmozBS.gif)
23
23
 
24
- - --test, -t (RSpec style)
24
+ - `--test`, `-t` (RSpec style)
25
25
  ![xcpretty alpha](http://i.imgur.com/VeTQQub.gif)
26
26
 
27
27
  - tun / tap (not yet implemented. possible solution for most CI servers)
28
28
 
29
+ ## Reporters
30
+
31
+ - `--report junit`, `-r junit`: Creates a JUnit-style XML report at `build/reports/junit.xml`, compatible with Jenkins CI.
32
+
29
33
  ## Have you just cloned xctool?
30
34
 
31
35
  Unlike [xctool](https://github.com/facebook/xctool), `xcpretty` isn't a build tool.
data/bin/xcpretty CHANGED
@@ -7,7 +7,12 @@ if RUBY_VERSION < '1.8.7'
7
7
  abort "error: XCPretty requires Ruby 1.8.7 or higher."
8
8
  end
9
9
 
10
+ report_formats = {
11
+ "junit" => XCPretty::JUnit
12
+ }
13
+
10
14
  OptionParser.new do |opts|
15
+ @report_formats = []
11
16
  opts.banner = "Usage: xcodebuild [options] | xcpretty"
12
17
  opts.on('-t', '--test', 'Use RSpec style output') do
13
18
  @klass = XCPretty::Printer::RSpec
@@ -21,6 +26,10 @@ OptionParser.new do |opts|
21
26
  opts.on('--no-utf', 'Disable unicode characters in output') do
22
27
  @no_utf = true
23
28
  end
29
+ opts.on("-r", "--report FORMAT", "Run FORMAT reporter",
30
+ " Choices: #{report_formats.keys.join(', ')}") do |format|
31
+ @report_formats << report_formats[format]
32
+ end
24
33
  opts.on_tail('-h', '--help', 'Show this message') { puts opts; exit }
25
34
  opts.on_tail("-v", "--version", "Show version") { puts XCPretty::VERSION; exit }
26
35
  opts.parse!
@@ -30,6 +39,11 @@ printer = (@klass || XCPretty::Printer::Simple).new
30
39
  printer.colorize = @colorize
31
40
  printer.use_unicode = !@no_utf
32
41
 
42
+ reporters = @report_formats.compact.map(&:new)
43
+
33
44
  ARGF.each_line do |line|
34
45
  printer.pretty_print(line)
46
+ reporters.each {|r| r.handle(line) }
35
47
  end
48
+
49
+ reporters.each(&:finish)
@@ -0,0 +1,24 @@
1
+ Feature: Creating a JUnit test report
2
+
3
+ Background:
4
+ Given the tests have started running
5
+
6
+ Scenario: Showing a test suite
7
+ When I pipe to xcpretty with "--report junit"
8
+ Then I should see a test suite node
9
+
10
+ Scenario: Showing failed tests
11
+ Given I have a failing test in my suite
12
+ When I pipe to xcpretty with "--report junit"
13
+ Then I should see a failed test node in my report
14
+
15
+ Scenario: Showing passing tests
16
+ Given I have a passing test in my suite
17
+ When I pipe to xcpretty with "--report junit"
18
+ Then I should see a passing test node in my report
19
+
20
+ Scenario: Counting tests
21
+ Given I have a passing test in my suite
22
+ And I have a failing test in my suite
23
+ When I pipe to xcpretty with "--report junit"
24
+ Then I should see 2 tests in my report
@@ -0,0 +1,21 @@
1
+ Then(/^I should see a failed test node in my report$/) do
2
+ junit_report.root.elements.to_a.detect do |node|
3
+ element = node.elements.to_a.first
4
+ element && element.name == "failure"
5
+ end.should_not be_nil
6
+ end
7
+
8
+ Then(/^I should see a passing test node in my report$/) do
9
+ junit_report.root.elements.to_a.detect do |node|
10
+ node.attributes["time"] != nil
11
+ end.should_not be_nil
12
+ end
13
+
14
+ Then(/^I should see a test suite node$/) do
15
+ junit_report.root.should_not be_nil
16
+ end
17
+
18
+ Then(/^I should see (\d+) tests in my report$/) do |test_count|
19
+ junit_report.root.attributes["tests"].should == test_count
20
+ junit_report.root.elements.to_a.count.should == test_count.to_i
21
+ end
@@ -4,6 +4,9 @@ require "tempfile"
4
4
  require "spec/fixtures/constants"
5
5
  require "spec/support/matchers/colors"
6
6
  require "lib/xcpretty/ansi"
7
+ require "rexml/document"
8
+ require "lib/xcpretty/printer"
9
+ require "lib/xcpretty/reporters/junit"
7
10
 
8
11
  include XCPretty::ANSI
9
12
 
@@ -37,6 +40,10 @@ def run_output
37
40
  @output ||= ""
38
41
  end
39
42
 
43
+ def junit_report
44
+ REXML::Document.new(File.open(XCPretty::JUnit::FILEPATH, 'r').read)
45
+ end
46
+
40
47
  Before do
41
48
  self.colorize = true
42
49
  end
@@ -44,4 +51,5 @@ end
44
51
  After do
45
52
  @input = ""
46
53
  @output = ""
54
+ FileUtils.rm_rf(XCPretty::JUnit::FILEPATH)
47
55
  end
@@ -16,9 +16,10 @@ module XCPretty
16
16
  TESTS_RUN_COMPLETION_MATCHER = /Test Suite '(?:.*\/)?(.*[ox]ctest.*)' finished at(.*)/
17
17
 
18
18
  # @regex Captured groups
19
- # $1 = test_case
20
- # $2 = time
21
- PASSING_TEST_MATCHER = /Test Case\s'-\[.*\s(.*)\]'\spassed\s\((\d*\.\d{3})\sseconds\)/
19
+ # $1 = class
20
+ # $2 = test_case
21
+ # $3 = time
22
+ PASSING_TEST_MATCHER = /Test Case\s'-\[(.*)\s(.*)\]'\spassed\s\((\d*\.\d{3})\sseconds\)/
22
23
 
23
24
  # @regex Captured groups
24
25
  # $1 = file
@@ -44,7 +44,7 @@ module XCPretty
44
44
  when /^Ld/
45
45
  print_linking(text)
46
46
  when PASSING_TEST_MATCHER
47
- print_passing_test($1, $2)
47
+ print_passing_test($2, $3)
48
48
  when FAILING_TEST_MATCHER
49
49
  print_failing_test($3, $4)
50
50
  when TESTS_RUN_START_MATCHER
@@ -0,0 +1,79 @@
1
+
2
+ module XCPretty
3
+ class JUnit
4
+ include Printer::Matchers
5
+
6
+ FILEPATH = 'build/reports/junit.xml'
7
+
8
+ def load_dependencies
9
+ unless @@loaded ||= false
10
+ require 'fileutils'
11
+ require 'rexml/document'
12
+ require 'rexml/formatters/pretty'
13
+ @@loaded = true
14
+ end
15
+ end
16
+
17
+ def initialize
18
+ load_dependencies
19
+ @document = REXML::Document.new
20
+ end
21
+
22
+ def handle(line)
23
+ case line
24
+ when TESTS_RUN_START_MATCHER
25
+ create_test_suite($1)
26
+ when TESTS_RUN_COMPLETION_MATCHER
27
+ finish_test_suite
28
+ when PASSING_TEST_MATCHER
29
+ create_passing_test_case($1, $2, $3)
30
+ when FAILING_TEST_MATCHER
31
+ create_failing_test_case($1, $2, $3, $4)
32
+ end
33
+ end
34
+
35
+ def finish
36
+ FileUtils.mkdir_p(File.dirname(FILEPATH))
37
+ formatter = REXML::Formatters::Pretty.new(2)
38
+ formatter.compact = true
39
+ formatter.write(@document, File.open(FILEPATH,'w+'))
40
+ end
41
+
42
+ def create_test_suite(name)
43
+ @test_count = 0
44
+ @fail_count = 0
45
+ suite = @document.add_element('testsuite')
46
+ suite.attributes['name'] = $1
47
+ end
48
+
49
+ def finish_test_suite
50
+ current_suite.attributes['tests'] = @test_count
51
+ current_suite.attributes['failures'] = @fail_count
52
+ @test_count = 0
53
+ @fail_count = 0
54
+ end
55
+
56
+ def current_suite
57
+ @document.elements.to_a.last
58
+ end
59
+
60
+ def create_failing_test_case(file, classname, name, reason)
61
+ test_node = current_suite.add_element('testcase')
62
+ test_node.attributes['classname'] = classname
63
+ test_node.attributes['name'] = name
64
+ fail_node = test_node.add_element('failure')
65
+ fail_node.attributes['message'] = reason
66
+ fail_node.text = file
67
+ @test_count+=1
68
+ @fail_count+=1
69
+ end
70
+
71
+ def create_passing_test_case(classname, name, time)
72
+ test_node = current_suite.add_element('testcase')
73
+ test_node.attributes['classname'] = classname
74
+ test_node.attributes['name'] = name
75
+ test_node.attributes['time'] = time
76
+ @test_count+=1
77
+ end
78
+ end
79
+ end
@@ -1,3 +1,3 @@
1
1
  module XCPretty
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/xcpretty.rb CHANGED
@@ -2,6 +2,7 @@ require "xcpretty/version"
2
2
  require "xcpretty/printer"
3
3
  require "xcpretty/printers/simple"
4
4
  require "xcpretty/printers/rspec"
5
+ require "xcpretty/reporters/junit"
5
6
 
6
7
  module XCPretty
7
8
  # Your code goes here...
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcpretty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marin Usalj
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-11 00:00:00.000000000 Z
12
+ date: 2013-12-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -82,13 +82,16 @@ files:
82
82
  - .kick
83
83
  - .travis.yml
84
84
  - CHANGELOG.md
85
+ - CONTRIBUTING.md
85
86
  - Gemfile
86
87
  - LICENSE.txt
87
88
  - README.md
88
89
  - Rakefile
89
90
  - bin/xcpretty
91
+ - features/junit_report.feature
90
92
  - features/simple_format.feature
91
93
  - features/steps/formatting_steps.rb
94
+ - features/steps/junit_steps.rb
92
95
  - features/support/env.rb
93
96
  - features/test_format.feature
94
97
  - lib/xcpretty.rb
@@ -96,6 +99,7 @@ files:
96
99
  - lib/xcpretty/printer.rb
97
100
  - lib/xcpretty/printers/rspec.rb
98
101
  - lib/xcpretty/printers/simple.rb
102
+ - lib/xcpretty/reporters/junit.rb
99
103
  - lib/xcpretty/version.rb
100
104
  - spec/fixtures/constants.rb
101
105
  - spec/fixtures/raw_kiwi_compilation_fail.txt
@@ -134,8 +138,10 @@ signing_key:
134
138
  specification_version: 4
135
139
  summary: xcodebuild formatter done right
136
140
  test_files:
141
+ - features/junit_report.feature
137
142
  - features/simple_format.feature
138
143
  - features/steps/formatting_steps.rb
144
+ - features/steps/junit_steps.rb
139
145
  - features/support/env.rb
140
146
  - features/test_format.feature
141
147
  - spec/fixtures/constants.rb
@@ -149,4 +155,3 @@ test_files:
149
155
  - spec/xcpretty/printers/printer_spec.rb
150
156
  - spec/xcpretty/printers/rspec_spec.rb
151
157
  - spec/xcpretty/printers/simple_spec.rb
152
- has_rdoc: