Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #30 from weathermob/master

Handle quoted and unquoted directory paths in output
  • Loading branch information...
commit 38b0c9581e226d8972db8a19e5498ea53dd5fae7 2 parents 76f0621 + 87afb2a
@lukeredpath 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.