Class: Fastlane::Maestro::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/maestro/helper/runner.rb

Class Method Summary collapse

Class Method Details

.command?(name) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
57
# File 'lib/fastlane/plugin/maestro/helper/runner.rb', line 54

def self.command?(name)
  `which #{name}`
  $?.success?
end

.download_samplesObject



47
48
49
50
51
52
# File 'lib/fastlane/plugin/maestro/helper/runner.rb', line 47

def self.download_samples
  maestro_path = ENV["HOME"] + "/.maestro/bin/maestro"
  Dir.chdir(ENV["PWD"]) do
    system("#{maestro_path} download-samples", out: $stdout, err: :out, exception: true)
  end
end

.installObject



43
44
45
# File 'lib/fastlane/plugin/maestro/helper/runner.rb', line 43

def self.install
  system("curl -Ls 'https://get.maestro.mobile.dev' | bash", out: $stdout, err: :out, exception: true)
end

.run(options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fastlane/plugin/maestro/helper/runner.rb', line 8

def self.run(options)
  # TODO: add possibility to specify maestro path
  maestro_path = ENV["HOME"] + "/.maestro/bin/maestro"

  command = [maestro_path]

  unless options[:device].empty? || options[:device].nil?
    command.push("--device", options[:device])
  end

  command.push("test")

  unless options[:report_type].empty? || options[:report_type].nil?
    command.push("--format", options[:report_type])
  end
  unless options[:output].empty? || options[:output].nil?
    command.push("--output", options[:output])
    # Make sure that the output folder is available
    FileUtils.mkdir_p(File.dirname(options[:output]))
  end
  unless options[:env_vars].nil? || options[:env_vars].empty?
    options[:env_vars].each do |key, value|
      command.push("-e", "#{key}=#{value}")
    end
  end

  command.push("#{options[:tests]}")
  command_string = command.join(" ")
  UI.message("Running command: #{command_string}")
  Dir.chdir(ENV["PWD"]) do
    # TODO: set exception based on parameter `failRun`
    system(command_string, out: $stdout, err: :out, exception: true)
  end
end