bozo-scripts 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/VERSION +1 -1
- data/lib/bozo/hooks/octopus_create_release.rb +67 -67
- data/lib/bozo/packagers/nuget.rb +257 -257
- data/lib/bozo/test_runners/nunit.rb +165 -165
- data/lib/bozo/test_runners/nunit3.rb +102 -94
- data/lib/bozo/tools/octopustools.rb +47 -47
- data/lib/bozo_scripts.rb +38 -38
- metadata +3 -3
@@ -1,166 +1,166 @@
|
|
1
|
-
module Bozo::TestRunners
|
2
|
-
|
3
|
-
# A TestRunner for NUnit
|
4
|
-
# By default the x64 runner is used. If you want to use a different
|
5
|
-
# platform runner then set the platform, e.g. 'x86'.
|
6
|
-
#
|
7
|
-
# == Dotcover integration
|
8
|
-
# To enable integration with the dotcover test runner the following
|
9
|
-
# interface needs to be used
|
10
|
-
#
|
11
|
-
# runner_path # should return the path to the runners executable
|
12
|
-
# runner_args # should return the arguments to be passed to use
|
13
|
-
class Nunit
|
14
|
-
|
15
|
-
def initialize
|
16
|
-
@projects = []
|
17
|
-
@include = []
|
18
|
-
@exclude = []
|
19
|
-
@execute_in_parallel = false
|
20
|
-
end
|
21
|
-
|
22
|
-
def destination(destination)
|
23
|
-
@destination = destination
|
24
|
-
end
|
25
|
-
|
26
|
-
def platform(platform)
|
27
|
-
@platform = platform
|
28
|
-
end
|
29
|
-
|
30
|
-
def project(path)
|
31
|
-
@projects << path
|
32
|
-
end
|
33
|
-
|
34
|
-
def report_path(path)
|
35
|
-
@report_path = path
|
36
|
-
end
|
37
|
-
|
38
|
-
def coverage(coverage)
|
39
|
-
@coverage = coverage
|
40
|
-
end
|
41
|
-
|
42
|
-
def include(include)
|
43
|
-
cannot_define_both_include_and_exclude_categories if @exclude.any?
|
44
|
-
@include << include
|
45
|
-
end
|
46
|
-
|
47
|
-
def exclude(exclude)
|
48
|
-
cannot_define_both_include_and_exclude_categories if @include.any?
|
49
|
-
@exclude << exclude
|
50
|
-
end
|
51
|
-
|
52
|
-
def execute_in_parallel
|
53
|
-
@execute_in_parallel = true
|
54
|
-
end
|
55
|
-
|
56
|
-
def to_s
|
57
|
-
"Run tests with nunit against projects #{@projects}"
|
58
|
-
end
|
59
|
-
|
60
|
-
# Returns the path to the runner's executable.
|
61
|
-
#
|
62
|
-
# @returns [String]
|
63
|
-
def runner_path
|
64
|
-
exe_name = "nunit-console.exe"
|
65
|
-
|
66
|
-
if defined? @platform
|
67
|
-
log_debug "Looking for runner with #@platform platform"
|
68
|
-
exe_name = "nunit-console-#@platform.exe"
|
69
|
-
end
|
70
|
-
|
71
|
-
nunit_runners = expand_and_glob('packages', 'NUnit*', 'tools', exe_name)
|
72
|
-
raise nunit_runner_not_found if nunit_runners.empty?
|
73
|
-
raise multiple_runners_found if nunit_runners.size > 1
|
74
|
-
|
75
|
-
nunit_runner = nunit_runners.first
|
76
|
-
|
77
|
-
log_debug "Found runner at #{nunit_runner}"
|
78
|
-
|
79
|
-
nunit_runner
|
80
|
-
end
|
81
|
-
|
82
|
-
# Returns the arguments required for the runner's executable.
|
83
|
-
#
|
84
|
-
# @returns [Array]
|
85
|
-
def runner_args(projects = nil, report_prefix = nil)
|
86
|
-
projects = @projects if projects.nil?
|
87
|
-
report_prefix = Time.now.to_i if report_prefix.nil?
|
88
|
-
|
89
|
-
args = []
|
90
|
-
|
91
|
-
projects.each do |project|
|
92
|
-
expand_and_glob('temp', 'msbuild', project, '**', "#{project}.dll").each do |test_dll|
|
93
|
-
args << "\"#{test_dll}\""
|
94
|
-
end
|
95
|
-
end
|
96
|
-
args << '/nologo'
|
97
|
-
|
98
|
-
report_path = @report_path
|
99
|
-
report_path = expand_path('temp', 'nunit', "#{report_prefix}-nunit-report.xml") unless report_path
|
100
|
-
|
101
|
-
# Ensure the directory is there because NUnit won't make it
|
102
|
-
FileUtils.mkdir_p File.dirname(report_path)
|
103
|
-
|
104
|
-
args << "/xml:\"#{report_path}\""
|
105
|
-
args << "/include:#{@include.join(',')}" if @include.any?
|
106
|
-
args << "/exclude:#{@exclude.join(',')}" if @exclude.any?
|
107
|
-
|
108
|
-
args
|
109
|
-
end
|
110
|
-
|
111
|
-
def execute
|
112
|
-
if @execute_in_parallel
|
113
|
-
failed_projects = Queue.new
|
114
|
-
threads = []
|
115
|
-
|
116
|
-
@projects.each do |project|
|
117
|
-
t = Thread.new {
|
118
|
-
begin
|
119
|
-
execute_command :nunit, [runner_path] << runner_args([project], "#{project}-#{Time.now.to_i}")
|
120
|
-
rescue
|
121
|
-
failed_projects.push(project)
|
122
|
-
end
|
123
|
-
}
|
124
|
-
threads.push(t)
|
125
|
-
end
|
126
|
-
|
127
|
-
threads.each(&:join)
|
128
|
-
|
129
|
-
failed = []
|
130
|
-
until failed_projects.empty?
|
131
|
-
failed << failed_projects.pop
|
132
|
-
end
|
133
|
-
|
134
|
-
if failed.length > 0
|
135
|
-
raise Bozo::ExecutionError.new(:nunit, [runner_path] << failed, 1)
|
136
|
-
end
|
137
|
-
else
|
138
|
-
execute_command :nunit, [runner_path] << runner_args
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
private
|
143
|
-
|
144
|
-
def nunit_runner_not_found
|
145
|
-
Bozo::ConfigurationError.new 'No NUnit runners found. You must install one via nuget.'
|
146
|
-
end
|
147
|
-
|
148
|
-
def multiple_runners_found
|
149
|
-
Bozo::ConfigurationError.new 'Multiple NUnit runners found. There should only be one.'
|
150
|
-
end
|
151
|
-
|
152
|
-
def expand_path(*args)
|
153
|
-
File.expand_path(File.join(args))
|
154
|
-
end
|
155
|
-
|
156
|
-
def expand_and_glob(*args)
|
157
|
-
Dir[expand_path(*args)]
|
158
|
-
end
|
159
|
-
|
160
|
-
def cannot_define_both_include_and_exclude_categories
|
161
|
-
raise Bozo::ConfigurationError.new 'Both include and exclude categories defined. You cannot specify both for nunit.'
|
162
|
-
end
|
163
|
-
|
164
|
-
end
|
165
|
-
|
1
|
+
module Bozo::TestRunners
|
2
|
+
|
3
|
+
# A TestRunner for NUnit
|
4
|
+
# By default the x64 runner is used. If you want to use a different
|
5
|
+
# platform runner then set the platform, e.g. 'x86'.
|
6
|
+
#
|
7
|
+
# == Dotcover integration
|
8
|
+
# To enable integration with the dotcover test runner the following
|
9
|
+
# interface needs to be used
|
10
|
+
#
|
11
|
+
# runner_path # should return the path to the runners executable
|
12
|
+
# runner_args # should return the arguments to be passed to use
|
13
|
+
class Nunit
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@projects = []
|
17
|
+
@include = []
|
18
|
+
@exclude = []
|
19
|
+
@execute_in_parallel = false
|
20
|
+
end
|
21
|
+
|
22
|
+
def destination(destination)
|
23
|
+
@destination = destination
|
24
|
+
end
|
25
|
+
|
26
|
+
def platform(platform)
|
27
|
+
@platform = platform
|
28
|
+
end
|
29
|
+
|
30
|
+
def project(path)
|
31
|
+
@projects << path
|
32
|
+
end
|
33
|
+
|
34
|
+
def report_path(path)
|
35
|
+
@report_path = path
|
36
|
+
end
|
37
|
+
|
38
|
+
def coverage(coverage)
|
39
|
+
@coverage = coverage
|
40
|
+
end
|
41
|
+
|
42
|
+
def include(include)
|
43
|
+
cannot_define_both_include_and_exclude_categories if @exclude.any?
|
44
|
+
@include << include
|
45
|
+
end
|
46
|
+
|
47
|
+
def exclude(exclude)
|
48
|
+
cannot_define_both_include_and_exclude_categories if @include.any?
|
49
|
+
@exclude << exclude
|
50
|
+
end
|
51
|
+
|
52
|
+
def execute_in_parallel
|
53
|
+
@execute_in_parallel = true
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_s
|
57
|
+
"Run tests with nunit against projects #{@projects}"
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns the path to the runner's executable.
|
61
|
+
#
|
62
|
+
# @returns [String]
|
63
|
+
def runner_path
|
64
|
+
exe_name = "nunit-console.exe"
|
65
|
+
|
66
|
+
if defined? @platform
|
67
|
+
log_debug "Looking for runner with #@platform platform"
|
68
|
+
exe_name = "nunit-console-#@platform.exe"
|
69
|
+
end
|
70
|
+
|
71
|
+
nunit_runners = expand_and_glob('packages', 'NUnit*', 'tools', exe_name)
|
72
|
+
raise nunit_runner_not_found if nunit_runners.empty?
|
73
|
+
raise multiple_runners_found if nunit_runners.size > 1
|
74
|
+
|
75
|
+
nunit_runner = nunit_runners.first
|
76
|
+
|
77
|
+
log_debug "Found runner at #{nunit_runner}"
|
78
|
+
|
79
|
+
nunit_runner
|
80
|
+
end
|
81
|
+
|
82
|
+
# Returns the arguments required for the runner's executable.
|
83
|
+
#
|
84
|
+
# @returns [Array]
|
85
|
+
def runner_args(projects = nil, report_prefix = nil)
|
86
|
+
projects = @projects if projects.nil?
|
87
|
+
report_prefix = Time.now.to_i if report_prefix.nil?
|
88
|
+
|
89
|
+
args = []
|
90
|
+
|
91
|
+
projects.each do |project|
|
92
|
+
expand_and_glob('temp', 'msbuild', project, '**', "#{project}.dll").each do |test_dll|
|
93
|
+
args << "\"#{test_dll}\""
|
94
|
+
end
|
95
|
+
end
|
96
|
+
args << '/nologo'
|
97
|
+
|
98
|
+
report_path = @report_path
|
99
|
+
report_path = expand_path('temp', 'nunit', "#{report_prefix}-nunit-report.xml") unless report_path
|
100
|
+
|
101
|
+
# Ensure the directory is there because NUnit won't make it
|
102
|
+
FileUtils.mkdir_p File.dirname(report_path)
|
103
|
+
|
104
|
+
args << "/xml:\"#{report_path}\""
|
105
|
+
args << "/include:#{@include.join(',')}" if @include.any?
|
106
|
+
args << "/exclude:#{@exclude.join(',')}" if @exclude.any?
|
107
|
+
|
108
|
+
args
|
109
|
+
end
|
110
|
+
|
111
|
+
def execute
|
112
|
+
if @execute_in_parallel
|
113
|
+
failed_projects = Queue.new
|
114
|
+
threads = []
|
115
|
+
|
116
|
+
@projects.each do |project|
|
117
|
+
t = Thread.new {
|
118
|
+
begin
|
119
|
+
execute_command :nunit, [runner_path] << runner_args([project], "#{project}-#{Time.now.to_i}")
|
120
|
+
rescue
|
121
|
+
failed_projects.push(project)
|
122
|
+
end
|
123
|
+
}
|
124
|
+
threads.push(t)
|
125
|
+
end
|
126
|
+
|
127
|
+
threads.each(&:join)
|
128
|
+
|
129
|
+
failed = []
|
130
|
+
until failed_projects.empty?
|
131
|
+
failed << failed_projects.pop
|
132
|
+
end
|
133
|
+
|
134
|
+
if failed.length > 0
|
135
|
+
raise Bozo::ExecutionError.new(:nunit, [runner_path] << failed, 1)
|
136
|
+
end
|
137
|
+
else
|
138
|
+
execute_command :nunit, [runner_path] << runner_args
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
private
|
143
|
+
|
144
|
+
def nunit_runner_not_found
|
145
|
+
Bozo::ConfigurationError.new 'No NUnit runners found. You must install one via nuget.'
|
146
|
+
end
|
147
|
+
|
148
|
+
def multiple_runners_found
|
149
|
+
Bozo::ConfigurationError.new 'Multiple NUnit runners found. There should only be one.'
|
150
|
+
end
|
151
|
+
|
152
|
+
def expand_path(*args)
|
153
|
+
File.expand_path(File.join(args))
|
154
|
+
end
|
155
|
+
|
156
|
+
def expand_and_glob(*args)
|
157
|
+
Dir[expand_path(*args)]
|
158
|
+
end
|
159
|
+
|
160
|
+
def cannot_define_both_include_and_exclude_categories
|
161
|
+
raise Bozo::ConfigurationError.new 'Both include and exclude categories defined. You cannot specify both for nunit.'
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
166
|
end
|
@@ -1,95 +1,103 @@
|
|
1
|
-
module Bozo::TestRunners
|
2
|
-
|
3
|
-
# A TestRunner for NUnit3
|
4
|
-
class Nunit3
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@projects = []
|
8
|
-
end
|
9
|
-
|
10
|
-
def platform(platform)
|
11
|
-
@platform = platform
|
12
|
-
end
|
13
|
-
|
14
|
-
def project(path)
|
15
|
-
@projects << path
|
16
|
-
end
|
17
|
-
|
18
|
-
def report_path(path)
|
19
|
-
@report_path = path
|
20
|
-
end
|
21
|
-
|
22
|
-
def
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
nunit_runner
|
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
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
def
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
def
|
90
|
-
|
91
|
-
end
|
92
|
-
|
93
|
-
|
94
|
-
|
1
|
+
module Bozo::TestRunners
|
2
|
+
|
3
|
+
# A TestRunner for NUnit3
|
4
|
+
class Nunit3
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@projects = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def platform(platform)
|
11
|
+
@platform = platform
|
12
|
+
end
|
13
|
+
|
14
|
+
def project(path)
|
15
|
+
@projects << path
|
16
|
+
end
|
17
|
+
|
18
|
+
def report_path(path)
|
19
|
+
@report_path = path
|
20
|
+
end
|
21
|
+
|
22
|
+
def agents(agents)
|
23
|
+
@agents = agents
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s
|
27
|
+
"Run tests with nunit3 against projects #{@projects}"
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns the path to the runner's executable.
|
31
|
+
#
|
32
|
+
# @returns [String]
|
33
|
+
def runner_path
|
34
|
+
exe_name = 'nunit3-console.exe'
|
35
|
+
|
36
|
+
nunit_runners = expand_and_glob('packages', 'NUnit*', 'tools', exe_name)
|
37
|
+
raise nunit_runner_not_found if nunit_runners.empty?
|
38
|
+
raise multiple_runners_found if nunit_runners.size > 1
|
39
|
+
|
40
|
+
nunit_runner = nunit_runners.first
|
41
|
+
|
42
|
+
log_debug "Found runner at #{nunit_runner}"
|
43
|
+
|
44
|
+
nunit_runner
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns the arguments required for the runner's executable.
|
48
|
+
#
|
49
|
+
# @returns [Array]
|
50
|
+
def runner_args
|
51
|
+
args = []
|
52
|
+
|
53
|
+
@projects.each do |project|
|
54
|
+
expand_and_glob('temp', 'msbuild', project, '**', "#{project}.dll").each do |test_dll|
|
55
|
+
args << "\"#{test_dll}\""
|
56
|
+
end
|
57
|
+
end
|
58
|
+
args << '--noheader'
|
59
|
+
|
60
|
+
if @platform == 'x86'
|
61
|
+
args << '--x86'
|
62
|
+
end
|
63
|
+
|
64
|
+
unless !agents || agents.empty?
|
65
|
+
args << "--agents=#{@agents}"
|
66
|
+
end
|
67
|
+
|
68
|
+
report_path = @report_path
|
69
|
+
report_path = expand_path('temp', 'nunit', "#{Time.now.to_i}-nunit-report.xml") unless report_path
|
70
|
+
|
71
|
+
# Ensure the directory is there because NUnit won't make it
|
72
|
+
FileUtils.mkdir_p File.dirname(report_path)
|
73
|
+
|
74
|
+
args << "--result=\"#{report_path}\""
|
75
|
+
|
76
|
+
args
|
77
|
+
end
|
78
|
+
|
79
|
+
def execute
|
80
|
+
execute_command :nunit, [runner_path] << runner_args
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def nunit_runner_not_found
|
86
|
+
Bozo::ConfigurationError.new 'No NUnit runners found. You must install one via nuget.'
|
87
|
+
end
|
88
|
+
|
89
|
+
def multiple_runners_found
|
90
|
+
Bozo::ConfigurationError.new 'Multiple NUnit runners found. There should only be one.'
|
91
|
+
end
|
92
|
+
|
93
|
+
def expand_path(*args)
|
94
|
+
File.expand_path(File.join(args))
|
95
|
+
end
|
96
|
+
|
97
|
+
def expand_and_glob(*args)
|
98
|
+
Dir[expand_path(*args)]
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
95
103
|
end
|
@@ -1,47 +1,47 @@
|
|
1
|
-
require 'open-uri'
|
2
|
-
require 'zip/zipfilesystem'
|
3
|
-
|
4
|
-
module Bozo::Tools
|
5
|
-
class OctopusTools
|
6
|
-
|
7
|
-
# Creates a new instance.
|
8
|
-
def initialize
|
9
|
-
@url = 'https://download.octopusdeploy.com/octopus-tools/3.3.2/OctopusTools.3.3.2.zip'
|
10
|
-
end
|
11
|
-
|
12
|
-
# Sets the source url for the Octopus Tools to be retrieved from
|
13
|
-
#
|
14
|
-
# @param [String] url
|
15
|
-
# A web server hosting the Octopus Tools
|
16
|
-
def source(url)
|
17
|
-
@url = url
|
18
|
-
end
|
19
|
-
|
20
|
-
# Retrieves the Octopus tools exe from the path
|
21
|
-
def retrieve(destination_path)
|
22
|
-
zip_file_path = download_path('OctopusTools.3.3.2.zip')
|
23
|
-
|
24
|
-
open(zip_file_path, 'wb') do |file|
|
25
|
-
file << open(@url).read
|
26
|
-
end
|
27
|
-
|
28
|
-
extract_zip(zip_file_path, destination_path)
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
def extract_zip(source, destination_path)
|
33
|
-
Zip::ZipFile.open(source) do |zip_file|
|
34
|
-
zip_file.each { |f|
|
35
|
-
f_path = File.join(destination_path, f.name)
|
36
|
-
FileUtils.mkdir_p(File.dirname(f_path))
|
37
|
-
zip_file.extract(f, f_path) unless File.exist?(f_path)
|
38
|
-
}
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def download_path(source_name)
|
43
|
-
FileUtils.mkdir_p('temp')
|
44
|
-
File.join('temp', source_name)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
1
|
+
require 'open-uri'
|
2
|
+
require 'zip/zipfilesystem'
|
3
|
+
|
4
|
+
module Bozo::Tools
|
5
|
+
class OctopusTools
|
6
|
+
|
7
|
+
# Creates a new instance.
|
8
|
+
def initialize
|
9
|
+
@url = 'https://download.octopusdeploy.com/octopus-tools/3.3.2/OctopusTools.3.3.2.zip'
|
10
|
+
end
|
11
|
+
|
12
|
+
# Sets the source url for the Octopus Tools to be retrieved from
|
13
|
+
#
|
14
|
+
# @param [String] url
|
15
|
+
# A web server hosting the Octopus Tools
|
16
|
+
def source(url)
|
17
|
+
@url = url
|
18
|
+
end
|
19
|
+
|
20
|
+
# Retrieves the Octopus tools exe from the path
|
21
|
+
def retrieve(destination_path)
|
22
|
+
zip_file_path = download_path('OctopusTools.3.3.2.zip')
|
23
|
+
|
24
|
+
open(zip_file_path, 'wb') do |file|
|
25
|
+
file << open(@url).read
|
26
|
+
end
|
27
|
+
|
28
|
+
extract_zip(zip_file_path, destination_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def extract_zip(source, destination_path)
|
33
|
+
Zip::ZipFile.open(source) do |zip_file|
|
34
|
+
zip_file.each { |f|
|
35
|
+
f_path = File.join(destination_path, f.name)
|
36
|
+
FileUtils.mkdir_p(File.dirname(f_path))
|
37
|
+
zip_file.extract(f, f_path) unless File.exist?(f_path)
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def download_path(source_name)
|
43
|
+
FileUtils.mkdir_p('temp')
|
44
|
+
File.join('temp', source_name)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|