xcpretty-security-patched 0.3.0
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 +7 -0
- data/.gitignore +19 -0
- data/.hound.yml +2 -0
- data/.kick +17 -0
- data/.rubocop.yml +239 -0
- data/.travis.yml +12 -0
- data/CHANGELOG.md +269 -0
- data/CONTRIBUTING.md +64 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +61 -0
- data/README.md +95 -0
- data/Rakefile +18 -0
- data/assets/report.html.erb +173 -0
- data/bin/xcpretty +90 -0
- data/features/assets/RACCommandSpec_enabled_signal_should_send_YES_while_executing_is_YES.png +0 -0
- data/features/assets/apple_raw.png +0 -0
- data/features/custom_formatter.feature +15 -0
- data/features/custom_reporter.feature +29 -0
- data/features/fixtures/xcodebuild.log +5963 -0
- data/features/html_report.feature +54 -0
- data/features/json_compilation_database_report.feature +33 -0
- data/features/junit_report.feature +49 -0
- data/features/knock_format.feature +11 -0
- data/features/simple_format.feature +238 -0
- data/features/steps/custom_reporter_steps.rb +16 -0
- data/features/steps/formatting_steps.rb +386 -0
- data/features/steps/html_steps.rb +32 -0
- data/features/steps/json_steps.rb +45 -0
- data/features/steps/junit_steps.rb +39 -0
- data/features/steps/report_steps.rb +27 -0
- data/features/steps/xcpretty_steps.rb +31 -0
- data/features/support/env.rb +123 -0
- data/features/tap_format.feature +31 -0
- data/features/test_format.feature +49 -0
- data/features/xcpretty.feature +14 -0
- data/lib/xcpretty/ansi.rb +72 -0
- data/lib/xcpretty/formatters/formatter.rb +200 -0
- data/lib/xcpretty/formatters/knock.rb +35 -0
- data/lib/xcpretty/formatters/rspec.rb +33 -0
- data/lib/xcpretty/formatters/simple.rb +200 -0
- data/lib/xcpretty/formatters/tap.rb +40 -0
- data/lib/xcpretty/parser.rb +596 -0
- data/lib/xcpretty/printer.rb +28 -0
- data/lib/xcpretty/reporters/html.rb +93 -0
- data/lib/xcpretty/reporters/json_compilation_database.rb +51 -0
- data/lib/xcpretty/reporters/junit.rb +102 -0
- data/lib/xcpretty/reporters/reporter.rb +62 -0
- data/lib/xcpretty/snippet.rb +38 -0
- data/lib/xcpretty/syntax.rb +58 -0
- data/lib/xcpretty/term.rb +14 -0
- data/lib/xcpretty/version.rb +4 -0
- data/lib/xcpretty.rb +38 -0
- data/spec/fixtures/NSStringTests.m +64 -0
- data/spec/fixtures/constants.rb +707 -0
- data/spec/fixtures/custom_formatter.rb +18 -0
- data/spec/fixtures/custom_reporter.rb +30 -0
- data/spec/fixtures/oneliner.m +1 -0
- data/spec/fixtures/raw_kiwi_compilation_fail.txt +24 -0
- data/spec/fixtures/raw_kiwi_fail.txt +1896 -0
- data/spec/fixtures/raw_specta_fail.txt +3110 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/support/matchers/colors.rb +21 -0
- data/spec/xcpretty/ansi_spec.rb +47 -0
- data/spec/xcpretty/formatters/formatter_spec.rb +151 -0
- data/spec/xcpretty/formatters/rspec_spec.rb +56 -0
- data/spec/xcpretty/formatters/simple_spec.rb +178 -0
- data/spec/xcpretty/parser_spec.rb +636 -0
- data/spec/xcpretty/printer_spec.rb +55 -0
- data/spec/xcpretty/reporters/junit_spec.rb +20 -0
- data/spec/xcpretty/reporters/reporter_spec.rb +40 -0
- data/spec/xcpretty/snippet_spec.rb +46 -0
- data/spec/xcpretty/syntax_spec.rb +39 -0
- data/spec/xcpretty/term_spec.rb +26 -0
- data/xcpretty.gemspec +37 -0
- metadata +250 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
module XCPretty
|
2
|
+
class JSONCompilationDatabase < Reporter
|
3
|
+
|
4
|
+
FILEPATH = 'build/reports/compilation_db.json'
|
5
|
+
|
6
|
+
def load_dependencies
|
7
|
+
unless @@loaded ||= false
|
8
|
+
require 'fileutils'
|
9
|
+
require 'pathname'
|
10
|
+
require 'json'
|
11
|
+
@@loaded = true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(options)
|
16
|
+
super(options)
|
17
|
+
@compilation_units = []
|
18
|
+
@pch_path = nil
|
19
|
+
@current_file = nil
|
20
|
+
@current_path = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def format_process_pch_command(file_path)
|
24
|
+
@pch_path = file_path
|
25
|
+
end
|
26
|
+
|
27
|
+
def format_compile(file_name, file_path)
|
28
|
+
@current_file = file_name
|
29
|
+
@current_path = file_path
|
30
|
+
end
|
31
|
+
|
32
|
+
def format_compile_command(compiler_command, file_path)
|
33
|
+
directory = file_path.gsub("#{@current_path}", '').gsub(/\/$/, '')
|
34
|
+
directory = '/' if directory.empty?
|
35
|
+
|
36
|
+
cmd = compiler_command
|
37
|
+
cmd = cmd.gsub(/(\-include)\s.*\.pch/, "\\1 #{@pch_path}") if @pch_path
|
38
|
+
|
39
|
+
@compilation_units << {command: cmd,
|
40
|
+
file: @current_path,
|
41
|
+
directory: directory}
|
42
|
+
end
|
43
|
+
|
44
|
+
def write_report
|
45
|
+
File.open(@filepath, 'w') do |f|
|
46
|
+
f.write(@compilation_units.to_json)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module XCPretty
|
2
|
+
class JUnit < Reporter
|
3
|
+
|
4
|
+
FILEPATH = 'build/reports/junit.xml'
|
5
|
+
|
6
|
+
def load_dependencies
|
7
|
+
unless @@loaded ||= false
|
8
|
+
require 'fileutils'
|
9
|
+
require 'pathname'
|
10
|
+
require 'rexml/document'
|
11
|
+
require 'rexml/formatters/pretty'
|
12
|
+
@@loaded = true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(options)
|
17
|
+
super(options)
|
18
|
+
@directory = `pwd`.strip
|
19
|
+
@document = REXML::Document.new
|
20
|
+
@document << REXML::XMLDecl.new('1.0', 'UTF-8')
|
21
|
+
@document.add_element('testsuites')
|
22
|
+
@total_fails = 0
|
23
|
+
@total_tests = 0
|
24
|
+
end
|
25
|
+
|
26
|
+
def handle(line)
|
27
|
+
@parser.parse(line)
|
28
|
+
end
|
29
|
+
|
30
|
+
def format_test_run_started(name)
|
31
|
+
@document.root.add_attribute('name', name)
|
32
|
+
end
|
33
|
+
|
34
|
+
def format_passing_test(classname, test_case, time)
|
35
|
+
test_node = suite(classname).add_element('testcase')
|
36
|
+
test_node.attributes['classname'] = classname
|
37
|
+
test_node.attributes['name'] = test_case
|
38
|
+
test_node.attributes['time'] = time
|
39
|
+
@test_count += 1
|
40
|
+
end
|
41
|
+
|
42
|
+
def format_pending_test(classname, test_case)
|
43
|
+
test_node = suite(classname).add_element('testcase')
|
44
|
+
test_node.attributes['classname'] = classname
|
45
|
+
test_node.attributes['name'] = test_case
|
46
|
+
test_node.add_element('skipped')
|
47
|
+
@test_count += 1
|
48
|
+
end
|
49
|
+
|
50
|
+
def format_failing_test(classname, test_case, reason, file)
|
51
|
+
test_node = suite(classname).add_element('testcase')
|
52
|
+
test_node.attributes['classname'] = classname
|
53
|
+
test_node.attributes['name'] = test_case
|
54
|
+
fail_node = test_node.add_element('failure')
|
55
|
+
fail_node.attributes['message'] = reason
|
56
|
+
fail_node.text = file.sub(@directory + '/', '')
|
57
|
+
@test_count += 1
|
58
|
+
@fail_count += 1
|
59
|
+
end
|
60
|
+
|
61
|
+
def finish
|
62
|
+
set_test_counters
|
63
|
+
@document.root.attributes['tests'] = @total_tests
|
64
|
+
@document.root.attributes['failures'] = @total_fails
|
65
|
+
super
|
66
|
+
end
|
67
|
+
|
68
|
+
def write_report
|
69
|
+
formatter = REXML::Formatters::Pretty.new(2)
|
70
|
+
formatter.compact = true
|
71
|
+
output_file = File.open(@filepath, 'w+')
|
72
|
+
result = formatter.write(@document, output_file)
|
73
|
+
output_file.close
|
74
|
+
result
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def suite(classname)
|
80
|
+
if @last_suite && @last_suite.attributes['name'] == classname
|
81
|
+
return @last_suite
|
82
|
+
end
|
83
|
+
|
84
|
+
set_test_counters
|
85
|
+
@last_suite = @document.root.add_element('testsuite')
|
86
|
+
@last_suite.attributes['name'] = classname
|
87
|
+
@last_suite
|
88
|
+
end
|
89
|
+
|
90
|
+
def set_test_counters
|
91
|
+
if @last_suite
|
92
|
+
@last_suite.attributes['tests'] = @test_count
|
93
|
+
@last_suite.attributes['failures'] = @fail_count
|
94
|
+
end
|
95
|
+
@total_fails += @fail_count || 0
|
96
|
+
@total_tests += @test_count || 0
|
97
|
+
@test_count = 0
|
98
|
+
@fail_count = 0
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module XCPretty
|
2
|
+
|
3
|
+
class Reporter < Formatter
|
4
|
+
FILEPATH = 'build/reports/tests.txt'
|
5
|
+
|
6
|
+
attr_reader :tests
|
7
|
+
|
8
|
+
def load_dependencies
|
9
|
+
unless @@loaded ||= false
|
10
|
+
require 'fileutils'
|
11
|
+
@@loaded = true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(options)
|
16
|
+
super(true, true)
|
17
|
+
load_dependencies
|
18
|
+
@filepath = options[:path] || self.class::FILEPATH
|
19
|
+
@test_count = 0
|
20
|
+
@fail_count = 0
|
21
|
+
@tests = []
|
22
|
+
end
|
23
|
+
|
24
|
+
def handle(line)
|
25
|
+
@parser.parse(line)
|
26
|
+
end
|
27
|
+
|
28
|
+
def finish
|
29
|
+
FileUtils.mkdir_p(File.dirname(@filepath))
|
30
|
+
write_report
|
31
|
+
end
|
32
|
+
|
33
|
+
def format_failing_test(suite, test_case, reason, file)
|
34
|
+
@test_count += 1
|
35
|
+
@fail_count += 1
|
36
|
+
@tests.push("#{test_case} in #{file} FAILED: #{reason}")
|
37
|
+
end
|
38
|
+
|
39
|
+
def format_passing_test(suite, test_case, time)
|
40
|
+
@test_count += 1
|
41
|
+
@tests.push("#{test_case} PASSED")
|
42
|
+
end
|
43
|
+
|
44
|
+
def format_pending_test(classname, test_case)
|
45
|
+
@test_count += 1
|
46
|
+
@tests.push("#{test_case} IS PENDING")
|
47
|
+
end
|
48
|
+
|
49
|
+
def write_report
|
50
|
+
File.open(@filepath, 'w') do |f|
|
51
|
+
# WAT: get rid of these locals. BTW Cucumber fails if you remove them
|
52
|
+
output_string = @tests.join("\n")
|
53
|
+
output_string +=
|
54
|
+
"\nFINISHED RUNNING #{@test_count} TESTS WITH #{@fail_count} FAILURES"
|
55
|
+
f.write output_string
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module XCPretty
|
2
|
+
class Snippet
|
3
|
+
attr_reader :contents, :file_path
|
4
|
+
|
5
|
+
def initialize(contents = '', file_path = '')
|
6
|
+
@contents = contents
|
7
|
+
@file_path = file_path
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.from_filepath(filepath)
|
11
|
+
path, line = filepath.split(':')
|
12
|
+
file = File.open(path)
|
13
|
+
|
14
|
+
text = read_snippet(file, line)
|
15
|
+
|
16
|
+
file.close
|
17
|
+
new(text, filepath)
|
18
|
+
rescue
|
19
|
+
new('', filepath)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def self.read_snippet(file, around_line)
|
24
|
+
text = ''
|
25
|
+
starting_position = around_line.to_i - 2
|
26
|
+
starting_position.times { file.gets }
|
27
|
+
3.times { text += readline(file) }
|
28
|
+
text
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.readline(file)
|
32
|
+
file.gets
|
33
|
+
$_ || ''
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
begin
|
2
|
+
require 'rouge'
|
3
|
+
rescue LoadError
|
4
|
+
# rubocop:disable Style/ConstantName
|
5
|
+
Rouge = nil
|
6
|
+
# rubocop:enable Style/ConstantName
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'xcpretty/snippet'
|
10
|
+
|
11
|
+
module XCPretty
|
12
|
+
module Syntax
|
13
|
+
def self.highlight(snippet)
|
14
|
+
return snippet.contents unless Rouge
|
15
|
+
highlight_with_formatter(snippet, Rouge::Formatters::Terminal256.new)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.highlight_html(snippet)
|
19
|
+
return snippet.contents unless Rouge
|
20
|
+
highlight_with_formatter(snippet, Rouge::Formatters::HTML.new)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.highlight_with_formatter(snippet, formatter)
|
24
|
+
if snippet.file_path.include?(':')
|
25
|
+
filename = snippet.file_path.rpartition(':').first
|
26
|
+
else
|
27
|
+
filename = snippet.file_path
|
28
|
+
end
|
29
|
+
|
30
|
+
lexer = find_lexer(filename, snippet.contents)
|
31
|
+
if lexer
|
32
|
+
formatter.format(lexer.lex(snippet.contents))
|
33
|
+
else
|
34
|
+
snippet.contents
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# @param [String] filename The filename
|
39
|
+
# @param [String] contents The contents of the file
|
40
|
+
# @return [Rouge::Lexer]
|
41
|
+
def self.find_lexer(filename, contents)
|
42
|
+
case File.extname(filename)
|
43
|
+
when '.cpp', '.cc', '.c++', '.cxx', '.hpp', '.h++', '.hxx'
|
44
|
+
Rouge::Lexers::Cpp
|
45
|
+
when '.m', '.h' then Rouge::Lexers::ObjectiveC
|
46
|
+
when '.swift' then Rouge::Lexers::Swift
|
47
|
+
when '.ruby', '.rb' then Rouge::Lexers::Ruby
|
48
|
+
else
|
49
|
+
options = {
|
50
|
+
filename: File.basename(filename),
|
51
|
+
source: contents
|
52
|
+
}
|
53
|
+
Rouge::Lexer.guesses(options).first
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
data/lib/xcpretty.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'xcpretty/version'
|
2
|
+
require 'xcpretty/printer'
|
3
|
+
require 'xcpretty/syntax'
|
4
|
+
require 'xcpretty/snippet'
|
5
|
+
require 'xcpretty/term'
|
6
|
+
require 'xcpretty/formatters/formatter'
|
7
|
+
require 'xcpretty/formatters/simple'
|
8
|
+
require 'xcpretty/formatters/rspec'
|
9
|
+
require 'xcpretty/formatters/knock'
|
10
|
+
require 'xcpretty/formatters/tap'
|
11
|
+
require 'xcpretty/reporters/reporter'
|
12
|
+
require 'xcpretty/reporters/junit'
|
13
|
+
require 'xcpretty/reporters/html'
|
14
|
+
require 'xcpretty/reporters/json_compilation_database'
|
15
|
+
|
16
|
+
module XCPretty
|
17
|
+
|
18
|
+
def self.class_from_path(path)
|
19
|
+
source = File.read(path)
|
20
|
+
klass = eval(source, nil, path)
|
21
|
+
raise unless klass.is_a?(Class)
|
22
|
+
klass
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.load_custom_class(path)
|
26
|
+
$LOAD_PATH.unshift File.dirname(path)
|
27
|
+
class_from_path(path)
|
28
|
+
rescue SyntaxError => e
|
29
|
+
exit_with_error("Expected custom source file to return a class. #{e}")
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.exit_with_error(message)
|
33
|
+
$stderr.puts "[!] #{message}"
|
34
|
+
exit 1
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
//
|
2
|
+
// NSStringTests.m
|
3
|
+
// SampleProject
|
4
|
+
//
|
5
|
+
// Created by Neil on 05/12/2012.
|
6
|
+
// Copyright (c) 2012 @supermarin | supermar.in | All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import "Kiwi.h"
|
10
|
+
#import "ObjectiveSugar.h"
|
11
|
+
|
12
|
+
SPEC_BEGIN(StringAdditions)
|
13
|
+
|
14
|
+
describe(@"Foundation-style functions", ^{
|
15
|
+
|
16
|
+
it(@"NSStringWithFormat makes NSString -stringWithFormat", ^{
|
17
|
+
|
18
|
+
[[NSStringWithFormat(@"This is %@", @1) should] equal:@"This is 1"];
|
19
|
+
});
|
20
|
+
|
21
|
+
});
|
22
|
+
|
23
|
+
describe(@"Additions", ^{
|
24
|
+
|
25
|
+
NSString *sentence = @"Jane Doe's going in a shop,and,yeah;";
|
26
|
+
|
27
|
+
it(@"-split splits by whitespace", ^{
|
28
|
+
[[[@" the\r\nquick brown\t \tfox\n" split] should] equal:@[@"the", @"quick", @"brown", @"fox"]];
|
29
|
+
});
|
30
|
+
|
31
|
+
it(@"-split: splits with given delimiter", ^{
|
32
|
+
[[[sentence split:@","] should] equal:@[@"Jane Doe's going in a shop", @"and", @"yeah;"]];
|
33
|
+
});
|
34
|
+
|
35
|
+
it(@"-split: splits with delimiter string, not just a char", ^{
|
36
|
+
[[[@"one / two / three" split:@" / "] should] equal:@[@"one", @"two", @"three"]];
|
37
|
+
});
|
38
|
+
|
39
|
+
it(@"contains string", ^{
|
40
|
+
[[@([sentence containsString:@"jane doe"]) should] beTrue];
|
41
|
+
});
|
42
|
+
|
43
|
+
context(@"CamelCase and snake_case", ^{
|
44
|
+
|
45
|
+
it(@"converts snake_cased to CamelCased", ^{
|
46
|
+
[[[@"snake_case" camelCase] should] equal:@"SnakeCase"];
|
47
|
+
});
|
48
|
+
|
49
|
+
it(@"handles correctly snake case on beginning and at the end", ^{
|
50
|
+
[[[@"_snake_case" camelCase] should] equal:@"SnakeCase"];
|
51
|
+
[[[@"snake_case_" camelCase] should] equal:@"SnakeCase"];
|
52
|
+
});
|
53
|
+
|
54
|
+
});
|
55
|
+
|
56
|
+
it(@"-strip strips whitespaces and newlines from both ends", ^{
|
57
|
+
[[[@" Look mo, no empties! " strip] should] equal:@"Look mo, no empties!"];
|
58
|
+
});
|
59
|
+
|
60
|
+
});
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
SPEC_END
|