Skip to content

Commit

Permalink
Add test to verify that show_env_vars_in_log and `always_out_of_dat…
Browse files Browse the repository at this point in the history
…e` are properly applied
  • Loading branch information
alexandre-pod committed Dec 5, 2023
1 parent 7db4fb3 commit 946c93e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/fixtures/execution_with_resettable_flags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
scripts:
my_script:
name: "My Script"
script: |
echo my_script
show_env_vars_in_log: '0'
always_out_of_date: '1'

targets:
EmptyProject:
- my_script
9 changes: 9 additions & 0 deletions test/fixtures/execution_without_resettable_flags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
scripts:
my_script:
name: "My Script"
script: |
echo my_script
targets:
EmptyProject:
- my_script
28 changes: 28 additions & 0 deletions test/runner_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class Xcodeproj::Project::Object::PBXNativeTarget
def ft_build_phases_names
build_phases.map(&:display_name)
end

def ft_spinjector_build_phases
build_phases.select { |build_phase| build_phase.display_name.include? "[SPI]" }
end
end

class RunnerParserTest < TestCase
Expand Down Expand Up @@ -298,6 +302,30 @@ def test_runner_idempotent
end
end

def test_runner_with_resettable_flags
copy_empty_project_to_tmp_folder do |project_path|
runner = Runner.new(project_path, './test/fixtures/execution_with_resettable_flags.yaml', LOGGER)
runner.run

my_script_phase = runner.project.ft_main_target.ft_spinjector_build_phases.first
refute_nil my_script_phase

assert_equal my_script_phase.show_env_vars_in_log, '0'
assert_equal my_script_phase.always_out_of_date, '1'

copy_empty_project_to_tmp_folder(File.dirname(project_path)) do |new_project_path|
runner = Runner.new(new_project_path, './test/fixtures/execution_without_resettable_flags.yaml', LOGGER)
runner.run

my_script_phase_flag_resetted = runner.project.ft_main_target.ft_spinjector_build_phases.first
refute_nil my_script_phase_flag_resetted

assert_equal my_script_phase_flag_resetted.show_env_vars_in_log, nil
assert_equal my_script_phase_flag_resetted.always_out_of_date, nil
end
end
end

# Private

def copy_empty_project_to_tmp_folder(source = nil)
Expand Down

0 comments on commit 946c93e

Please sign in to comment.