forked from olegoid/xamarin-touch-unit-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
step.rb
67 lines (57 loc) · 1.65 KB
/
step.rb
1
2
3
4
5
6
7
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require 'optparse'
require 'fileutils'
require 'tmpdir'
require 'find'
require_relative 'xamarin-builder/builder'
# -----------------------
# --- Functions
# -----------------------
def fail_with_message(message)
puts "\e[31m#{message}\e[0m"
exit(1)
end
def error_with_message(message)
puts "\e[31m#{message}\e[0m"
end
# -----------------------
# --- Main
# -----------------------
#
# Parse options
options = {
solution: nil,
configuration: nil,
platform: nil
}
parser = OptionParser.new do |opts|
opts.banner = 'Usage: step.rb [options]'
opts.on('-s', '--solution path', 'Solution') { |s| options[:solution] = s unless s.to_s == '' }
opts.on('-c', '--configuration config', 'Configuration') { |c| options[:configuration] = c unless c.to_s == '' }
opts.on('-l', '--platform platform', 'Platform') { |l| options[:platform] = l unless l.to_s == '' }
opts.on('-h', '--help', 'Displays Help') do
exit
end
end
parser.parse!
#
# Print options
puts
puts '========== Configs =========='
puts " * solution: #{options[:solution]}"
puts " * configuration: #{options[:configuration]}"
puts " * platform: #{options[:platform]}"
#
# Validate options
fail_with_message("No solution file found at path: #{options[:solution]}") unless options[:solution] && File.exist?(options[:solution])
fail_with_message('No configuration environment found') unless options[:configuration]
#
# Main
builder = Builder.new(options[:solution], options[:configuration], options[:platform], nil)
begin
builder.run_nunit_lite_tests
rescue => ex
error_with_message(ex.inspect.to_s)
error_with_message('--- Stack trace: ---')
error_with_message(ex.backtrace.to_s)
exit(1)
end