Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiple test summary Plists/destinations #20

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 78 additions & 74 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,117 +2,117 @@ PATH
remote: .
specs:
trainer (0.7.0)
fastlane (>= 2.25.0)
plist (>= 3.1.0, < 4.0.0)

GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.3.5)
activesupport (4.2.8)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
CFPropertyList (3.0.0)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
ast (2.3.0)
atomos (0.1.2)
babosa (1.0.2)
claide (1.0.1)
claide (1.0.2)
coderay (1.1.1)
colored (1.2)
colored2 (3.1.2)
commander-fastlane (4.4.4)
commander-fastlane (4.4.6)
highline (~> 1.7.2)
declarative (0.0.10)
declarative-option (0.1.0)
diff-lcs (1.3)
domain_name (0.5.20170223)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.2.0)
excon (0.55.0)
faraday (0.12.0.1)
dotenv (2.4.0)
emoji_regex (0.1.1)
excon (0.62.0)
faraday (0.15.0)
multipart-post (>= 1.2, < 3)
faraday-cookie_jar (0.0.6)
faraday (>= 0.7.4)
http-cookie (~> 1.0.0)
faraday_middleware (0.11.0.1)
faraday_middleware (0.12.2)
faraday (>= 0.7.4, < 1.0)
fastimage (2.1.0)
fastlane (2.25.0)
activesupport (< 5)
fastimage (2.1.3)
fastlane (2.94.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.3, < 3.0.0)
babosa (>= 1.0.2, < 2.0.0)
bundler (>= 1.12.0, < 2.0.0)
colored
commander-fastlane (>= 4.4.0, < 5.0.0)
commander-fastlane (>= 4.4.6, < 5.0.0)
dotenv (>= 2.1.1, < 3.0.0)
emoji_regex (~> 0.1)
excon (>= 0.45.0, < 1.0.0)
faraday (~> 0.9)
faraday-cookie_jar (~> 0.0.6)
faraday_middleware (~> 0.9)
fastimage (>= 1.6)
gh_inspector (>= 1.0.1, < 2.0.0)
google-api-client (~> 0.9.2)
fastimage (>= 2.1.0, < 3.0.0)
gh_inspector (>= 1.1.2, < 2.0.0)
google-api-client (>= 0.13.1, < 0.14.0)
highline (>= 1.7.2, < 2.0.0)
json (< 3.0.0)
mini_magick (~> 4.5.1)
multi_json
multi_xml (~> 0.5)
multipart-post (~> 2.0.0)
plist (>= 3.1.0, < 4.0.0)
public_suffix (~> 2.0.0)
rubyzip (>= 1.1.0, < 2.0.0)
security (= 0.1.3)
slack-notifier (>= 1.3, < 2.0.0)
simctl (~> 1.6.3)
slack-notifier (>= 2.0.0, < 3.0.0)
terminal-notifier (>= 1.6.2, < 2.0.0)
terminal-table (>= 1.4.5, < 2.0.0)
tty-screen (~> 0.5.0)
tty-screen (>= 0.6.3, < 1.0.0)
tty-spinner (>= 0.8.0, < 1.0.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 0.20, < 2.0.0)
xcodeproj (>= 1.5.7, < 2.0.0)
xcpretty (>= 0.2.4, < 1.0.0)
xcpretty-travis-formatter (>= 0.0.3)
gh_inspector (1.0.3)
google-api-client (0.9.28)
addressable (~> 2.3)
gh_inspector (1.1.3)
google-api-client (0.13.6)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 0.5)
httpclient (~> 2.7)
hurley (~> 0.1)
memoist (~> 0.11)
mime-types (>= 1.6)
representable (~> 2.3.0)
retriable (~> 2.0)
googleauth (0.5.1)
faraday (~> 0.9)
jwt (~> 1.4)
httpclient (>= 2.8.1, < 3.0)
mime-types (~> 3.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.0)
googleauth (0.6.2)
faraday (~> 0.12)
jwt (>= 1.4, < 3.0)
logging (~> 2.0)
memoist (~> 0.12)
multi_json (~> 1.11)
os (~> 0.9)
signet (~> 0.7)
highline (1.7.8)
highline (1.7.10)
http-cookie (1.0.3)
domain_name (~> 0.5)
httpclient (2.8.3)
hurley (0.2)
i18n (0.8.1)
json (2.0.3)
jwt (1.5.6)
json (2.1.0)
jwt (2.1.0)
little-plugger (1.1.4)
logging (2.2.0)
logging (2.2.2)
little-plugger (~> 1.1)
multi_json (~> 1.10)
memoist (0.15.0)
memoist (0.16.0)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_magick (4.5.1)
minitest (5.10.1)
multi_json (1.12.1)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nanaimo (0.2.3)
nanaimo (0.2.5)
naturally (2.1.0)
os (0.9.6)
parser (2.4.0.0)
ast (~> 2.2)
plist (3.2.0)
plist (3.4.0)
powerpack (0.1.1)
pry (0.10.4)
coderay (~> 1.1.0)
Expand All @@ -121,10 +121,12 @@ GEM
public_suffix (2.0.5)
rainbow (2.2.1)
rake (12.0.0)
representable (2.3.0)
uber (~> 0.0.7)
retriable (2.1.0)
rouge (1.11.1)
representable (3.0.4)
declarative (< 0.1.0)
declarative-option (< 0.2.0)
uber (< 0.2.0)
retriable (3.1.1)
rouge (2.0.7)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
Expand All @@ -146,48 +148,50 @@ GEM
ruby-progressbar (1.8.1)
rubyzip (1.2.1)
security (0.1.3)
signet (0.7.3)
signet (0.8.1)
addressable (~> 2.3)
faraday (~> 0.9)
jwt (~> 1.5)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
slack-notifier (1.5.1)
simctl (1.6.4)
CFPropertyList
naturally
slack-notifier (2.3.2)
slop (3.6.0)
terminal-notifier (1.7.1)
terminal-table (1.7.3)
unicode-display_width (~> 1.1.1)
thread_safe (0.3.6)
tty-screen (0.5.0)
tzinfo (1.2.3)
thread_safe (~> 0.1)
uber (0.0.15)
terminal-notifier (1.8.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
tty-cursor (0.5.0)
tty-screen (0.6.4)
tty-spinner (0.8.0)
tty-cursor (>= 0.5.0)
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.2)
unf_ext (0.0.7.5)
unicode-display_width (1.1.3)
word_wrap (1.0.0)
xcodeproj (1.4.3)
CFPropertyList (~> 2.3.3)
activesupport (>= 3)
claide (>= 1.0.1, < 2.0)
xcodeproj (1.5.7)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.2)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.2.3)
xcpretty (0.2.6)
rouge (~> 1.8)
xcpretty-travis-formatter (0.0.4)
nanaimo (~> 0.2.4)
xcpretty (0.2.8)
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.0)
xcpretty (~> 0.2, >= 0.0.7)

PLATFORMS
ruby

DEPENDENCIES
bundler
fastlane (>= 2.25.0)
pry
rake
rspec (~> 3.1.0)
rubocop (~> 0.38.0)
trainer!

BUNDLED WITH
1.14.6
1.16.1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class TrainerAction < Action
def self.run(params)
require "trainer"

params[:path] = Actions.lane_context[Actions::SharedValues::SCAN_GENERATED_PLIST_FILE] if Actions.lane_context[Actions::SharedValues::SCAN_GENERATED_PLIST_FILE]
params[:path] ||= Actions.lane_context[Actions::SharedValues::SCAN_GENERATED_PLIST_FILE] if Actions.lane_context[Actions::SharedValues::SCAN_GENERATED_PLIST_FILE]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you weren't previously setting 'path' it will now always be '.' (the options default) even if SCAN_GENERATED_PLIST_FILE exists. If you want everything to be passive you could do something like this. I'm not sure what the best fix is for people using with/without Fastlane, since they're both assuming different default values.

Looks good; thanks for creating the PR.

params[:path] ||= Actions.lane_context[Actions::SharedValues::SCAN_DERIVED_DATA_PATH] if Actions.lane_context[Actions::SharedValues::SCAN_DERIVED_DATA_PATH]

fail_build = params[:fail_build]
Expand Down
27 changes: 22 additions & 5 deletions lib/assets/junit.xml.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<% number_of_tests = 0 %>
<% number_of_failures = 0 %>
<% @results.each { |a| number_of_tests += a[:number_of_tests] } %>
<% @results.each { |a| number_of_failures += a[:number_of_failures] } %>
<% number_of_tests = @results.map {|r| r[:number_of_tests] }.reduce(:+) %>
<% number_of_failures = @results.map {|r| r[:number_of_failures] }.reduce(:+) %>

<testsuites tests="<%= number_of_tests %>" failures="<%= number_of_failures %>">
<% @results.each do |testsuite| %>
<testsuite name=<%= (testsuite[:target_name].nil? ? testsuite[:test_name] : testsuite[:target_name]).encode(:xml => :attr) %> tests="<%= testsuite[:number_of_tests] %>" failures="<%= testsuite[:number_of_failures] %>" time="<%= testsuite[:duration] %>">
<% run_destination = testsuite[:run_destination] %>
<% if run_destination %>
<% target_device = run_destination[:target_device] %>
<% package = "#{run_destination[:name]} (#{target_device[:operating_system_version]})" %>
<% package_attr = "package=#{ package.encode(:xml => :attr) }" %>
<% testsuite_name = "#{(testsuite[:target_name].nil? ? testsuite[:test_name] : testsuite[:target_name])} - #{package}" %>
<% else %>
<% package_attr = "" %>
<% testsuite_name = testsuite[:target_name] %>
<% end %>
<testsuite <%= package_attr %> name=<%= testsuite_name.encode(:xml => :attr) %> tests="<%= testsuite[:number_of_tests] %>" failures="<%= testsuite[:number_of_failures] %>" time="<%= testsuite[:duration] %>">
<% if run_destination %>
<properties>
<property name="RunDestination.Name" value="<%= run_destination[:name] %>"/>
<property name="RunDestination.TargetArchitecture" value="<%= run_destination[:target_architecture] %>"/>
<property name="RunDestination.TargetDevice.Identifier" value="<%= target_device[:identifier] %>"/>
<property name="RunDestination.TargetDevice.Name" value="<%= target_device[:name] %>"/>
<property name="RunDestination.TargetDevice.OperatingSystemVersion" value="<%= target_device[:operating_system_version] %>"/>
</properties>
<% end %>
<% testsuite[:tests].each do |test| %>
<testcase classname=<%= test[:test_group].encode(:xml => :attr) %> name=<%= test[:name].encode(:xml => :attr) %> time="<%= test[:duration] %>">
<% (test[:failures] || []).each do |failure| %>
Expand Down
21 changes: 18 additions & 3 deletions lib/trainer/test_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ def self.auto_convert(config)
title: "Summary for trainer #{Trainer::VERSION}")

containing_dir = config[:path]
files = Dir["#{containing_dir}/**/Logs/Test/*TestSummaries.plist"]
files += Dir["#{containing_dir}/Test/*TestSummaries.plist"]
files += Dir["#{containing_dir}/*TestSummaries.plist"]
files = Dir["#{containing_dir}/**/*_TestSummaries.plist"]
files += Dir[containing_dir] if containing_dir.end_with?(".plist") # if it's the exact path to a plist file

if files.empty?
Expand Down Expand Up @@ -104,12 +102,29 @@ def unfold_tests(data)

# Convert the Hashes and Arrays in something more useful
def parse_content
plist_run_destination = self.raw_json["RunDestination"]
if plist_run_destination
plist_target_device = plist_run_destination["TargetDevice"]
run_destination = {
name: plist_run_destination["Name"],
target_architecture: plist_run_destination["TargetArchitecture"],
target_device: {
identifier: plist_target_device["Identifier"],
name: plist_target_device["Name"],
operating_system_version: plist_target_device["OperatingSystemVersion"]
}
}
else
run_destination = nil
end

self.data = self.raw_json["TestableSummaries"].collect do |testable_summary|
summary_row = {
project_path: testable_summary["ProjectPath"],
target_name: testable_summary["TargetName"],
test_name: testable_summary["TestName"],
duration: testable_summary["Tests"].map { |current_test| current_test["Duration"] }.inject(:+),
run_destination: run_destination,
tests: unfold_tests(testable_summary["Tests"]).collect do |current_test|
current_row = {
identifier: current_test["TestIdentifier"],
Expand Down
19 changes: 19 additions & 0 deletions spec/fixtures/TestSummaries-NoRunDestination.junit
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="5" failures="0">
<testsuite name="FooTests" tests="1" failures="0" time="0.0">
<testcase classname="BarViewControllerTests" name="testInit_NoPlaces_NoSelection()" time="0.0">
</testcase>
</testsuite>
<testsuite name="FooViewsTests" tests="3" failures="0" time="0.0">
<testcase classname="FooEmptyTableViewHelperTests" name="testHeaderViewObservation()" time="0.0">
</testcase>
<testcase classname="UIView_ExtensionsTests" name="testComplexViewIsVisibleInWindow()" time="0.0">
</testcase>
<testcase classname="UIView_ExtensionsTests" name="testSimpleViewIsVisibleInWindow()" time="0.0">
</testcase>
</testsuite>
<testsuite name="FooFoundationTests" tests="1" failures="0" time="0.0">
<testcase classname="KeyValueObserverDeferredTests" name="testCancelReleasesObservedObject()" time="0.0">
</testcase>
</testsuite>
</testsuites>
Loading