xcpretty 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -2
- data/bin/xcpretty +20 -30
- data/features/junit_report.feature +7 -0
- data/features/simple_format.feature +35 -0
- data/features/steps/formatting_steps.rb +47 -0
- data/features/steps/junit_steps.rb +22 -0
- data/features/support/env.rb +17 -0
- data/features/test_format.feature +11 -1
- data/lib/xcpretty/formatters/formatter.rb +3 -0
- data/lib/xcpretty/formatters/rspec.rb +5 -0
- data/lib/xcpretty/formatters/simple.rb +30 -4
- data/lib/xcpretty/parser.rb +20 -0
- data/lib/xcpretty/reporters/junit.rb +4 -3
- data/lib/xcpretty/version.rb +1 -1
- data/lib/xcpretty.rb +23 -1
- data/spec/fixtures/constants.rb +13 -0
- data/spec/xcpretty/formatters/rspec_spec.rb +10 -1
- data/spec/xcpretty/formatters/simple_spec.rb +15 -0
- data/spec/xcpretty/parser_spec.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b2c23619219f7da6d12fbe9603ba2deece7157d
|
4
|
+
data.tar.gz: de800a6d3e0ca7806915e708e7b1483a708c0140
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eac17f808e34f54236c1b003ea467e6575fdd8b16a5dddf8e3a2baa98ce8fa5ec57b0a0ef2af1236f226c8c49ab788ad4f0a0cd688d2ed1ecec70a902874f49
|
7
|
+
data.tar.gz: 281d4d622def4747891d9e30878111e15ea8ca8d81de96fb3d69a0069c79f0242bfa3a6bd8623b195597696108ca424c894da59f135071e676b58974dd634bc2
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,29 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.1.0
|
4
|
+
|
5
|
+
###### Enhancements
|
6
|
+
|
7
|
+
* Color semi-slow tests in yellow, slow tests in red |
|
8
|
+
[#46](https://github.com/mneorr/xcpretty/pull/46)
|
9
|
+
* Add option to specify a custom location for report generation |
|
10
|
+
[#43](https://github.com/mneorr/XCPretty/pull/43)
|
11
|
+
|
12
|
+
|
13
|
+
## 0.0.9
|
14
|
+
|
15
|
+
###### Enhancements
|
16
|
+
|
17
|
+
* major performance fix, it's faster than `cat` by 2-3 times on big inputs.
|
18
|
+
Thanks [@kviksilver](https://github.com/kviksilver) for providing debug log and helping to reproduce
|
19
|
+
|
20
|
+
|
3
21
|
## 0.0.8
|
4
22
|
|
5
23
|
###### Bug Fixes
|
6
24
|
|
7
|
-
* show version if not piped
|
25
|
+
* show version if not piped |
|
26
|
+
[#39](https://github.com/mneorr/XCPretty/issues/39)
|
8
27
|
|
9
28
|
###### Enhancements
|
10
29
|
|
@@ -45,7 +64,7 @@
|
|
45
64
|
|
46
65
|
###### Enhancements
|
47
66
|
|
48
|
-
* Prettier `--simple` output
|
67
|
+
* Prettier `--simple` output |
|
49
68
|
[Preview](https://travis-ci.org/allending/Kiwi/builds/15190533)
|
50
69
|
* Removed Paint dependency
|
51
70
|
* Better test failure formatting (added indentation, grouped by suite)
|
data/bin/xcpretty
CHANGED
@@ -10,68 +10,57 @@ end
|
|
10
10
|
require 'xcpretty'
|
11
11
|
require 'optparse'
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
klass = eval(source, nil, path)
|
16
|
-
raise unless klass.is_a?(Class)
|
17
|
-
klass
|
18
|
-
end
|
19
|
-
|
20
|
-
def load_custom_formatter(path)
|
21
|
-
begin
|
22
|
-
$:.unshift File.dirname(path)
|
23
|
-
class_from_path(path)
|
24
|
-
rescue SyntaxError => e
|
25
|
-
$stderr.puts "[!] Expected formatter source file to return a class. #{e}"
|
26
|
-
exit 1
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
13
|
+
report_options = []
|
14
|
+
report_classes = []
|
30
15
|
report_formats = {
|
31
16
|
"junit" => XCPretty::JUnit
|
32
17
|
}
|
33
18
|
|
34
|
-
|
19
|
+
printer_opts = {
|
35
20
|
:unicode => true,
|
36
21
|
:colorize => false,
|
37
22
|
:formatter => XCPretty::Simple
|
38
23
|
}
|
39
24
|
|
40
|
-
reporter_classes = []
|
41
|
-
|
42
25
|
OptionParser.new do |opts|
|
43
26
|
opts.banner = "Usage: xcodebuild [options] | xcpretty"
|
44
27
|
opts.on('-t', '--test', 'Use RSpec style output') do
|
45
|
-
|
28
|
+
printer_opts[:formatter] = XCPretty::RSpec
|
46
29
|
end
|
47
30
|
opts.on('-s', '--simple', 'Use simple output (default)') do
|
48
|
-
|
31
|
+
printer_opts[:formatter] = XCPretty::Simple
|
49
32
|
end
|
50
33
|
opts.on('-f', '--formatter PATH', 'Use formatter returned from evaluating the specified Ruby file') do |path|
|
51
|
-
|
34
|
+
printer_opts[:formatter] = XCPretty.load_custom_formatter(path)
|
52
35
|
end
|
53
36
|
opts.on('-c', '--color', 'Use colorized output') do
|
54
|
-
|
37
|
+
printer_opts[:colorize] = true
|
55
38
|
end
|
56
39
|
opts.on('--no-utf', 'Disable unicode characters in output') do
|
57
|
-
|
40
|
+
printer_opts[:unicode] = false
|
58
41
|
end
|
59
42
|
opts.on("-r", "--report FORMAT", "Run FORMAT reporter",
|
60
43
|
" Choices: #{report_formats.keys.join(', ')}") do |format|
|
61
|
-
|
44
|
+
report_classes << report_formats[format]
|
45
|
+
report_options << {}
|
46
|
+
end
|
47
|
+
opts.on('-o', '--output PATH', 'Write report output to PATH') do |path|
|
48
|
+
unless opts = report_options.last
|
49
|
+
XCPretty.exit_with_error('Expected report format to be speficied before before output path')
|
50
|
+
end
|
51
|
+
opts[:path] = path
|
62
52
|
end
|
63
53
|
opts.on_tail('-h', '--help', 'Show this message') { puts opts; exit }
|
64
54
|
opts.on_tail("-v", "--version", "Show version") { puts XCPretty::VERSION; exit }
|
65
55
|
opts.parse!
|
66
56
|
|
67
57
|
if STDIN.tty?
|
68
|
-
|
69
|
-
exit 1
|
58
|
+
XCPretty.exit_with_error(opts.help)
|
70
59
|
end
|
71
60
|
end
|
72
61
|
|
73
|
-
printer = XCPretty::Printer.new(
|
74
|
-
reporters =
|
62
|
+
printer = XCPretty::Printer.new(printer_opts)
|
63
|
+
reporters = report_classes.compact.each_with_index.map {|k,i| k.new(report_options[i])}
|
75
64
|
|
76
65
|
ARGF.each_line do |line|
|
77
66
|
XCPretty::ExitStatus.handle(line)
|
@@ -81,3 +70,4 @@ end
|
|
81
70
|
|
82
71
|
reporters.each(&:finish)
|
83
72
|
exit(XCPretty::ExitStatus.code)
|
73
|
+
|
@@ -30,3 +30,10 @@ Feature: Creating a JUnit test report
|
|
30
30
|
When I pipe to xcpretty with "--report junit"
|
31
31
|
Then I should see 2 test suites
|
32
32
|
|
33
|
+
Scenario: Writing to a custom file path
|
34
|
+
When I pipe to xcpretty with "--report junit" and specify a custom path
|
35
|
+
Then I should have a test report in a custom path
|
36
|
+
|
37
|
+
Scenario: Writing to multiple custom file paths
|
38
|
+
When I pipe to xcpretty with two custom report paths
|
39
|
+
Then I should have test reports in two custom paths
|
@@ -40,6 +40,16 @@ Feature: Showing build output in simple format
|
|
40
40
|
When I pipe to xcpretty with "--simple"
|
41
41
|
Then I should see a successful analyze message
|
42
42
|
|
43
|
+
Scenario: Showing tiff file validation
|
44
|
+
Given I have a tiff file to validate
|
45
|
+
When I pipe to xcpretty with "--simple"
|
46
|
+
Then I should see a successful tiff validation message
|
47
|
+
|
48
|
+
Scenario: Showing touch file
|
49
|
+
Given I have a file to touch
|
50
|
+
When I pipe to xcpretty with "--simple"
|
51
|
+
Then I should see a successful touch message
|
52
|
+
|
43
53
|
Scenario: Showing analyze with color
|
44
54
|
Given I have a file to analyze
|
45
55
|
When I pipe to xcpretty with "--simple --color"
|
@@ -50,6 +60,16 @@ Feature: Showing build output in simple format
|
|
50
60
|
When I pipe to xcpretty with "--simple --color"
|
51
61
|
Then I should see a yellow completion icon
|
52
62
|
|
63
|
+
Scenario: Showing tiff file validation with color
|
64
|
+
Given I have a tiff file to validate
|
65
|
+
When I pipe to xcpretty with "--simple --color"
|
66
|
+
Then I should see a yellow completion icon
|
67
|
+
|
68
|
+
Scenario: Showing touch file with color
|
69
|
+
Given I have a file to touch
|
70
|
+
When I pipe to xcpretty with "--simple --color"
|
71
|
+
Then I should see a yellow completion icon
|
72
|
+
|
53
73
|
Scenario: Showing the start of a test run
|
54
74
|
Given the tests have started running
|
55
75
|
When I pipe to xcpretty with "--simple"
|
@@ -79,6 +99,21 @@ Feature: Showing build output in simple format
|
|
79
99
|
And I should not see the name of the test group
|
80
100
|
And I should not see the path of a passing test
|
81
101
|
|
102
|
+
Scenario: Colorizing slow-ish tests in yellow
|
103
|
+
Given I have a slow-ish test in my suite
|
104
|
+
When I pipe to xcpretty with "--simple --color"
|
105
|
+
Then I should see the test time in yellow
|
106
|
+
|
107
|
+
Scenario: Colorizing slow tests in red
|
108
|
+
Given I have a slow test in my suite
|
109
|
+
When I pipe to xcpretty with "--simple --color"
|
110
|
+
Then I should see the test time in red
|
111
|
+
|
112
|
+
Scenario: Showing pending test output
|
113
|
+
Given I have a pending test in my suite
|
114
|
+
When I pipe to xcpretty with "--simple"
|
115
|
+
Then I should see the name of a pending test
|
116
|
+
|
82
117
|
Scenario: Showing failed test output with color
|
83
118
|
Given I have a failing test in my suite
|
84
119
|
And the test suite has finished
|
@@ -31,6 +31,14 @@ Given(/^I have a passing test in my suite$/) do
|
|
31
31
|
add_run_input SAMPLE_OCUNIT_TEST
|
32
32
|
end
|
33
33
|
|
34
|
+
Given(/^I have a slow\-ish test in my suite$/) do
|
35
|
+
add_run_input SAMPLE_SLOWISH_TEST
|
36
|
+
end
|
37
|
+
|
38
|
+
Given(/^I have a slow test in my suite$/) do
|
39
|
+
add_run_input SAMPLE_SLOW_TEST
|
40
|
+
end
|
41
|
+
|
34
42
|
Given(/^the tests have started running$/) do
|
35
43
|
add_run_input SAMPLE_OCUNIT_TEST_RUN_BEGINNING
|
36
44
|
end
|
@@ -72,6 +80,26 @@ Given(/^the linker has failed with undefined symbols$/) do
|
|
72
80
|
add_run_input SAMPLE_UNDEFINED_SYMBOLS
|
73
81
|
end
|
74
82
|
|
83
|
+
Given(/^I have a pending test in my suite$/) do
|
84
|
+
add_run_input SAMPLE_PENDING_KIWI_TEST
|
85
|
+
end
|
86
|
+
|
87
|
+
Given(/^I have a tiff file to validate$/) do
|
88
|
+
add_run_input SAMPLE_TIFFUTIL
|
89
|
+
end
|
90
|
+
|
91
|
+
Given(/^I have a file to touch$/) do
|
92
|
+
add_run_input SAMPLE_TOUCH
|
93
|
+
end
|
94
|
+
|
95
|
+
Then(/^I should see a successful tiff validation message$/) do
|
96
|
+
run_output.should start_with("▸ Validating")
|
97
|
+
end
|
98
|
+
|
99
|
+
Then(/^I should see a successful touch message$/) do
|
100
|
+
run_output.should start_with("▸ Touching")
|
101
|
+
end
|
102
|
+
|
75
103
|
When(/^I pipe to xcpretty with "(.*?)"$/) do |flags|
|
76
104
|
run_xcpretty(flags)
|
77
105
|
end
|
@@ -129,6 +157,14 @@ Then(/^I should see a red failed test icon$/) do
|
|
129
157
|
run_output.should include(red("F"))
|
130
158
|
end
|
131
159
|
|
160
|
+
Then(/^I should see a pending test icon in ASCII$/) do
|
161
|
+
run_output.should start_with("P")
|
162
|
+
end
|
163
|
+
|
164
|
+
Then(/^I should see a yellow pending test icon$/) do
|
165
|
+
run_output.should start_with(yellow("P"))
|
166
|
+
end
|
167
|
+
|
132
168
|
Then(/^the final execution message should be (red|green)$/) do |color|
|
133
169
|
last_line = run_output.lines.to_a.last
|
134
170
|
last_line.should be_colored(color.to_sym)
|
@@ -207,3 +243,14 @@ Then(/^I should see the symbol and reference that caused failure$/) do
|
|
207
243
|
run_output.should include("objc-class-ref in ATZRadialProgressControl.o")
|
208
244
|
end
|
209
245
|
|
246
|
+
Then(/^I should see the name of a pending test$/) do
|
247
|
+
run_output.should =~ PENDING_TEST_NAME_MATCHER
|
248
|
+
end
|
249
|
+
|
250
|
+
Then(/^I should see the test time in yellow$/) do
|
251
|
+
run_output.should include("#{yellow("0.026")}")
|
252
|
+
end
|
253
|
+
|
254
|
+
Then(/^I should see the test time in red$/) do
|
255
|
+
run_output.should include("#{red("0.101")}") end
|
256
|
+
|
@@ -3,6 +3,28 @@ Given(/^I have tests in my suite from 2 classes$/) do
|
|
3
3
|
add_run_input SAMPLE_KIWI_TEST
|
4
4
|
end
|
5
5
|
|
6
|
+
When(/^I pipe to xcpretty with "(.*?)" and specify a custom path$/) do |args|
|
7
|
+
step("I pipe to xcpretty with \"#{args} --output #{custom_report_path}\"")
|
8
|
+
end
|
9
|
+
|
10
|
+
When(/^I pipe to xcpretty with two custom report paths$/) do
|
11
|
+
step("I pipe to xcpretty with \"--report junit --output #{custom_report_path} --report junit --output #{other_custom_report_path}\"")
|
12
|
+
end
|
13
|
+
|
14
|
+
Then(/^I should have test reports in two custom paths$/) do
|
15
|
+
step("I should have a test report at \"#{custom_report_path}\"")
|
16
|
+
step("I should have a test report at \"#{other_custom_report_path}\"")
|
17
|
+
end
|
18
|
+
|
19
|
+
Then(/^I should have a test report in a custom path$/) do
|
20
|
+
step("I should have a test report at \"#{custom_report_path}\"")
|
21
|
+
end
|
22
|
+
|
23
|
+
Then(/^I should have a test report at "(.*?)"$/) do |path|
|
24
|
+
doc = REXML::Document.new(File.open(path, 'r').read)
|
25
|
+
doc.root.should_not be_nil
|
26
|
+
end
|
27
|
+
|
6
28
|
Then(/^I should see a failed test node in my report$/) do
|
7
29
|
junit_report_root.elements.to_a.detect do |node|
|
8
30
|
element = node.elements.to_a.first
|
data/features/support/env.rb
CHANGED
@@ -17,6 +17,7 @@ TEST_SUITE_COMPLETION_MATCHER = /Executed \d+ tests, with \d+ failures \(\d+ une
|
|
17
17
|
TEST_SUITE_START_MATCHER = /[\w]*(Spec|Tests)$/
|
18
18
|
TEST_PATH_MATCHER = %r{[\w/\-\s]+:\d+}
|
19
19
|
PASSING_TEST_NAME_MATCHER = %r{\w+\s\(\d+\.\d+\sseconds\)}
|
20
|
+
PENDING_TEST_NAME_MATCHER = %r{\w+\s\[PENDING\]}
|
20
21
|
FAILING_TEST_NAME_MATCHER = %r{\w+, expected:}
|
21
22
|
|
22
23
|
def run_xcpretty(flags)
|
@@ -48,6 +49,20 @@ def junit_report_root
|
|
48
49
|
junit_report.root.elements.to_a.first
|
49
50
|
end
|
50
51
|
|
52
|
+
def custom_report_path
|
53
|
+
@custom_report_path ||= begin
|
54
|
+
@custom_report_file1 = Tempfile.new('custom_report_path')
|
55
|
+
@custom_report_file1.path
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def other_custom_report_path
|
60
|
+
@custom_report_path2 ||= begin
|
61
|
+
@custom_report_file2 = Tempfile.new('custom_report_path')
|
62
|
+
@custom_report_file2.path
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
51
66
|
Before do
|
52
67
|
self.colorize = true
|
53
68
|
end
|
@@ -55,5 +70,7 @@ end
|
|
55
70
|
After do
|
56
71
|
@input = ""
|
57
72
|
@output = ""
|
73
|
+
@custom_report_file1.unlink if @custom_report_file1
|
74
|
+
@custom_report_file2.unlink if @custom_report_file2
|
58
75
|
FileUtils.rm_rf(XCPretty::JUnit::FILEPATH)
|
59
76
|
end
|
@@ -10,6 +10,11 @@ Feature: Showing RSpec-style test output
|
|
10
10
|
When I pipe to xcpretty with "--test"
|
11
11
|
Then I should see a passing test icon in ASCII
|
12
12
|
|
13
|
+
Scenario: Showing pending tests
|
14
|
+
Given I have a pending test in my suite
|
15
|
+
When I pipe to xcpretty with "--test"
|
16
|
+
Then I should see a pending test icon in ASCII
|
17
|
+
|
13
18
|
Scenario: Showing some tests failed with color
|
14
19
|
Given I have a failing test in my suite
|
15
20
|
And the test suite has finished
|
@@ -18,11 +23,16 @@ Feature: Showing RSpec-style test output
|
|
18
23
|
And I should see the path of a failed test
|
19
24
|
And the final execution message should be red
|
20
25
|
|
21
|
-
Scenario: Showing passing tests with
|
26
|
+
Scenario: Showing passing tests with color
|
22
27
|
Given I have a passing test in my suite
|
23
28
|
When I pipe to xcpretty with "--test --color"
|
24
29
|
Then I should see a green passing test icon
|
25
30
|
|
31
|
+
Scenario: Showing pending tests with color
|
32
|
+
Given I have a pending test in my suite
|
33
|
+
When I pipe to xcpretty with "--test --color"
|
34
|
+
Then I should see a yellow pending test icon
|
35
|
+
|
26
36
|
Scenario: Showing that all tests passed with color
|
27
37
|
Given all of my tests will pass in my suite
|
28
38
|
When I pipe to xcpretty with "--test --color"
|
@@ -23,6 +23,7 @@ module XCPretty
|
|
23
23
|
def format_linking(file, build_variant, arch); EMPTY; end
|
24
24
|
def format_libtool(library); EMPTY; end
|
25
25
|
def format_passing_test(suite, test, time); EMPTY; end
|
26
|
+
def format_pending_test(suite, test); EMPTY; end
|
26
27
|
def format_failing_test(suite, test, time, file_path); EMPTY; end
|
27
28
|
def format_process_pch(file); EMPTY; end
|
28
29
|
def format_phase_script_execution(script_name); EMPTY; end
|
@@ -34,6 +35,8 @@ module XCPretty
|
|
34
35
|
def format_test_run_finished(name, time); EMPTY; end
|
35
36
|
def format_test_suite_started(name); EMPTY; end
|
36
37
|
def format_test_summary(message, failures_per_suite); EMPTY; end
|
38
|
+
def format_touch(file_path, file_name); EMPTY; end
|
39
|
+
def format_tiffutil(file); EMPTY; end
|
37
40
|
|
38
41
|
# COMPILER / LINKER ERRORS
|
39
42
|
def format_compile_error(file_name, file_path, reason,
|
@@ -7,10 +7,12 @@ module XCPretty
|
|
7
7
|
|
8
8
|
PASS = "✓"
|
9
9
|
FAIL = "✗"
|
10
|
+
PENDING = "⧖"
|
10
11
|
|
11
12
|
ASCII_PASS = "."
|
12
13
|
ASCII_FAIL = "x"
|
13
14
|
COMPLETION = "▸"
|
15
|
+
ASCII_PENDING = "P"
|
14
16
|
ASCII_COMPLETION = ">"
|
15
17
|
|
16
18
|
def format_analyze(file_name, file_path)
|
@@ -54,11 +56,15 @@ module XCPretty
|
|
54
56
|
end
|
55
57
|
|
56
58
|
def format_failing_test(suite, test_case, reason, file)
|
57
|
-
format_test("#{test_case}, #{reason}",
|
59
|
+
format_test("#{test_case}, #{reason}", :fail)
|
58
60
|
end
|
59
61
|
|
60
62
|
def format_passing_test(suite, test_case, time)
|
61
|
-
format_test("#{test_case} (#{time} seconds)")
|
63
|
+
format_test("#{test_case} (#{colored_time(time)} seconds)", :pass)
|
64
|
+
end
|
65
|
+
|
66
|
+
def format_pending_test(suite, test_case)
|
67
|
+
format_test("#{test_case} [PENDING]", :pending)
|
62
68
|
end
|
63
69
|
|
64
70
|
def format_phase_script_execution(script_name)
|
@@ -93,6 +99,13 @@ module XCPretty
|
|
93
99
|
heading("", name, "")
|
94
100
|
end
|
95
101
|
|
102
|
+
def format_touch(file_path, file_name)
|
103
|
+
format("Touching", file_name)
|
104
|
+
end
|
105
|
+
|
106
|
+
def format_tiffutil(file_name)
|
107
|
+
format("Validating", file_name)
|
108
|
+
end
|
96
109
|
|
97
110
|
private
|
98
111
|
|
@@ -104,8 +117,8 @@ module XCPretty
|
|
104
117
|
[status_symbol(success ? :completion : :fail), white(command), argument_text].join(" ").strip
|
105
118
|
end
|
106
119
|
|
107
|
-
def format_test(test_case,
|
108
|
-
[status_symbol(
|
120
|
+
def format_test(test_case, status)
|
121
|
+
[status_symbol(status), test_case].join(" ").strip
|
109
122
|
end
|
110
123
|
|
111
124
|
def status_symbol(status)
|
@@ -114,6 +127,8 @@ module XCPretty
|
|
114
127
|
green(use_unicode? ? PASS : ASCII_PASS)
|
115
128
|
when :fail
|
116
129
|
red(use_unicode? ? FAIL : ASCII_FAIL)
|
130
|
+
when :pending
|
131
|
+
yellow(use_unicode? ? PENDING : ASCII_PENDING)
|
117
132
|
when :error
|
118
133
|
red(use_unicode? ? ERROR : ASCII_ERROR)
|
119
134
|
when :completion
|
@@ -123,5 +138,16 @@ module XCPretty
|
|
123
138
|
end
|
124
139
|
end
|
125
140
|
|
141
|
+
def colored_time(time)
|
142
|
+
case time.to_f
|
143
|
+
when 0..0.025
|
144
|
+
time
|
145
|
+
when 0.026..0.100
|
146
|
+
yellow(time)
|
147
|
+
else
|
148
|
+
red(time)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
126
152
|
end
|
127
153
|
end
|
data/lib/xcpretty/parser.rb
CHANGED
@@ -96,6 +96,11 @@ module XCPretty
|
|
96
96
|
# $3 = time
|
97
97
|
PASSING_TEST_MATCHER = /^Test Case\s'-\[(.*)\s(.*)\]'\spassed\s\((\d*\.\d{3})\sseconds\)/
|
98
98
|
|
99
|
+
# @regex Captured groups
|
100
|
+
# $1 = suite
|
101
|
+
# $2 = test_case
|
102
|
+
PENDING_TEST_MATCHER = /^Test Case\s'-\[(.*)\s(.*)PENDING\]'\spassed/
|
103
|
+
|
99
104
|
# @regex Captured groups
|
100
105
|
# $1 = script_name
|
101
106
|
PHASE_SCRIPT_EXECUTION_MATCHER = /^PhaseScriptExecution\s(.*)\s\//
|
@@ -136,6 +141,15 @@ module XCPretty
|
|
136
141
|
# @regex Captured groups
|
137
142
|
# $1 test suite name
|
138
143
|
TEST_SUITE_START_MATCHER = /Test Suite '(.*)' started at/
|
144
|
+
|
145
|
+
# @regex Captured groups
|
146
|
+
# $1 file_name
|
147
|
+
TIFFUTIL_MATCHER = /^TiffUtil\s(.*)/
|
148
|
+
|
149
|
+
# @regex Captured groups
|
150
|
+
# $1 file_path
|
151
|
+
# $2 file_name
|
152
|
+
TOUCH_MATCHER = /^Touch\s(.*\/([\w+\.]+))/
|
139
153
|
end
|
140
154
|
|
141
155
|
class Parser
|
@@ -184,6 +198,8 @@ module XCPretty
|
|
184
198
|
formatter.format_libtool($1)
|
185
199
|
when LINKING_MATCHER
|
186
200
|
formatter.format_linking($1, $2, $3)
|
201
|
+
when PENDING_TEST_MATCHER
|
202
|
+
formatter.format_pending_test($1, $2)
|
187
203
|
when PASSING_TEST_MATCHER
|
188
204
|
formatter.format_passing_test($1, $2, $3)
|
189
205
|
when PODS_ERROR_MATCHER
|
@@ -208,6 +224,10 @@ module XCPretty
|
|
208
224
|
formatter.format_test_run_started($1)
|
209
225
|
when TEST_SUITE_START_MATCHER
|
210
226
|
formatter.format_test_suite_started($1)
|
227
|
+
when TIFFUTIL_MATCHER
|
228
|
+
formatter.format_tiffutil($1)
|
229
|
+
when TOUCH_MATCHER
|
230
|
+
formatter.format_touch($1, $2)
|
211
231
|
else
|
212
232
|
""
|
213
233
|
end
|
@@ -14,8 +14,9 @@ module XCPretty
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def initialize
|
17
|
+
def initialize(options)
|
18
18
|
load_dependencies
|
19
|
+
@filepath = options[:path] || FILEPATH
|
19
20
|
@directory = `pwd`.strip
|
20
21
|
@document = REXML::Document.new
|
21
22
|
@document << REXML::XMLDecl.new('1.0','UTF-8')
|
@@ -58,10 +59,10 @@ module XCPretty
|
|
58
59
|
private
|
59
60
|
|
60
61
|
def write_report_file
|
61
|
-
FileUtils.mkdir_p(File.dirname(
|
62
|
+
FileUtils.mkdir_p(File.dirname(@filepath))
|
62
63
|
formatter = REXML::Formatters::Pretty.new(2)
|
63
64
|
formatter.compact = true
|
64
|
-
formatter.write(@document, File.open(
|
65
|
+
formatter.write(@document, File.open(@filepath, 'w+'))
|
65
66
|
end
|
66
67
|
|
67
68
|
def suite(classname)
|
data/lib/xcpretty/version.rb
CHANGED
data/lib/xcpretty.rb
CHANGED
@@ -7,7 +7,7 @@ require "xcpretty/formatters/rspec"
|
|
7
7
|
require "xcpretty/reporters/junit"
|
8
8
|
|
9
9
|
module XCPretty
|
10
|
-
|
10
|
+
module ExitStatus
|
11
11
|
|
12
12
|
include XCPretty::Matchers
|
13
13
|
|
@@ -27,5 +27,27 @@ module XCPretty
|
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
30
|
+
|
31
|
+
def self.class_from_path(path)
|
32
|
+
source = File.read(path)
|
33
|
+
klass = eval(source, nil, path)
|
34
|
+
raise unless klass.is_a?(Class)
|
35
|
+
klass
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.load_custom_formatter(path)
|
39
|
+
begin
|
40
|
+
$:.unshift File.dirname(path)
|
41
|
+
class_from_path(path)
|
42
|
+
rescue SyntaxError => e
|
43
|
+
exit_with_error("Expected formatter source file to return a class. #{e}")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.exit_with_error(message)
|
48
|
+
$stderr.puts "[!] #{message}"
|
49
|
+
exit 1
|
50
|
+
end
|
51
|
+
|
30
52
|
end
|
31
53
|
|
data/spec/fixtures/constants.rb
CHANGED
@@ -23,7 +23,10 @@ Clean.Remove clean /Users/musalj/Library/Developer/Xcode/DerivedData/ObjectiveSu
|
|
23
23
|
)
|
24
24
|
SAMPLE_EXECUTED_TESTS = "Executed 4 tests, with 0 failures (0 unexpected) in 0.003 (0.004) seconds"
|
25
25
|
SAMPLE_OCUNIT_TEST = "Test Case '-[RACCommandSpec enabled_signal_should_send_YES_while_executing_is_YES_and_allowsConcurrentExecution_is_YES]' passed (0.001 seconds)."
|
26
|
+
SAMPLE_SLOWISH_TEST = "Test Case '-[RACCommandSpec enabled_signal_should_send_YES_while_executing_is_YES_and_allowsConcurrentExecution_is_YES]' passed (0.026 seconds)."
|
27
|
+
SAMPLE_SLOW_TEST = "Test Case '-[RACCommandSpec enabled_signal_should_send_YES_while_executing_is_YES_and_allowsConcurrentExecution_is_YES]' passed (0.101 seconds)."
|
26
28
|
SAMPLE_KIWI_TEST = "Test Case '-[MappingsTests Mappings_SupportsCreatingAParentObjectUsingJustIDFromTheServer]' passed (0.004 seconds)."
|
29
|
+
SAMPLE_PENDING_KIWI_TEST = "Test Case '-[TAPIConversationSpec TAPIConversation_createConversation_SendsAPOSTRequestToTheConversationsEndpointPENDING]' passed (0.001 seconds)."
|
27
30
|
SAMPLE_COMPILE = %Q(
|
28
31
|
CompileC /Users/musalj/Library/Developer/Xcode/DerivedData/ObjectiveSugar-ayzdhqmmwtqgysdpznmovjlupqjy/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-ObjectiveSugar.build/Objects-normal/i386/NSMutableArray+ObjectiveSugar.o /Users/musalj/code/OSS/ObjectiveSugar/Classes/NSMutableArray+ObjectiveSugar.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
|
29
32
|
cd /Users/musalj/code/OSS/ObjectiveSugar/Example/Pods
|
@@ -82,6 +85,16 @@ GenerateDSYMFile /Users/musalj/Library/Developer/Xcode/DerivedData/ObjectiveSuga
|
|
82
85
|
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/musalj/code/go/bin:/Users/musalj/.rbenv/shims:/Users/musalj/.rbenv/bin:/usr/local/share/npm/bin:/usr/local/bin:/Library/Python/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
|
83
86
|
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil /Users/musalj/Library/Developer/Xcode/DerivedData/ObjectiveSugar-ayzdhqmmwtqgysdpznmovjlupqjy/Build/Products/Debug-iphonesimulator/ObjectiveSugarTests.octest/ObjectiveSugarTests -o /Users/musalj/Library/Developer/Xcode/DerivedData/ObjectiveSugar-ayzdhqmmwtqgysdpznmovjlupqjy/Build/Products/Debug-iphonesimulator/ObjectiveSugarTests.octest.dSYM
|
84
87
|
)
|
88
|
+
SAMPLE_TOUCH = %Q(
|
89
|
+
Touch /Users/musalj/Library/Developer/Xcode/DerivedData/Alcatraz-aobuxcinaqyzjugrnxjjhfzgwaou/Build/Products/Debug/AlcatrazTests.octest
|
90
|
+
cd /Users/musalj/code/OSS/Alcatraz
|
91
|
+
/usr/bin/touch -c /Users/musalj/Library/Developer/Xcode/DerivedData/Alcatraz-aobuxcinaqyzjugrnxjjhfzgwaou/Build/Products/Debug/AlcatrazTests.octest
|
92
|
+
)
|
93
|
+
SAMPLE_TIFFUTIL = %Q(
|
94
|
+
TiffUtil eye_icon.tiff
|
95
|
+
cd /Users/musalj/code/OSS/Alcatraz
|
96
|
+
/usr/bin/tiffutil -cathidpicheck /Users/musalj/code/OSS/Alcatraz/Alcatraz/eye_icon@2x.png /Users/musalj/code/OSS/Alcatraz/Alcatraz/eye_icon.png -out /Users/musalj/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/Alcatraz.xcplugin/Contents/Resources/eye_icon.tiff
|
97
|
+
)
|
85
98
|
SAMPLE_RUN_SCRIPT = %Q(
|
86
99
|
PhaseScriptExecution Check\\ Pods\\ Manifest.lock /Users/musalj/Library/Developer/Xcode/DerivedData/ObjectiveSugar-ayzdhqmmwtqgysdpznmovjlupqjy/Build/Intermediates/ObjectiveSugar.build/Debug-iphonesimulator/ObjectiveSugar.build/Script-468DABF301EC4EC1A00CC4C2.sh
|
87
100
|
cd /Users/musalj/code/OSS/ObjectiveSugar/Example
|
@@ -16,10 +16,14 @@ module XCPretty
|
|
16
16
|
|
17
17
|
context "without colors" do
|
18
18
|
|
19
|
-
it "prints
|
19
|
+
it "prints dots for passing tests" do
|
20
20
|
@formatter.format_passing_test("sweez testz", "sample spec", "0.002").should == "."
|
21
21
|
end
|
22
22
|
|
23
|
+
it "prints P for pending tests" do
|
24
|
+
@formatter.format_pending_test("sweez testz", "sample spec").should == "P"
|
25
|
+
end
|
26
|
+
|
23
27
|
it "prints F for failing tests" do
|
24
28
|
@formatter.format_failing_test(
|
25
29
|
"///file", "NSNumber Specs", "adding numbers", "should add 2 numbers"
|
@@ -36,6 +40,11 @@ module XCPretty
|
|
36
40
|
).should be_colored :green
|
37
41
|
end
|
38
42
|
|
43
|
+
it "prints yellow for pending tests" do
|
44
|
+
@formatter.format_pending_test("sweez testz", "sample spec"
|
45
|
+
).should be_colored :yellow
|
46
|
+
end
|
47
|
+
|
39
48
|
it "prints red for failing tests" do
|
40
49
|
@formatter.format_failing_test(
|
41
50
|
"///file", "NSNumber Specs", "adding numbers", "should add 2 numbers"
|
@@ -75,6 +75,11 @@ module XCPretty
|
|
75
75
|
". _tupleByAddingObject__should_add_a_non_nil_object (0.001 seconds)"
|
76
76
|
end
|
77
77
|
|
78
|
+
it "formats pending tests" do
|
79
|
+
@formatter.format_pending_test("RACCommandSpec", "_tupleByAddingObject__should_add_a_non_nil_object").should ==
|
80
|
+
"P _tupleByAddingObject__should_add_a_non_nil_object [PENDING]"
|
81
|
+
end
|
82
|
+
|
78
83
|
it "formats Phase Script Execution" do
|
79
84
|
@formatter.format_phase_script_execution("Check Pods Manifest.lock").should ==
|
80
85
|
"> Running script 'Check Pods Manifest.lock'"
|
@@ -110,5 +115,15 @@ module XCPretty
|
|
110
115
|
"RACKVOWrapperSpec"
|
111
116
|
end
|
112
117
|
|
118
|
+
it "formats Touch" do
|
119
|
+
@formatter.format_touch("/path/to/SomeFile.txt","SomeFile.txt").should ==
|
120
|
+
"> Touching SomeFile.txt"
|
121
|
+
end
|
122
|
+
|
123
|
+
it "formats TiffUtil" do
|
124
|
+
@formatter.format_tiffutil("unbelievable.tiff").should ==
|
125
|
+
"> Validating unbelievable.tiff"
|
126
|
+
end
|
127
|
+
|
113
128
|
end
|
114
129
|
end
|
@@ -117,6 +117,12 @@ module XCPretty
|
|
117
117
|
@parser.parse(SAMPLE_OCUNIT_TEST)
|
118
118
|
end
|
119
119
|
|
120
|
+
it "parses pending tests" do
|
121
|
+
@formatter.should receive(:format_pending_test).with('TAPIConversationSpec',
|
122
|
+
'TAPIConversation_createConversation_SendsAPOSTRequestToTheConversationsEndpoint')
|
123
|
+
@parser.parse(SAMPLE_PENDING_KIWI_TEST)
|
124
|
+
end
|
125
|
+
|
120
126
|
it "parses PhaseScriptExecution" do
|
121
127
|
@formatter.should receive(:format_phase_script_execution).with('Check Pods Manifest.lock')
|
122
128
|
@parser.parse(SAMPLE_RUN_SCRIPT)
|
@@ -137,6 +143,18 @@ module XCPretty
|
|
137
143
|
@parser.parse(SAMPLE_PBXCP)
|
138
144
|
end
|
139
145
|
|
146
|
+
it "parses Touch" do
|
147
|
+
@formatter.should receive(:format_touch).with(
|
148
|
+
'/Users/musalj/Library/Developer/Xcode/DerivedData/Alcatraz-aobuxcinaqyzjugrnxjjhfzgwaou/Build/Products/Debug/AlcatrazTests.octest',
|
149
|
+
'AlcatrazTests.octest')
|
150
|
+
@parser.parse(SAMPLE_TOUCH)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "parses TiffUtil" do
|
154
|
+
@formatter.should receive(:format_tiffutil).with('eye_icon.tiff')
|
155
|
+
@parser.parse(SAMPLE_TIFFUTIL)
|
156
|
+
end
|
157
|
+
|
140
158
|
it "parses undefined symbols" do
|
141
159
|
@formatter.should receive(:format_linker_failure).with("Undefined symbols for architecture x86_64",
|
142
160
|
'_OBJC_CLASS_$_CABasicAnimation',
|
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
|
4
|
+
version: 0.1.0
|
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:
|
12
|
+
date: 2014-01-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|