ext 1.1.2 → 2.0.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.
@@ -1,353 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') if $0 == __FILE__
2
- $:.unshift File.join(File.dirname(__FILE__), 'support') if $0 == __FILE__
3
- require 'ext_test_case'
4
- require 'externals/ext'
5
- require 'rails_app_svn_branches'
6
-
7
- module Externals
8
- module Test
9
- class TestSvnBranches < ::Test::Unit::TestCase
10
- include ExtTestCase
11
-
12
- def test_checkout_with_subproject
13
- mode = "checkout"
14
- repository = RailsAppSvnBranches.new
15
- repository.prepare
16
-
17
- assert File.exists?(File.join(repository.clean_dir, "db"))
18
-
19
- workdir = File.join(root_dir, 'test', "tmp", "workdir", mode, "svn", "branches")
20
- mkdir_p workdir
21
-
22
- if File.exists?(File.join(workdir, "rails_app"))
23
- rm_r File.join(workdir, "rails_app")
24
- end
25
-
26
- Dir.chdir workdir do
27
- source = repository.clean_url
28
- if windows?
29
- source = source.gsub(/\\/, "/")
30
- end
31
-
32
- puts "About to #{mode} #{source}"
33
- Ext.run mode, "--svn", source, "-b", "current", 'rails_app'
34
-
35
- Dir.chdir 'rails_app' do
36
- assert File.exists?('.svn')
37
-
38
- %w(redhillonrails_core acts_as_list).each do |proj|
39
- ignore_text = `svn propget svn:ignore vendor/plugins`
40
- puts "ignore_text is:"
41
- puts ignore_text
42
- assert(ignore_text =~ /^#{proj}$/)
43
- end
44
-
45
- ignore_text = `svn propget svn:ignore vendor`
46
- assert(ignore_text =~ /^rails$/)
47
-
48
- %w(redhillonrails_core acts_as_list engines).each do |proj|
49
- assert File.exists?(File.join('vendor', 'plugins', proj, 'lib'))
50
- end
51
-
52
- assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
53
-
54
- assert File.exists?(File.join('vendor', 'rails', '.git'))
55
-
56
- assert File.exists?(File.join('modules', 'modules.txt'))
57
-
58
- assert File.read(File.join('modules', 'modules.txt')) =~ /line1 of/
59
-
60
- ext = Ext.new
61
- main_project = ext.main_project
62
- engines = ext.subproject("engines")
63
- modules = ext.subproject("modules")
64
-
65
- assert_equal "current", main_project.current_branch
66
-
67
- assert_equal "edge", engines.current_branch
68
- assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
69
-
70
- assert_equal "current", modules.current_branch
71
- assert_equal "current", ext.configuration["modules"]["branch"]
72
-
73
- assert !File.exists?(File.join(%w(vendor plugins ssl_requirement)))
74
- assert !File.exists?(File.join(%w(vendor plugins empty_plugin)))
75
-
76
- #let's run update. This can expose certain errors.
77
- Ext.run "update"
78
-
79
- `svn switch #{[source, "branches", "new_branch"].join("/")}`
80
- unless $? == 0
81
- raise
82
- end
83
-
84
- assert !File.exists?(File.join(%w(vendor plugins ssl_requirement)))
85
- assert !File.exists?(File.join(%w(vendor plugins empty_plugin)))
86
-
87
- assert !main_project.ignore_contains?("vendor/rails")
88
-
89
- ext = Ext.new
90
- main_project = ext.main_project
91
- engines = ext.subproject("engines")
92
- modules = ext.subproject("modules")
93
-
94
- assert_equal "branches/new_branch", main_project.current_branch
95
-
96
- assert_equal "edge", engines.current_branch
97
- assert_equal "branch1", ext.configuration["vendor/plugins/engines"]["branch"]
98
-
99
- assert_equal "current", modules.current_branch
100
- assert_equal "branches/branch2", ext.configuration["modules"]["branch"]
101
-
102
- Ext.run "up"
103
-
104
- assert File.exists?(File.join(%w(vendor plugins ssl_requirement)))
105
- assert File.exists?(File.join(%w(vendor plugins empty_plugin)))
106
-
107
- Dir.chdir File.join("vendor",'plugins', "ssl_requirement") do
108
- assert `git show HEAD` =~ /^\s*commit\s*#{
109
- repository.dependents[:ssl_requirement].attributes[:revision]
110
- }\s*$/i
111
- end
112
-
113
- assert_equal "branches/new_branch", main_project.current_branch
114
-
115
- assert_equal "branch1", engines.current_branch
116
- assert_equal "branch1", ext.configuration["vendor/plugins/engines"]["branch"]
117
-
118
- assert_equal "branches/branch2", modules.current_branch
119
- assert_equal "branches/branch2", ext.configuration["modules"]["branch"]
120
-
121
- assert File.read(File.join('modules', 'modules.txt')) =~
122
- /line 2 of modules.txt ... this is branch2!/
123
-
124
- #let's run update. This can expose certain errors.
125
- Ext.run "update"
126
-
127
- `svn switch #{[source, "current"].join("/")}`
128
- ext = Ext.new
129
- main_project = ext.main_project
130
- engines = ext.subproject("engines")
131
- modules = ext.subproject("modules")
132
-
133
- assert_equal "current", main_project.current_branch
134
-
135
- assert_equal "branch1", engines.current_branch
136
- assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
137
-
138
- assert_equal "branches/branch2", modules.current_branch
139
- assert_equal "current", ext.configuration["modules"]["branch"]
140
- assert File.read(File.join('modules', 'modules.txt')) =~
141
- /line 2 of modules.txt ... this is branch2!/
142
-
143
- Ext.run "up"
144
- ext = Ext.new
145
- main_project = ext.main_project
146
- engines = ext.subproject("engines")
147
- modules = ext.subproject("modules")
148
-
149
- assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
150
-
151
- assert File.exists?(File.join('vendor', 'rails', '.git'))
152
-
153
- assert_equal "current", main_project.current_branch
154
-
155
- assert_equal "edge", engines.current_branch
156
- assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
157
-
158
- assert_equal "current", modules.current_branch
159
- assert_equal "current", ext.configuration["modules"]["branch"]
160
- assert File.read(File.join('modules', 'modules.txt')) !~
161
- /line 2 of modules.txt ... this is branch2!/
162
- assert File.read(File.join('modules', 'modules.txt')) =~ /line1 of/
163
-
164
- assert main_project.ignore_contains?("vendor/rails")
165
-
166
- # let's test the switch command.
167
- capture = StringIO.new
168
- begin
169
- $stdout = capture
170
-
171
- Ext.run "switch", "branches/new_branch"
172
-
173
- ext = Ext.new
174
- main_project = ext.main_project
175
- engines = ext.subproject("engines")
176
- modules = ext.subproject("modules")
177
-
178
- ensure
179
- $stdout = STDOUT
180
- end
181
- capture = capture.string
182
-
183
- assert_equal "branches/new_branch", main_project.current_branch
184
-
185
- assert_equal "branch1", engines.current_branch
186
- assert_equal "branch1", ext.configuration["vendor/plugins/engines"]["branch"]
187
-
188
- assert_equal "branches/branch2", modules.current_branch
189
- assert_equal "branches/branch2", ext.configuration["modules"]["branch"]
190
-
191
- assert capture =~ /WARNING:/
192
- assert capture =~ /rm\s+-rf?\s+vendor.rails/
193
- assert capture.scan(/rm/).size == 1
194
-
195
- assert !main_project.ignore_contains?("vendor/rails")
196
-
197
- [
198
- %w(vendor rails),
199
- %w(vendor plugins ssl_requirement),
200
- %w(vendor plugins empty_plugin)
201
- ].each do |dir|
202
- rm_r File.join(*dir)
203
- unless $? == 0
204
- raise
205
- end
206
- end
207
-
208
- assert File.read(File.join('modules', 'modules.txt')) =~
209
- /line 2 of modules.txt ... this is branch2!/
210
-
211
- capture = StringIO.new
212
- begin
213
- $stdout = capture
214
-
215
- Ext.run "switch", "current"
216
- ext = Ext.new
217
- main_project = ext.main_project
218
- engines = ext.subproject("engines")
219
- modules = ext.subproject("modules")
220
-
221
- ensure
222
- $stdout = STDOUT
223
- end
224
-
225
- capture = capture.string
226
-
227
- assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
228
-
229
- assert File.exists?(File.join('vendor', 'rails', '.git'))
230
-
231
-
232
- assert_equal "current", main_project.current_branch
233
-
234
- assert_equal "edge", engines.current_branch
235
- assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
236
-
237
- assert_equal "current", modules.current_branch
238
- assert_equal "current", ext.configuration["modules"]["branch"]
239
-
240
- assert capture !~ /WARNING:/
241
- assert capture !~ /rm\s+-rf?\s+vendor.rails/
242
- assert main_project.ignore_contains?("vendor/rails")
243
- assert capture.scan(/rm/).size == 0
244
-
245
- assert File.read(File.join('modules', 'modules.txt')) !~
246
- /line 2 of modules.txt ... this is branch2!/
247
- assert File.read(File.join('modules', 'modules.txt')) =~ /line1 of/
248
- end
249
- end
250
- end
251
-
252
- def test_export_with_subproject
253
- mode = "export"
254
-
255
- repository = RailsAppSvnBranches.new
256
- repository.prepare
257
-
258
- assert File.exists?(File.join(repository.clean_dir, "db"))
259
-
260
- workdir = File.join(root_dir, 'test', "tmp", "workdir", mode, "svn", "branch_test")
261
- rm_rf workdir
262
- mkdir_p workdir
263
-
264
- if File.exists?(File.join(workdir,"rails_app"))
265
- rm_r File.join(workdir, "rails_app")
266
- end
267
-
268
- Dir.chdir workdir do
269
- source = repository.clean_url
270
- if windows?
271
- source = source.gsub(/\\/, "/")
272
- end
273
-
274
- puts "About to #{mode} #{source}"
275
- Ext.run mode, "--svn", source, "-b", "current", 'rails_app'
276
-
277
- Dir.chdir 'rails_app' do
278
- assert !File.exists?('.svn')
279
-
280
- %w(redhillonrails_core).each do |proj|
281
- assert !File.exists?(File.join('vendor', 'plugins', proj, '.svn'))
282
- end
283
-
284
- %w(redhillonrails_core acts_as_list engines).each do |proj|
285
- assert File.exists?(File.join('vendor', 'plugins', proj, 'lib'))
286
- end
287
-
288
- assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
289
-
290
- assert File.exists?(File.join('vendor', 'rails', '.git'))
291
-
292
- assert File.exists?(File.join('modules', 'modules.txt'))
293
-
294
- assert File.read(File.join('modules', 'modules.txt')) =~ /line1 of/
295
-
296
- ext = Ext.new
297
- assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
298
- assert_equal "current", ext.configuration["modules"]["branch"]
299
-
300
- assert !File.exists?(File.join(%w(vendor plugins ssl_requirement)))
301
- assert !File.exists?(File.join(%w(vendor plugins empty_plugin)))
302
- end
303
- end
304
- end
305
-
306
- def test_uninstall
307
- repository = RailsAppSvnBranches.new
308
- repository.prepare
309
-
310
- assert File.exists?(File.join(repository.clean_dir, "db"))
311
-
312
- workdir = File.join(root_dir, 'test', "tmp", "workdir","uninstall","svn","branches")
313
- mkdir_p workdir
314
-
315
- if File.exists?(File.join(workdir,"rails_app"))
316
- rm_r File.join(workdir, "rails_app")
317
- end
318
-
319
- Dir.chdir workdir do
320
- source = repository.clean_url
321
-
322
- puts "About to checkout #{source}"
323
- Ext.run "checkout", "--svn", "-b", "current", source, "rails_app"
324
-
325
- Dir.chdir 'rails_app' do
326
- mp = Ext.new.main_project
327
-
328
- projs = %w(redhillonrails_core acts_as_list)
329
- projs_i = projs.dup
330
- projs_ni = []
331
-
332
- #let's uninstall acts_as_list
333
- Ext.run "uninstall", "acts_as_list"
334
-
335
- projs_ni << projs_i.delete('acts_as_list')
336
-
337
- mp.assert_e_dne_i_ni proc{|a|assert(a)}, projs, [], projs_i, projs_ni
338
-
339
- Ext.run "uninstall", "-f", "redhillonrails_core"
340
-
341
- projs_ni << projs_i.delete('redhillonrails_core')
342
-
343
- projs_dne = []
344
- projs_dne << projs.delete('redhillonrails_core')
345
-
346
- mp.assert_e_dne_i_ni proc{|a|assert(a)}, projs, projs_dne, projs_i, projs_ni
347
- end
348
- end
349
- end
350
-
351
- end
352
- end
353
- end
@@ -1,59 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__),'..','lib') if $0 == __FILE__
2
-
3
- require 'ext_test_case'
4
- require 'externals/ext'
5
-
6
- module Externals
7
- module Test
8
- class TestTouchEmptydirs < ::Test::Unit::TestCase
9
- include ExtTestCase
10
-
11
- def setup
12
- teardown
13
-
14
- Dir.chdir File.join(root_dir, 'test') do
15
- mkdir "workdir"
16
-
17
- Dir.chdir 'workdir' do
18
- mkdir "notempty1"
19
- Dir.chdir 'notempty1' do
20
- mkdir "notempty2"
21
- mkdir "empty1"
22
- Dir.chdir 'notempty2' do
23
- mkdir "empty2"
24
- mkdir "notempty3"
25
- Dir.chdir 'notempty3' do
26
- File.open('readme.txt', 'w') do |f|
27
- f.write "some text\n"
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end
34
- end
35
-
36
- def teardown
37
- Dir.chdir File.join(root_dir, 'test') do
38
- rm_rf "workdir"
39
- end
40
- end
41
-
42
- def test_touch_emptydirs
43
- Dir.chdir File.join(root_dir, 'test') do
44
- assert !File.exists?(File.join('.emptydir'))
45
- Dir.chdir 'workdir' do
46
- Ext.run "touch_emptydirs"
47
- assert !File.exists?(File.join('.emptydir'))
48
- assert !File.exists?(File.join('notempty1', '.emptydir'))
49
- assert File.exists?(File.join('notempty1', 'empty1', '.emptydir'))
50
- assert !File.exists?(File.join('notempty1', 'notempty2', '.emptydir'))
51
- assert File.exists?(File.join('notempty1', 'notempty2', 'empty2', '.emptydir'))
52
- assert !File.exists?(File.join('notempty1', 'notempty2', 'notempty3', '.emptydir'))
53
- end
54
- end
55
- end
56
-
57
- end
58
- end
59
- end
data/test/test_version.rb DELETED
@@ -1,33 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') if $0 == __FILE__
2
- require 'ext_test_case'
3
- require 'externals/ext'
4
- require 'stringio'
5
-
6
- module Externals
7
- module Test
8
- class TestVersion < ::Test::Unit::TestCase
9
- include ExtTestCase
10
-
11
- def test_version
12
- version_regex = /(?:[^\.\d]|^)(\d+\.\d+\.\d+)(?:[^\.\d]|$)/
13
-
14
- assert Externals::VERSION =~ version_regex
15
-
16
- ["version", "--version"].each do |options|
17
- out = StringIO.new
18
- old_stdout = $stdout
19
-
20
- begin
21
- $stdout = out
22
- Ext.run options
23
- ensure
24
- $stdout = old_stdout
25
- end
26
-
27
- assert(out.string =~ version_regex)
28
- assert_equal $1, Externals::VERSION.strip
29
- end
30
- end
31
- end
32
- end
33
- end