bozo-scripts 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 -234
- data/lib/bozo/test_runners/nunit.rb +165 -160
- data/lib/bozo/test_runners/nunit3.rb +94 -94
- data/lib/bozo/tools/octopustools.rb +47 -47
- data/lib/bozo_scripts.rb +38 -38
- metadata +3 -3
@@ -1,161 +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 =
|
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
|
122
|
-
end
|
123
|
-
}
|
124
|
-
threads.push(t)
|
125
|
-
end
|
126
|
-
|
127
|
-
threads.each(&:join)
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
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
|
+
|
161
166
|
end
|
@@ -1,95 +1,95 @@
|
|
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 to_s
|
23
|
-
"Run tests with nunit3 against projects #{@projects}"
|
24
|
-
end
|
25
|
-
|
26
|
-
# Returns the path to the runner's executable.
|
27
|
-
#
|
28
|
-
# @returns [String]
|
29
|
-
def runner_path
|
30
|
-
exe_name = 'nunit3-console.exe'
|
31
|
-
|
32
|
-
nunit_runners = expand_and_glob('packages', 'NUnit*', 'tools', exe_name)
|
33
|
-
raise nunit_runner_not_found if nunit_runners.empty?
|
34
|
-
raise multiple_runners_found if nunit_runners.size > 1
|
35
|
-
|
36
|
-
nunit_runner = nunit_runners.first
|
37
|
-
|
38
|
-
log_debug "Found runner at #{nunit_runner}"
|
39
|
-
|
40
|
-
nunit_runner
|
41
|
-
end
|
42
|
-
|
43
|
-
# Returns the arguments required for the runner's executable.
|
44
|
-
#
|
45
|
-
# @returns [Array]
|
46
|
-
def runner_args
|
47
|
-
args = []
|
48
|
-
|
49
|
-
@projects.each do |project|
|
50
|
-
expand_and_glob('temp', 'msbuild', project, '**', "#{project}.dll").each do |test_dll|
|
51
|
-
args << "\"#{test_dll}\""
|
52
|
-
end
|
53
|
-
end
|
54
|
-
args << '--noheader'
|
55
|
-
|
56
|
-
if @platform == 'x86'
|
57
|
-
args << '--x86'
|
58
|
-
end
|
59
|
-
|
60
|
-
report_path = @report_path
|
61
|
-
report_path = expand_path('temp', 'nunit', "#{Time.now.to_i}-nunit-report.xml") unless report_path
|
62
|
-
|
63
|
-
# Ensure the directory is there because NUnit won't make it
|
64
|
-
FileUtils.mkdir_p File.dirname(report_path)
|
65
|
-
|
66
|
-
args << "--result=\"#{report_path}\""
|
67
|
-
|
68
|
-
args
|
69
|
-
end
|
70
|
-
|
71
|
-
def execute
|
72
|
-
execute_command :nunit, [runner_path] << runner_args
|
73
|
-
end
|
74
|
-
|
75
|
-
private
|
76
|
-
|
77
|
-
def nunit_runner_not_found
|
78
|
-
Bozo::ConfigurationError.new 'No NUnit runners found. You must install one via nuget.'
|
79
|
-
end
|
80
|
-
|
81
|
-
def multiple_runners_found
|
82
|
-
Bozo::ConfigurationError.new 'Multiple NUnit runners found. There should only be one.'
|
83
|
-
end
|
84
|
-
|
85
|
-
def expand_path(*args)
|
86
|
-
File.expand_path(File.join(args))
|
87
|
-
end
|
88
|
-
|
89
|
-
def expand_and_glob(*args)
|
90
|
-
Dir[expand_path(*args)]
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
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 to_s
|
23
|
+
"Run tests with nunit3 against projects #{@projects}"
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the path to the runner's executable.
|
27
|
+
#
|
28
|
+
# @returns [String]
|
29
|
+
def runner_path
|
30
|
+
exe_name = 'nunit3-console.exe'
|
31
|
+
|
32
|
+
nunit_runners = expand_and_glob('packages', 'NUnit*', 'tools', exe_name)
|
33
|
+
raise nunit_runner_not_found if nunit_runners.empty?
|
34
|
+
raise multiple_runners_found if nunit_runners.size > 1
|
35
|
+
|
36
|
+
nunit_runner = nunit_runners.first
|
37
|
+
|
38
|
+
log_debug "Found runner at #{nunit_runner}"
|
39
|
+
|
40
|
+
nunit_runner
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns the arguments required for the runner's executable.
|
44
|
+
#
|
45
|
+
# @returns [Array]
|
46
|
+
def runner_args
|
47
|
+
args = []
|
48
|
+
|
49
|
+
@projects.each do |project|
|
50
|
+
expand_and_glob('temp', 'msbuild', project, '**', "#{project}.dll").each do |test_dll|
|
51
|
+
args << "\"#{test_dll}\""
|
52
|
+
end
|
53
|
+
end
|
54
|
+
args << '--noheader'
|
55
|
+
|
56
|
+
if @platform == 'x86'
|
57
|
+
args << '--x86'
|
58
|
+
end
|
59
|
+
|
60
|
+
report_path = @report_path
|
61
|
+
report_path = expand_path('temp', 'nunit', "#{Time.now.to_i}-nunit-report.xml") unless report_path
|
62
|
+
|
63
|
+
# Ensure the directory is there because NUnit won't make it
|
64
|
+
FileUtils.mkdir_p File.dirname(report_path)
|
65
|
+
|
66
|
+
args << "--result=\"#{report_path}\""
|
67
|
+
|
68
|
+
args
|
69
|
+
end
|
70
|
+
|
71
|
+
def execute
|
72
|
+
execute_command :nunit, [runner_path] << runner_args
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def nunit_runner_not_found
|
78
|
+
Bozo::ConfigurationError.new 'No NUnit runners found. You must install one via nuget.'
|
79
|
+
end
|
80
|
+
|
81
|
+
def multiple_runners_found
|
82
|
+
Bozo::ConfigurationError.new 'Multiple NUnit runners found. There should only be one.'
|
83
|
+
end
|
84
|
+
|
85
|
+
def expand_path(*args)
|
86
|
+
File.expand_path(File.join(args))
|
87
|
+
end
|
88
|
+
|
89
|
+
def expand_and_glob(*args)
|
90
|
+
Dir[expand_path(*args)]
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
95
|
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
|