From c7ab17c51e265d283f4ed76027925d591d645ce7 Mon Sep 17 00:00:00 2001 From: Nicolae Ghimbovschi Date: Wed, 23 Sep 2015 04:58:44 +0300 Subject: [PATCH 1/2] Added buildlog_path option to change the location of the xcodebuild logs --- lib/gym/generators/build_command_generator.rb | 4 +++- lib/gym/options.rb | 5 +++++ spec/build_command_generator_spec.rb | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/gym/generators/build_command_generator.rb b/lib/gym/generators/build_command_generator.rb index 43b02dc..0ef5992 100644 --- a/lib/gym/generators/build_command_generator.rb +++ b/lib/gym/generators/build_command_generator.rb @@ -68,7 +68,9 @@ def pipe def xcodebuild_log_path file_name = "#{Gym.project.app_name}-#{Gym.config[:scheme]}.log" - containing = File.expand_path("~/Library/Logs/gym") + file_dir = Gym.config[:buildlog_path] + file_dir ||= "~/Library/Logs/gym" + containing = File.expand_path(file_dir) FileUtils.mkdir_p(containing) return File.join(containing, file_name) diff --git a/lib/gym/options.rb b/lib/gym/options.rb index 34ffbde..e04b79b 100644 --- a/lib/gym/options.rb +++ b/lib/gym/options.rb @@ -63,6 +63,11 @@ def self.plain_options verify_block: proc do |value| value.gsub!(".ipa", "") end), + FastlaneCore::ConfigItem.new(key: :buildlog_path, + short_option: "-l", + env_name: "GYM_BUILDLOG_PATH", + description: "The directory were to store the build log", + optional: true), FastlaneCore::ConfigItem.new(key: :sdk, short_option: "-k", env_name: "GYM_SDK", diff --git a/spec/build_command_generator_spec.rb b/spec/build_command_generator_spec.rb index 067b392..27ef922 100644 --- a/spec/build_command_generator_spec.rb +++ b/spec/build_command_generator_spec.rb @@ -71,6 +71,18 @@ regex = %r{Library/Developer/Xcode/Archives/\d\d\d\d\-\d\d\-\d\d/ExampleProductName \d\d\d\d\-\d\d\-\d\d \d\d\.\d\d\.\d\d.xcarchive} expect(result).to match(regex) end + + it "#buildlog_path is used when provided" do + options = { project: "./examples/standard/Example.xcodeproj", buildlog_path: "/tmp/my/path" } + Gym.config = FastlaneCore::Configuration.create(Gym::Options.available_options, options) + result = Gym::BuildCommandGenerator.xcodebuild_log_path + expect(result).to include("/tmp/my/path") + end + + it "#buildlog_path is not used when not provided" do + result = Gym::BuildCommandGenerator.xcodebuild_log_path + expect(result.to_s).to include("Library/Logs/gym") + end end end end From e9ba16a98c82ce88692c776b871fae9aecd9d6e4 Mon Sep 17 00:00:00 2001 From: Nicolae Ghimbovschi Date: Wed, 23 Sep 2015 05:37:23 +0300 Subject: [PATCH 2/2] Simplified the buildlog_path implementation --- lib/gym/generators/build_command_generator.rb | 4 +--- lib/gym/options.rb | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/gym/generators/build_command_generator.rb b/lib/gym/generators/build_command_generator.rb index 0ef5992..60d70e4 100644 --- a/lib/gym/generators/build_command_generator.rb +++ b/lib/gym/generators/build_command_generator.rb @@ -68,9 +68,7 @@ def pipe def xcodebuild_log_path file_name = "#{Gym.project.app_name}-#{Gym.config[:scheme]}.log" - file_dir = Gym.config[:buildlog_path] - file_dir ||= "~/Library/Logs/gym" - containing = File.expand_path(file_dir) + containing = File.expand_path(Gym.config[:buildlog_path]) FileUtils.mkdir_p(containing) return File.join(containing, file_name) diff --git a/lib/gym/options.rb b/lib/gym/options.rb index e04b79b..6b1eea2 100644 --- a/lib/gym/options.rb +++ b/lib/gym/options.rb @@ -67,7 +67,7 @@ def self.plain_options short_option: "-l", env_name: "GYM_BUILDLOG_PATH", description: "The directory were to store the build log", - optional: true), + default_value: "~/Library/Logs/gym"), FastlaneCore::ConfigItem.new(key: :sdk, short_option: "-k", env_name: "GYM_SDK",