Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

When parsing output to get build directory, be oblivious to whether t…

…he directory path is quoted.
  • Loading branch information...
commit 87afb2a8d2e990d73d89fe58b7cf3280b52ba573 1 parent 76f0621
@techbelly techbelly authored
Showing with 55 additions and 11 deletions.
  1. +3 −11 lib/beta_builder.rb
  2. +52 −0 lib/beta_builder/build_output_parser.rb
View
14 lib/beta_builder.rb
@@ -4,6 +4,7 @@
require 'cfpropertylist'
require 'beta_builder/archived_build'
require 'beta_builder/deployment_strategies'
+require 'beta_builder/build_output_parser'
module BetaBuilder
class Tasks < ::Rake::TaskLib
@@ -84,17 +85,8 @@ def built_app_path
end
def derived_build_dir_from_build_output
- output = File.read("build.output")
-
- # yes, this is truly horrible, but unless somebody else can find a better way...
- found = output.split("\n").grep(/^Validate(.*)\/Xcode\/DerivedData\/(.*)-(.*)/).first
- if found && found =~ /Validate \"(.*)\"/
- reference = $1
- else
- raise "Cannot parse build_dir from build output."
- end
- derived_data_directory = reference.split("/Build/Products/").first
- "#{derived_data_directory}/Build/Products/"
+ output = BuildOutputParser.new(File.read("build.output"))
+ output.build_output_dir
end
def built_app_dsym_path
View
52 lib/beta_builder/build_output_parser.rb
@@ -0,0 +1,52 @@
+module BetaBuilder
+ class BuildOutputParser
+
+ def initialize(output)
+ @output = output
+ end
+
+ def build_output_dir
+ # yes, this is truly horrible, but unless somebody else can find a better way...
+ found = @output.split("\n").grep(/^Validate(.*)\/Xcode\/DerivedData\/(.*)-(.*)/).first
+ if found && found =~ /Validate [\"]?([^\"|$]*)/
+ reference = $1
+ else
+ raise "Cannot parse build_dir from build output."
+ end
+ derived_data_directory = reference.split("/Build/Products/").first
+ "#{derived_data_directory}/Build/Products/"
+ end
+ end
+end
+
+# quick testing
+if __FILE__ == $0
+
+require 'test/unit'
+class BuildOutputTest < Test::Unit::TestCase
+
+ def test_parses_output_with_unquoted_build_path
+ bop = BetaBuilder::BuildOutputParser.new(<<eos)
+Validate /Users/johnsmith/Library/Developer/Xcode/DerivedData/Application-hegpgdbpjylesafhkxnsymrzjavl/Build/Products/Distribution-iphoneos/Application.app
+ cd /Users/user/app/ios
+ setenv PATH \"/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin\"
+ setenv PRODUCT_TYPE com.apple.product-type.application
+ /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/Validation /Users/user/Library/Developer/Xcode/DerivedData/Application-hegpgdbpjylesafhkxnsymrzjavl/Build/Products/Distribution-iphoneos/Application.app
+eos
+ assert_equal "/Users/johnsmith/Library/Developer/Xcode/DerivedData/Application-hegpgdbpjylesafhkxnsymrzjavl/Build/Products/", bop.build_output_dir
+ end
+
+ def test_parses_output_with_quoted_build_path
+ bop = BetaBuilder::BuildOutputParser.new(<<eos)
+Validate \"/Users/john smith/Library/Developer/Xcode/DerivedData/Application-hegpgdbpjylesafhkxnsymrzjavl/Build/Products/Distribution-iphoneos/Application.app\"
+ cd /Users/user/app/ios
+ setenv PATH \"/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin\"
+ setenv PRODUCT_TYPE com.apple.product-type.application
+ /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/Validation /Users/user/Library/Developer/Xcode/DerivedData/Application-hegpgdbpjylesafhkxnsymrzjavl/Build/Products/Distribution-iphoneos/Application.app
+eos
+ assert_equal "/Users/john smith/Library/Developer/Xcode/DerivedData/Application-hegpgdbpjylesafhkxnsymrzjavl/Build/Products/", bop.build_output_dir
+ end
+
+end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.