boxen 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/boxen.gemspec +1 -1
- data/lib/boxen/cli.rb +2 -2
- data/lib/boxen/reporter.rb +13 -0
- data/test/boxen_cli_test.rb +35 -34
- data/test/boxen_config_test.rb +1 -1
- data/test/boxen_reporter_test.rb +59 -0
- metadata +4 -4
data/boxen.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "boxen"
|
5
|
-
gem.version = "0.4.
|
5
|
+
gem.version = "0.4.1"
|
6
6
|
gem.authors = ["John Barnette", "Will Farrington"]
|
7
7
|
gem.email = ["jbarnette@github.com", "wfarr@github.com"]
|
8
8
|
gem.description = "Manage Mac development boxes with love (and Puppet)."
|
data/lib/boxen/cli.rb
CHANGED
@@ -119,8 +119,8 @@ module Boxen
|
|
119
119
|
|
120
120
|
# Okay, we're gonna run Puppet. Let's make some dirs.
|
121
121
|
|
122
|
-
Boxen::Util.sudo("mkdir", "-p", config.homedir) &&
|
123
|
-
Boxen::Util.sudo("chown", "#{config.user}:staff", config.homedir)
|
122
|
+
Boxen::Util.sudo("/bin/mkdir", "-p", config.homedir) &&
|
123
|
+
Boxen::Util.sudo("/usr/sbin/chown", "#{config.user}:staff", config.homedir)
|
124
124
|
|
125
125
|
# Save the config for Puppet (and next time).
|
126
126
|
|
data/lib/boxen/reporter.rb
CHANGED
@@ -32,12 +32,16 @@ module Boxen
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def record_failure
|
35
|
+
return unless issues?
|
36
|
+
|
35
37
|
title = "Failed for #{config.user}"
|
36
38
|
config.api.create_issue(config.reponame, title, failure_details,
|
37
39
|
:labels => [failure_label])
|
38
40
|
end
|
39
41
|
|
40
42
|
def close_failures
|
43
|
+
return unless issues?
|
44
|
+
|
41
45
|
comment = "Succeeded at version #{checkout.sha}."
|
42
46
|
failures.each do |issue|
|
43
47
|
config.api.add_comment(config.reponame, issue.number, comment)
|
@@ -46,6 +50,8 @@ module Boxen
|
|
46
50
|
end
|
47
51
|
|
48
52
|
def failures
|
53
|
+
return [] unless issues?
|
54
|
+
|
49
55
|
issues = config.api.list_issues(config.reponame, :state => 'open',
|
50
56
|
:labels => failure_label, :creator => config.login)
|
51
57
|
issues.reject! {|i| i.labels.collect(&:name).include?(ongoing_label)}
|
@@ -86,5 +92,12 @@ module Boxen
|
|
86
92
|
@ongoing_label ||= 'ongoing'
|
87
93
|
end
|
88
94
|
attr_writer :ongoing_label
|
95
|
+
|
96
|
+
def issues?
|
97
|
+
return unless config.reponame
|
98
|
+
return if config.reponame == 'boxen/our-boxen'
|
99
|
+
|
100
|
+
config.api.repository(config.reponame).has_issues
|
101
|
+
end
|
89
102
|
end
|
90
103
|
end
|
data/test/boxen_cli_test.rb
CHANGED
@@ -133,6 +133,7 @@ class BoxenCLITest < Boxen::Test
|
|
133
133
|
Dir.expects(:[]).with("/Library/LaunchDaemons/com.boxen.*.plist").returns([
|
134
134
|
"/Library/LaunchDaemons/com.boxen.test.plist"
|
135
135
|
])
|
136
|
+
|
136
137
|
Boxen::Util.expects(:sudo).with(
|
137
138
|
"/bin/launchctl",
|
138
139
|
"unload",
|
@@ -143,40 +144,40 @@ class BoxenCLITest < Boxen::Test
|
|
143
144
|
assert_raises(SystemExit) do
|
144
145
|
cli.process
|
145
146
|
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_enable_services
|
150
|
+
config = Boxen::Config.new
|
151
|
+
flags = Boxen::Flags.new('--enable-services')
|
152
|
+
cli = Boxen::CLI.new config, flags
|
153
|
+
|
154
|
+
Dir.expects(:[]).with("/Library/LaunchDaemons/com.boxen.*.plist").returns([
|
155
|
+
"/Library/LaunchDaemons/com.boxen.test.plist"
|
156
|
+
])
|
157
|
+
|
158
|
+
Boxen::Util.expects(:sudo).with(
|
159
|
+
"/bin/launchctl",
|
160
|
+
"load",
|
161
|
+
"-w",
|
162
|
+
"/Library/LaunchDaemons/com.boxen.test.plist"
|
163
|
+
).returns(true)
|
146
164
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
assert_raises(SystemExit) do
|
164
|
-
cli.process
|
165
|
-
end
|
166
|
-
|
167
|
-
def test_list_services
|
168
|
-
config = Boxen::Config.new
|
169
|
-
flags = Boxen::Flags.new('--list-services')
|
170
|
-
cli = Boxen::CLI.new config, flags
|
171
|
-
|
172
|
-
Dir.expects(:[]).with("/Library/LaunchDaemons/com.boxen.*.plist").returns([
|
173
|
-
"/Library/LaunchDaemons/com.boxen.test.plist"
|
174
|
-
])
|
175
|
-
|
176
|
-
assert_raises(SystemExit) do
|
177
|
-
cli.process
|
178
|
-
end
|
179
|
-
end
|
165
|
+
assert_raises(SystemExit) do
|
166
|
+
cli.process
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_list_services
|
171
|
+
config = Boxen::Config.new
|
172
|
+
flags = Boxen::Flags.new('--list-services')
|
173
|
+
cli = Boxen::CLI.new config, flags
|
174
|
+
|
175
|
+
Dir.expects(:[]).with("/Library/LaunchDaemons/com.boxen.*.plist").returns([
|
176
|
+
"/Library/LaunchDaemons/com.boxen.test.plist"
|
177
|
+
])
|
178
|
+
|
179
|
+
assert_raises(SystemExit) do
|
180
|
+
cli.process
|
180
181
|
end
|
181
182
|
end
|
182
|
-
end
|
183
|
+
end
|
data/test/boxen_config_test.rb
CHANGED
data/test/boxen_reporter_test.rb
CHANGED
@@ -49,6 +49,8 @@ class BoxenReporterTest < Boxen::Test
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_record_failure
|
52
|
+
@reporter.stubs(:issues?).returns(true)
|
53
|
+
|
52
54
|
details = 'Everything went wrong.'
|
53
55
|
@reporter.stubs(:failure_details).returns(details)
|
54
56
|
|
@@ -63,6 +65,15 @@ class BoxenReporterTest < Boxen::Test
|
|
63
65
|
@reporter.record_failure
|
64
66
|
end
|
65
67
|
|
68
|
+
def test_record_failure_no_issues
|
69
|
+
@reporter.stubs(:issues?).returns(false)
|
70
|
+
|
71
|
+
@config.api = api = mock('api')
|
72
|
+
api.expects(:create_issue).never
|
73
|
+
|
74
|
+
@reporter.record_failure
|
75
|
+
end
|
76
|
+
|
66
77
|
def test_failure_label
|
67
78
|
default = 'failure'
|
68
79
|
assert_equal default, @reporter.failure_label
|
@@ -139,6 +150,8 @@ class BoxenReporterTest < Boxen::Test
|
|
139
150
|
Label = Struct.new(:name)
|
140
151
|
|
141
152
|
def test_close_failures
|
153
|
+
@reporter.stubs(:issues?).returns(true)
|
154
|
+
|
142
155
|
@config.reponame = repo = 'some/repo'
|
143
156
|
|
144
157
|
issues = Array.new(3) { |i| Issue.new(i*2 + 2) }
|
@@ -156,7 +169,21 @@ class BoxenReporterTest < Boxen::Test
|
|
156
169
|
@reporter.close_failures
|
157
170
|
end
|
158
171
|
|
172
|
+
def test_close_failures_no_issues
|
173
|
+
@reporter.stubs(:issues?).returns(false)
|
174
|
+
|
175
|
+
@reporter.expects(:failures).never
|
176
|
+
|
177
|
+
@config.api = api = mock('api')
|
178
|
+
api.expects(:add_comment).never
|
179
|
+
api.expects(:close_issue).never
|
180
|
+
|
181
|
+
@reporter.close_failures
|
182
|
+
end
|
183
|
+
|
159
184
|
def test_failures
|
185
|
+
@reporter.stubs(:issues?).returns(true)
|
186
|
+
|
160
187
|
@config.reponame = repo = 'some/repo'
|
161
188
|
@config.login = user = 'hapless'
|
162
189
|
|
@@ -180,4 +207,36 @@ class BoxenReporterTest < Boxen::Test
|
|
180
207
|
|
181
208
|
assert_equal issues.values_at(0,1,3), @reporter.failures
|
182
209
|
end
|
210
|
+
|
211
|
+
def test_failures_no_issues
|
212
|
+
@reporter.stubs(:issues?).returns(false)
|
213
|
+
|
214
|
+
@config.api = api = mock('api')
|
215
|
+
api.expects(:list_issues).never
|
216
|
+
|
217
|
+
assert_equal [], @reporter.failures
|
218
|
+
end
|
219
|
+
|
220
|
+
RepoInfo = Struct.new(:has_issues)
|
221
|
+
def test_issues?
|
222
|
+
@config.reponame = repo = 'some/repo'
|
223
|
+
|
224
|
+
repo_info = RepoInfo.new(true)
|
225
|
+
|
226
|
+
@config.api = api = mock('api')
|
227
|
+
api.stubs(:repository).with(repo).returns(repo_info)
|
228
|
+
assert @reporter.issues?
|
229
|
+
|
230
|
+
repo_info = RepoInfo.new(false)
|
231
|
+
api.stubs(:repository).with(repo).returns(repo_info)
|
232
|
+
refute @reporter.issues?
|
233
|
+
|
234
|
+
@config.stubs(:reponame) # to ensure the returned value is nil
|
235
|
+
api.stubs(:repository).returns(RepoInfo.new(true))
|
236
|
+
refute @reporter.issues?
|
237
|
+
|
238
|
+
@config.stubs(:reponame).returns('boxen/our-boxen') # our main public repo
|
239
|
+
api.stubs(:repository).returns(RepoInfo.new(true))
|
240
|
+
refute @reporter.issues?
|
241
|
+
end
|
183
242
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boxen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 1
|
10
|
+
version: 0.4.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Barnette
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-10-
|
19
|
+
date: 2012-10-10 00:00:00 -10:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|