-
Notifications
You must be signed in to change notification settings - Fork 454
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
Xcode 10 changes for test schemes #583
Changes from 3 commits
836a9e6
54af23b
07f7a56
0a2137e
19e0bf3
03e3c83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,6 +151,36 @@ def skipped=(flag) | |
@xml_element.attributes['skipped'] = bool_to_string(flag) | ||
end | ||
|
||
# @return [Bool] | ||
# Whether or not this TestableReference (test bundle) should be run in parallel or not | ||
# | ||
def parallelizable? | ||
string_to_bool(@xml_element.attributes['parallelizable']) | ||
end | ||
|
||
# @param [Bool] | ||
# Set whether or not this TestableReference (test bundle) should be run in parallel or not | ||
# | ||
def parallelizable=(flag) | ||
@xml_element.attributes['parallelizable'] = bool_to_string(flag) | ||
end | ||
|
||
# @return [Bool] | ||
# Whether or not this TestableReference (test bundle) should be run in randomized order. | ||
# | ||
def randomized? | ||
str = @xml_element.attributes['testExecutionOrdering'] | ||
raise Informative, 'Invalid tag value. Expected `random` or nil.' unless ['random', nil].include?(str) | ||
str == 'random' | ||
end | ||
|
||
# @param [Bool] flag | ||
# Set whether or not this TestableReference (test bundle) should be run in randomized order. | ||
# | ||
def randomized=(flag) | ||
@xml_element.attributes['testExecutionOrdering'] = flag ? 'random' : nil | ||
end | ||
|
||
# @return [Array<BuildableReference>] | ||
# The list of BuildableReferences this action will build. | ||
# (The list usually contains only one element) | ||
|
@@ -200,6 +230,52 @@ def add_skipped_test(skipped_test) | |
entries.add_element(skipped_test.xml_element) | ||
end | ||
|
||
# @return [Bool] | ||
# Whether or not this TestableReference (test bundle) should use a whitelist or not | ||
# | ||
def whitelist? | ||
string_to_bool(@xml_element.attributes['useTestSelectionWhitelist']) | ||
end | ||
|
||
# @param [Bool] flag | ||
# Set whether or not this TestableReference (test bundle) should use a whitelist or not | ||
# | ||
def whitelist=(flag) | ||
@xml_element.attributes['useTestSelectionWhitelist'] = bool_to_string(flag) | ||
end | ||
|
||
# @return [Array<SelectedTest>] | ||
# The list of SelectedTest this action will run. | ||
# | ||
def selected_tests | ||
return [] if @xml_element.elements['SelectedTests'].nil? | ||
@xml_element.elements['SelectedTests'].get_elements('Test').map do |node| | ||
TestableReference::SelectedTest.new(node) | ||
end | ||
end | ||
|
||
# @param [Array<SelectedTest>] tests | ||
# Set the list of SelectedTest this action will run. | ||
# | ||
def selected_tests=(tests) | ||
@xml_element.delete_element('SelectedTests') unless @xml_element.elements['SelectedTests'].nil? | ||
if tests.nil? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return | ||
end | ||
entries = @xml_element.add_element('SelectedTests') | ||
tests.each do |selected| | ||
entries.add_element(selected.xml_element) | ||
end | ||
end | ||
|
||
# @param [SelectedTest] selected_test | ||
# The SelectedTest to add to the list of tests this action will run. | ||
# | ||
def add_selected_test(selected_test) | ||
entries = @xml_element.elements['SelectedTests'] || @xml_element.add_element('SelectedTests') | ||
entries.add_element(selected_test.xml_element) | ||
end | ||
|
||
class SkippedTest < XMLElementWrapper | ||
# @param [REXML::Element] node | ||
# The 'Test' XML node that this object will wrap. | ||
|
@@ -226,6 +302,32 @@ def identifier=(value) | |
end | ||
end | ||
|
||
class SelectedTest < XMLElementWrapper | ||
# @param [REXML::Element] node | ||
# The 'Test' XML node that this object will wrap. | ||
# If nil, will create a default XML node to use. | ||
# | ||
def initialize(node = nil) | ||
create_xml_element_with_fallback(node, 'Test') do | ||
self.identifier = node.attributes['Identifier'] unless node.nil? | ||
end | ||
end | ||
|
||
# @return [String] | ||
# Selected test class name | ||
# | ||
def identifier | ||
@xml_element.attributes['Identifier'] | ||
end | ||
|
||
# @param [String] value | ||
# Set the name of the selected test class name | ||
# | ||
def identifier=(value) | ||
@xml_element.attributes['Identifier'] = value | ||
end | ||
end | ||
|
||
# @todo handle 'AdditionalOptions' tag | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,6 +221,7 @@ module Xcodeproj | |
test_ref.xml_element.name.should == 'TestableReference' | ||
test_ref.xml_element.attributes.count.should == 1 | ||
test_ref.xml_element.attributes['skipped'].should == 'NO' | ||
test_ref.randomized?.should.be.false? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did not know abt this syntax! |
||
end | ||
|
||
it 'raises if created with an invalid XML node' do | ||
|
@@ -246,8 +247,38 @@ module Xcodeproj | |
|
||
attributes = { | ||
:skipped => 'skipped', | ||
:parallelizable => 'parallelizable', | ||
:whitelist => 'useTestSelectionWhitelist', | ||
} | ||
specs_for_bool_attr(attributes) | ||
|
||
# Reimplemented because `testExecutionOrdering` doesn't use standard YES/NO | ||
describe 'randomized' do | ||
it '#randomized? detect a true value' do | ||
@sut.xml_element.attributes['testExecutionOrdering'] = 'random' | ||
@sut.randomized?.should == true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
end | ||
|
||
it '#randomized? detect a false value' do | ||
@sut.xml_element.attributes['testExecutionOrdering'] = nil | ||
@sut.randomized?.should == false | ||
end | ||
|
||
it '#randomized? detect an invalid value' do | ||
@sut.xml_element.attributes['testExecutionOrdering'] = 'BadValue' | ||
should.raise(Xcodeproj::Informative) { @sut.randomized? } | ||
end | ||
|
||
it '#randomized= set true value' do | ||
@sut.randomized = true | ||
@sut.xml_element.attributes['testExecutionOrdering'].should == 'random' | ||
end | ||
|
||
it '#randomized= set false value' do | ||
@sut.randomized = false | ||
@sut.xml_element.attributes['testExecutionOrdering'].should.nil? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
end | ||
end | ||
end | ||
|
||
it '#add_skipped_test' do | ||
|
@@ -302,6 +333,58 @@ module Xcodeproj | |
test_ref.skipped_tests[1].xml_element.should == test2.xml_element | ||
end | ||
|
||
it '#add_selected_test' do | ||
test_ref = XCScheme::TestAction::TestableReference.new | ||
selected_test = XCScheme::TestAction::TestableReference::SelectedTest.new | ||
selected_test.identifier = 'MyClassTests' | ||
test_ref.add_selected_test(selected_test) | ||
test_ref.xml_element.elements['SelectedTests'].should.not.nil? | ||
test_ref.xml_element.elements['SelectedTests'].count.should == 1 | ||
test_ref.xml_element.elements['SelectedTests'].elements['Test'].should == selected_test.xml_element | ||
end | ||
|
||
it '#set_selected_tests_nil' do | ||
test_ref = XCScheme::TestAction::TestableReference.new | ||
test_ref.selected_tests = [XCScheme::TestAction::TestableReference::SelectedTest.new] | ||
test_ref.selected_tests.count.should == 1 | ||
test_ref.selected_tests = nil | ||
test_ref.xml_element.elements['SelectedTests'].should.nil? | ||
test_ref.selected_tests.count.should == 0 | ||
end | ||
|
||
it '#set_selected_tests' do | ||
test_ref = XCScheme::TestAction::TestableReference.new | ||
|
||
test1 = XCScheme::TestAction::TestableReference::SelectedTest.new | ||
test1.identifier = 'MyClassTests1' | ||
|
||
test2 = XCScheme::TestAction::TestableReference::SelectedTest.new | ||
test2.identifier = 'MyClassTests2' | ||
|
||
test_ref.selected_tests = [test1, test2] | ||
test_ref.selected_tests.count.should == 2 | ||
test_ref.selected_tests.all? { |e| e.class.should == XCScheme::TestAction::TestableReference::SelectedTest } | ||
test_ref.selected_tests[0].xml_element.should == test1.xml_element | ||
test_ref.selected_tests[1].xml_element.should == test2.xml_element | ||
end | ||
|
||
it '#selected_tests' do | ||
test_ref = XCScheme::TestAction::TestableReference.new | ||
|
||
test1 = XCScheme::TestAction::TestableReference::SelectedTest.new | ||
test1.identifier = 'MyClassTests1' | ||
test_ref.add_selected_test(test1) | ||
|
||
test2 = XCScheme::TestAction::TestableReference::SelectedTest.new | ||
test2.identifier = 'MyClassTests2' | ||
test_ref.add_selected_test(test2) | ||
|
||
test_ref.selected_tests.count.should == 2 | ||
test_ref.selected_tests.all? { |e| e.class.should == XCScheme::TestAction::TestableReference::SelectedTest } | ||
test_ref.selected_tests[0].xml_element.should == test1.xml_element | ||
test_ref.selected_tests[1].xml_element.should == test2.xml_element | ||
end | ||
|
||
it '#add_buildable_reference' do | ||
project = Xcodeproj::Project.new('/foo/bar/baz.xcodeproj') | ||
test_ref = XCScheme::TestAction::TestableReference.new | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be able to delete the conditional on this line -- calling
delete
with a parameter that's not in the collection will just returnnil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is copied from
skipped_tests=
so i removed it there too