Sha256: 45f8ca506e34748af1522a6d2dc089e43b2f792f9de00453e88ba3d0187ecd4c

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

# -*- encoding: utf-8 -*-

require 'xctest-runner/shell'

class XCTestRunner
  module BuildEnvironment
    include Shell

    def current_environment(build_command)
      env = {}
      settings = execute_command("#{build_command} -showBuildSettings test")
      settings.each_line do |line|
        if line.strip.start_with?('Build settings')
          break if env.include?('EXECUTABLE_FOLDER_PATH') && env['EXECUTABLE_FOLDER_PATH'].end_with?('.xctest')
        elsif line =~ /^\s(.*)=(.*)/
          variable, value = line.split('=')
          env[variable.strip] = value.strip
        end
      end
      env
    end

    def xcodebuild_list
      execute_command("xcodebuild -list")
    end

    def default_scheme
      unless @default_scheme
        scheme = nil
        is_scheme = false

        output = xcodebuild_list
        output.each_line do |line|
          line = line.strip
          if line =~ /\w+:/
            is_scheme = ('Schemes:' == line)
          elsif is_scheme
            scheme = line if scheme.nil? || line.end_with?('Tests')
          end
        end
        @default_scheme = scheme
      end
      @default_scheme
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xctest-runner-1.0.2 lib/xctest-runner/build-environment.rb
xctest-runner-1.0.1 lib/xctest-runner/build-environment.rb