-
Notifications
You must be signed in to change notification settings - Fork 104
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
Let users add arbitrary configuration to tests #213
Changes from all commits
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ class XcodeprojHelper | |
def treat_warnings_as_errors(enable_errors) | ||
if enable_errors | ||
puts 'Setting GCC_TREAT_WARNINGS_AS_ERRORS for Release builds' | ||
target.build_settings('Release')['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'YES' | ||
application_target.build_settings('Release')['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'YES' | ||
end | ||
end | ||
|
||
|
@@ -53,18 +53,18 @@ def add_script_phases(scripts) | |
end | ||
end | ||
|
||
def perform_extra_config(extra_config) | ||
if extra_config | ||
extra_config.each do |name, settings| | ||
if name.downcase == "all" | ||
object = target | ||
else | ||
object = target.build_settings(name) | ||
end | ||
def perform_extra_config(app_config, test_config) | ||
{app_config => application_target, test_config => test_target}.each do |config, target| | ||
if config | ||
config.each do |name, settings| | ||
if name.downcase == "all" | ||
object = target | ||
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. Should this now be 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. Nope, it's whatever target we've associated with the config on line 56. |
||
else | ||
object = target.build_settings(name) | ||
end | ||
|
||
if object | ||
settings.each do |key, value| | ||
object[key] = value | ||
if object | ||
object.merge!(settings) | ||
end | ||
end | ||
end | ||
|
@@ -77,28 +77,40 @@ def save | |
|
||
private | ||
|
||
def target | ||
@target ||= ObjectPicker.choose_item('target', available_targets) | ||
def application_target | ||
@target ||= ObjectPicker.choose_item('target', application_targets) | ||
end | ||
|
||
def test_target | ||
@test_target ||= ObjectPicker.choose_item('test target', test_targets) | ||
end | ||
|
||
def application_targets | ||
all_targets.reject { |t| t.name.end_with?('Tests') } | ||
end | ||
|
||
def test_targets | ||
all_targets.select { |t| t.name.end_with?('Tests') } | ||
end | ||
|
||
def available_targets | ||
xcode_project.targets.to_a.reject { |t| t.name.end_with?('Tests') } | ||
def all_targets | ||
xcode_project.targets.to_a | ||
end | ||
|
||
def add_shell_script_build_phase(script, name, index) | ||
if build_phase_does_not_exist_with_name?(name) | ||
build_phase = target.new_shell_script_build_phase(name) | ||
build_phase = application_target.new_shell_script_build_phase(name) | ||
build_phase.shell_script = script | ||
|
||
target.build_phases.delete(build_phase) | ||
target.build_phases.insert(index, build_phase) | ||
application_target.build_phases.delete(build_phase) | ||
application_target.build_phases.insert(index, build_phase) | ||
|
||
xcode_project.save | ||
end | ||
end | ||
|
||
def build_phase_does_not_exist_with_name?(name) | ||
target.build_phases.to_a.none? { |phase| phase.display_name == name } | ||
application_target.build_phases.to_a.none? { |phase| phase.display_name == name } | ||
end | ||
|
||
def file_manager | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,12 @@ def []=(key, value) | |
configuration.build_settings[key] = value | ||
end | ||
end | ||
|
||
def merge!(hash) | ||
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. |
||
hash.each do |key, value| | ||
self[key] = value | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
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.
You could do
.compact.each
to remove thisif
statement..compact
removesnil
s.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.
How functional!