ext 1.0.3 → 1.0.4

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.
Files changed (43) hide show
  1. data/CHANGELOG +7 -0
  2. data/README +2 -0
  3. data/Rakefile +1 -74
  4. data/bin/ext +0 -0
  5. data/lib/externals/ext.rb +25 -9
  6. data/lib/externals/extensions/file_utils.rb +40 -0
  7. data/lib/externals/extensions/string.rb +1 -1
  8. data/lib/externals/project.rb +3 -0
  9. data/lib/externals/scms/git_project.rb +3 -4
  10. data/lib/externals/scms/svn_project.rb +10 -12
  11. data/lib/externals/test/basic_git_repository.rb +41 -0
  12. data/lib/externals/test/engines.rb +11 -0
  13. data/lib/externals/test/engines_with_branch1.rb +36 -0
  14. data/lib/externals/test/fake_rails_repository.rb +112 -0
  15. data/lib/externals/test/git_repository_from_internet.rb +19 -0
  16. data/lib/externals/test/modules_svn_branches_repository.rb +72 -0
  17. data/lib/externals/test/modules_svn_repository.rb +41 -0
  18. data/lib/externals/test/rails_app_git_branches.rb +100 -0
  19. data/lib/externals/test/rails_app_git_repository.rb +55 -0
  20. data/lib/externals/test/rails_app_svn_branches.rb +132 -0
  21. data/lib/externals/test/rails_app_svn_repository.rb +106 -0
  22. data/lib/externals/test/rails_app_unmanaged.rb +25 -0
  23. data/lib/externals/test/repository.rb +188 -0
  24. data/lib/externals/test/svn_repository_from_dump.rb +27 -0
  25. data/lib/externals/test/svn_repository_helper.rb +10 -0
  26. data/lib/externals/test_case.rb +16 -307
  27. data/test/setup/empty_plugin.svn.gz +0 -0
  28. data/test/setup/foreign_key_migrations.svn.gz +0 -0
  29. data/test/setup/redhillonrails_core.svn.gz +0 -0
  30. data/test/test_checkout_git.rb +16 -25
  31. data/test/test_checkout_with_subprojects_git.rb +109 -193
  32. data/test/test_checkout_with_subprojects_svn.rb +239 -294
  33. data/test/test_file_utils_extensions.rb +29 -0
  34. data/test/test_freeze_to_revision.rb +46 -85
  35. data/test/test_git_project_extract_name.rb +10 -8
  36. data/test/test_init_git.rb +19 -29
  37. data/test/test_projects.rb +87 -93
  38. data/test/test_rails_detection.rb +12 -17
  39. data/test/test_string_extensions.rb +32 -30
  40. data/test/test_svn_branches.rb +227 -383
  41. data/test/test_touch_emptydirs.rb +39 -34
  42. data/test/test_version.rb +18 -16
  43. metadata +47 -23
@@ -2,26 +2,21 @@ $:.unshift File.join(File.dirname(__FILE__),'..','lib') if $0 == __FILE__
2
2
 
3
3
  require 'externals/test_case'
4
4
  require 'externals/ext'
5
+ require 'externals/test/rails_app_unmanaged'
5
6
 
6
7
  module Externals
7
- class TestRailsDetection < TestCase
8
- include ExtTestCase
9
-
10
- def setup
11
- destroy_rails_application
12
- create_rails_application
13
- end
14
-
15
- def teardown
16
- destroy_rails_application
17
- end
18
-
19
- def test_detection
20
- detector = Ext.project_type_detector('rails')
8
+ module Test
9
+ class TestRailsDetection < TestCase
10
+ include ExtTestCase
11
+
12
+ def test_detection
13
+ repository = RailsAppUnmanaged.new
14
+ detector = Ext.project_type_detector('rails')
21
15
 
22
- assert !detector.detected?
23
- Dir.chdir(rails_application_dir) do
24
- assert detector.detected?
16
+ assert !detector.detected?
17
+ Dir.chdir(repository.clean_dir) do
18
+ assert detector.detected?
19
+ end
25
20
  end
26
21
  end
27
22
  end
@@ -4,46 +4,48 @@ require 'externals/test_case'
4
4
  require 'externals/ext'
5
5
 
6
6
  module Externals
7
- class TestStringExtensions < TestCase
8
- include ExtTestCase
9
-
10
- def test_classify
11
- assert_equal "yourmom".classify, "Yourmom"
12
- assert_equal "your_mom".classify, "YourMom"
13
- assert_equal "lol_your_mom".classify, "LolYourMom"
14
- assert_equal "".classify, ""
15
- end
7
+ module Test
8
+ class TestStringExtensions < TestCase
9
+ include ExtTestCase
10
+
11
+ def test_classify
12
+ assert_equal "yourmom".classify, "Yourmom"
13
+ assert_equal "your_mom".classify, "YourMom"
14
+ assert_equal "lol_your_mom".classify, "LolYourMom"
15
+ assert_equal "".classify, ""
16
+ end
16
17
 
17
- def test_lines_by_width
18
- assert_equal [
19
- "this",
20
- "is a",
21
- "test"
18
+ def test_lines_by_width
19
+ assert_equal [
20
+ "this",
21
+ "is a",
22
+ "test"
22
23
  ],
23
24
  "this is a test".lines_by_width(4)
24
25
 
25
- assert_equal [
26
- "this",
27
- "is",
28
- "a",
29
- "test"
26
+ assert_equal [
27
+ "this",
28
+ "is",
29
+ "a",
30
+ "test"
30
31
  ],
31
32
  "this is a test".lines_by_width(2)
32
33
 
33
- assert_equal ["this is a test"], "this is a test".lines_by_width
34
+ assert_equal ["this is a test"], "this is a test".lines_by_width
34
35
 
35
- assert_equal [
36
- "The working directory to execute",
37
- "commands from. Use this if for",
38
- "some reason you cannot execute",
39
- "ext from the main project's",
40
- "directory (or if it's just",
41
- "inconvenient, such as in a",
42
- "script or in a Capistrano task)"
43
- ],
44
- "The working directory to execute commands from. Use this if for some reason you
36
+ assert_equal [
37
+ "The working directory to execute",
38
+ "commands from. Use this if for",
39
+ "some reason you cannot execute",
40
+ "ext from the main project's",
41
+ "directory (or if it's just",
42
+ "inconvenient, such as in a",
43
+ "script or in a Capistrano task)"
44
+ ],
45
+ "The working directory to execute commands from. Use this if for some reason you
45
46
  cannot execute ext from the main project's directory (or if it's just inconvenient, such as in a script
46
47
  or in a Capistrano task)".lines_by_width
48
+ end
47
49
  end
48
50
  end
49
51
  end
@@ -1,501 +1,345 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') if $0 == __FILE__
2
2
  require 'externals/test_case'
3
3
  require 'externals/ext'
4
+ require 'externals/test/rails_app_svn_branches'
4
5
 
5
6
  module Externals
6
- class TestSvnBranches < TestCase
7
- include ExtTestCase
8
-
9
- def teardown
10
- destroy_rails_application
11
- destroy_with_svn_branches_repository
12
- destroy_with_svn_branches_modules_repository
13
-
14
- Dir.chdir File.join(root_dir, 'test') do
15
- parts = 'workdir/checkout/rails_app/vendor/plugins/foreign_key_migrations/lib/red_hill_consulting/foreign_key_migrations/active_record/connection_adapters/.svn/text-base/table_definition.rb.svn-base'.split('/')
16
- if File.exists? File.join(*parts)
17
- Dir.chdir File.join(*(parts[0..-2])) do
18
- File.delete parts[-1]
19
- end
7
+ module Test
8
+ class TestSvnBranches < TestCase
9
+ include ExtTestCase
10
+
11
+ def test_checkout_with_subproject
12
+ mode = "checkout"
13
+ repository = RailsAppSvnBranches.new
14
+ repository.prepare
15
+
16
+ assert File.exists?(File.join(repository.clean_dir, "db"))
17
+
18
+ workdir = File.join(root_dir, 'test', "tmp", "workdir", mode, "svn", "branches")
19
+ mkdir_p workdir
20
+
21
+ if File.exists?(File.join(workdir, "rails_app"))
22
+ rm_r File.join(workdir, "rails_app")
20
23
  end
21
- `rm -rf workdir`
22
- end
23
- end
24
24
 
25
- def setup
26
- teardown
25
+ Dir.chdir workdir do
26
+ source = repository.clean_url
27
+ if windows?
28
+ source = source.gsub(/\\/, "/")
29
+ end
27
30
 
28
- create_rails_application
31
+ puts "About to #{mode} #{source}"
32
+ Ext.run mode, "--svn", source, "-b", "current", 'rails_app'
29
33
 
30
- create_with_svn_branches_repository
31
- create_with_svn_branches_modules_repository
32
- initialize_with_svn_branches_repository
33
- initialize_with_svn_branches_modules_repository
34
- end
34
+ Dir.chdir 'rails_app' do
35
+ assert File.exists?('.svn')
35
36
 
36
- def test_checkout_with_subproject
37
- Dir.chdir File.join(root_dir, 'test') do
38
- Dir.chdir 'workdir' do
39
- `mkdir checkout`
40
- Dir.chdir 'checkout' do
41
- source = with_svn_branches_repository_url
42
- if windows?
43
- source = source.gsub(/\\/, "/")
37
+ %w(redhillonrails_core acts_as_list).each do |proj|
38
+ ignore_text = `svn propget svn:ignore vendor/plugins`
39
+ puts "ignore_text is:"
40
+ puts ignore_text
41
+ assert(ignore_text =~ /^#{proj}$/)
44
42
  end
45
43
 
46
- puts "About to checkout #{source}"
47
- Ext.run "checkout", "--svn", source, "-b", "current", 'rails_app'
44
+ ignore_text = `svn propget svn:ignore vendor`
45
+ assert(ignore_text =~ /^rails$/)
48
46
 
49
- Dir.chdir 'rails_app' do
50
- assert File.exists?('.svn')
47
+ %w(redhillonrails_core acts_as_list engines).each do |proj|
48
+ assert File.exists?(File.join('vendor', 'plugins', proj, 'lib'))
49
+ end
51
50
 
52
- %w(foreign_key_migrations redhillonrails_core acts_as_list).each do |proj|
53
- ignore_text = `svn propget svn:ignore vendor/plugins`
54
- puts "ignore_text is:"
55
- puts ignore_text
56
- assert(ignore_text =~ /^#{proj}$/)
57
- end
51
+ assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
58
52
 
59
- ignore_text = `svn propget svn:ignore vendor`
60
- assert(ignore_text =~ /^rails$/)
53
+ assert File.exists?(File.join('vendor', 'rails', '.git'))
61
54
 
62
- %w(foreign_key_migrations redhillonrails_core acts_as_list engines).each do |proj|
63
- assert File.exists?(File.join('vendor', 'plugins', proj, 'lib'))
64
- end
55
+ assert File.exists?(File.join('modules', 'modules.txt'))
65
56
 
66
- assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
57
+ assert File.read(File.join('modules', 'modules.txt')) =~ /line1 of/
67
58
 
68
- assert File.exists?(File.join('vendor', 'rails', '.git'))
59
+ ext = Ext.new
60
+ main_project = ext.main_project
61
+ engines = ext.subproject("engines")
62
+ modules = ext.subproject("modules")
69
63
 
70
- assert File.exists?(File.join('modules', 'modules.txt'))
64
+ assert_equal "current", main_project.current_branch
71
65
 
72
- assert File.read(File.join('modules', 'modules.txt')) =~ /line1 of/
66
+ assert_equal "edge", engines.current_branch
67
+ assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
73
68
 
74
- ext = Ext.new
75
- main_project = ext.main_project
76
- engines = ext.subproject("engines")
77
- modules = ext.subproject("modules")
69
+ assert_equal "current", modules.current_branch
70
+ assert_equal "current", ext.configuration["modules"]["branch"]
71
+ gi
72
+ assert !File.exists?(File.join(%w(vendor plugins ssl_requirement)))
73
+ assert !File.exists?(File.join(%w(vendor plugins empty_plugin)))
78
74
 
79
- assert_equal "current", main_project.current_branch
75
+ `svn switch #{[source, "branches", "new_branch"].join("/")}`
76
+ unless $? == 0
77
+ raise
78
+ end
80
79
 
81
- assert_equal "edge", engines.current_branch
82
- assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
80
+ assert !File.exists?(File.join(%w(vendor plugins ssl_requirement)))
81
+ assert !File.exists?(File.join(%w(vendor plugins empty_plugin)))
83
82
 
84
- assert_equal "current", modules.current_branch
85
- assert_equal "current", ext.configuration["modules"]["branch"]
83
+ assert !main_project.ignore_contains?("vendor/rails")
86
84
 
87
- `svn switch #{[source, "branches", "new_branch"].join("/")}`
88
- unless $? == 0
89
- raise
90
- end
85
+ ext = Ext.new
86
+ main_project = ext.main_project
87
+ engines = ext.subproject("engines")
88
+ modules = ext.subproject("modules")
91
89
 
92
- assert !main_project.ignore_contains?("vendor/rails")
90
+ assert_equal "branches/new_branch", main_project.current_branch
93
91
 
94
- ext = Ext.new
95
- main_project = ext.main_project
96
- engines = ext.subproject("engines")
97
- modules = ext.subproject("modules")
92
+ assert_equal "edge", engines.current_branch
93
+ assert_equal "branch1", ext.configuration["vendor/plugins/engines"]["branch"]
98
94
 
99
- assert_equal "branches/new_branch", main_project.current_branch
95
+ assert_equal "current", modules.current_branch
96
+ assert_equal "branches/branch2", ext.configuration["modules"]["branch"]
100
97
 
101
- assert_equal "edge", engines.current_branch
102
- assert_equal "branch1", ext.configuration["vendor/plugins/engines"]["branch"]
98
+ Ext.run "up"
103
99
 
104
- assert_equal "current", modules.current_branch
105
- assert_equal "branches/branch2", ext.configuration["modules"]["branch"]
100
+ assert File.exists?(File.join(%w(vendor plugins ssl_requirement)))
101
+ assert File.exists?(File.join(%w(vendor plugins empty_plugin)))
106
102
 
107
- Ext.run "up"
103
+ Dir.chdir File.join("vendor",'plugins', "ssl_requirement") do
104
+ assert `git show HEAD` =~ /^\s*commit\s*#{
105
+ repository.dependents[:ssl_requirement].attributes[:revision]
106
+ }\s*$/i
107
+ end
108
108
 
109
- assert_equal "branches/new_branch", main_project.current_branch
109
+ assert_equal "branches/new_branch", main_project.current_branch
110
110
 
111
- assert_equal "branch1", engines.current_branch
112
- assert_equal "branch1", ext.configuration["vendor/plugins/engines"]["branch"]
111
+ assert_equal "branch1", engines.current_branch
112
+ assert_equal "branch1", ext.configuration["vendor/plugins/engines"]["branch"]
113
113
 
114
- assert_equal "branches/branch2", modules.current_branch
115
- assert_equal "branches/branch2", ext.configuration["modules"]["branch"]
114
+ assert_equal "branches/branch2", modules.current_branch
115
+ assert_equal "branches/branch2", ext.configuration["modules"]["branch"]
116
116
 
117
- assert File.read(File.join('modules', 'modules.txt')) =~
118
- /line 2 of modules.txt ... this is branch2!/
117
+ assert File.read(File.join('modules', 'modules.txt')) =~
118
+ /line 2 of modules.txt ... this is branch2!/
119
119
 
120
- `svn switch #{[source, "current"].join("/")}`
121
- ext = Ext.new
122
- main_project = ext.main_project
123
- engines = ext.subproject("engines")
124
- modules = ext.subproject("modules")
120
+ `svn switch #{[source, "current"].join("/")}`
121
+ ext = Ext.new
122
+ main_project = ext.main_project
123
+ engines = ext.subproject("engines")
124
+ modules = ext.subproject("modules")
125
125
 
126
- assert_equal "current", main_project.current_branch
126
+ assert_equal "current", main_project.current_branch
127
127
 
128
- assert_equal "branch1", engines.current_branch
129
- assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
128
+ assert_equal "branch1", engines.current_branch
129
+ assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
130
130
 
131
- assert_equal "branches/branch2", modules.current_branch
132
- assert_equal "current", ext.configuration["modules"]["branch"]
133
- assert File.read(File.join('modules', 'modules.txt')) =~
134
- /line 2 of modules.txt ... this is branch2!/
131
+ assert_equal "branches/branch2", modules.current_branch
132
+ assert_equal "current", ext.configuration["modules"]["branch"]
133
+ assert File.read(File.join('modules', 'modules.txt')) =~
134
+ /line 2 of modules.txt ... this is branch2!/
135
135
 
136
- Ext.run "up"
137
- ext = Ext.new
138
- main_project = ext.main_project
139
- engines = ext.subproject("engines")
140
- modules = ext.subproject("modules")
136
+ Ext.run "up"
137
+ ext = Ext.new
138
+ main_project = ext.main_project
139
+ engines = ext.subproject("engines")
140
+ modules = ext.subproject("modules")
141
141
 
142
- assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
142
+ assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
143
143
 
144
- assert File.exists?(File.join('vendor', 'rails', '.git'))
144
+ assert File.exists?(File.join('vendor', 'rails', '.git'))
145
145
 
146
- assert_equal "current", main_project.current_branch
146
+ assert_equal "current", main_project.current_branch
147
147
 
148
- assert_equal "edge", engines.current_branch
149
- assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
148
+ assert_equal "edge", engines.current_branch
149
+ assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
150
150
 
151
- assert_equal "current", modules.current_branch
152
- assert_equal "current", ext.configuration["modules"]["branch"]
153
- assert File.read(File.join('modules', 'modules.txt')) !~
154
- /line 2 of modules.txt ... this is branch2!/
155
- assert File.read(File.join('modules', 'modules.txt')) =~ /line1 of/
151
+ assert_equal "current", modules.current_branch
152
+ assert_equal "current", ext.configuration["modules"]["branch"]
153
+ assert File.read(File.join('modules', 'modules.txt')) !~
154
+ /line 2 of modules.txt ... this is branch2!/
155
+ assert File.read(File.join('modules', 'modules.txt')) =~ /line1 of/
156
156
 
157
- assert main_project.ignore_contains?("vendor/rails")
157
+ assert main_project.ignore_contains?("vendor/rails")
158
158
 
159
- # let's test the switch command.
160
- capture = StringIO.new
161
- begin
162
- $stdout = capture
159
+ # let's test the switch command.
160
+ capture = StringIO.new
161
+ begin
162
+ $stdout = capture
163
163
 
164
- Ext.run "switch", "branches/new_branch"
164
+ Ext.run "switch", "branches/new_branch"
165
165
 
166
- ext = Ext.new
167
- main_project = ext.main_project
168
- engines = ext.subproject("engines")
169
- modules = ext.subproject("modules")
166
+ ext = Ext.new
167
+ main_project = ext.main_project
168
+ engines = ext.subproject("engines")
169
+ modules = ext.subproject("modules")
170
170
 
171
- ensure
172
- $stdout = STDOUT
173
- end
174
- capture = capture.string
171
+ ensure
172
+ $stdout = STDOUT
173
+ end
174
+ capture = capture.string
175
175
 
176
- assert_equal "branches/new_branch", main_project.current_branch
176
+ assert_equal "branches/new_branch", main_project.current_branch
177
177
 
178
- assert_equal "branch1", engines.current_branch
179
- assert_equal "branch1", ext.configuration["vendor/plugins/engines"]["branch"]
178
+ assert_equal "branch1", engines.current_branch
179
+ assert_equal "branch1", ext.configuration["vendor/plugins/engines"]["branch"]
180
180
 
181
- assert_equal "branches/branch2", modules.current_branch
182
- assert_equal "branches/branch2", ext.configuration["modules"]["branch"]
181
+ assert_equal "branches/branch2", modules.current_branch
182
+ assert_equal "branches/branch2", ext.configuration["modules"]["branch"]
183
183
 
184
- assert capture =~ /WARNING:/
185
- assert capture =~ /rm\s+-rf?\s+vendor.rails/
186
- assert capture.scan(/rm/).size == 1
184
+ assert capture =~ /WARNING:/
185
+ assert capture =~ /rm\s+-rf?\s+vendor.rails/
186
+ assert capture.scan(/rm/).size == 1
187
187
 
188
- assert !main_project.ignore_contains?("vendor/rails")
188
+ assert !main_project.ignore_contains?("vendor/rails")
189
189
 
190
- `rm -rf vendor/rails`
190
+ [
191
+ %w(vendor rails),
192
+ %w(vendor plugins ssl_requirement),
193
+ %w(vendor plugins empty_plugin)
194
+ ].each do |dir|
195
+ rm_r File.join(*dir)
191
196
  unless $? == 0
192
197
  raise
193
198
  end
199
+ end
194
200
 
195
- assert File.read(File.join('modules', 'modules.txt')) =~
196
- /line 2 of modules.txt ... this is branch2!/
201
+ assert File.read(File.join('modules', 'modules.txt')) =~
202
+ /line 2 of modules.txt ... this is branch2!/
197
203
 
198
- capture = StringIO.new
199
- begin
200
- $stdout = capture
204
+ capture = StringIO.new
205
+ begin
206
+ $stdout = capture
201
207
 
202
- Ext.run "switch", "current"
203
- ext = Ext.new
204
- main_project = ext.main_project
205
- engines = ext.subproject("engines")
206
- modules = ext.subproject("modules")
208
+ Ext.run "switch", "current"
209
+ ext = Ext.new
210
+ main_project = ext.main_project
211
+ engines = ext.subproject("engines")
212
+ modules = ext.subproject("modules")
207
213
 
208
- ensure
209
- $stdout = STDOUT
210
- end
214
+ ensure
215
+ $stdout = STDOUT
216
+ end
211
217
 
212
- capture = capture.string
218
+ capture = capture.string
213
219
 
214
- assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
220
+ assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
215
221
 
216
- assert File.exists?(File.join('vendor', 'rails', '.git'))
222
+ assert File.exists?(File.join('vendor', 'rails', '.git'))
217
223
 
218
224
 
219
- assert_equal "current", main_project.current_branch
225
+ assert_equal "current", main_project.current_branch
220
226
 
221
- assert_equal "edge", engines.current_branch
222
- assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
227
+ assert_equal "edge", engines.current_branch
228
+ assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
223
229
 
224
- assert_equal "current", modules.current_branch
225
- assert_equal "current", ext.configuration["modules"]["branch"]
230
+ assert_equal "current", modules.current_branch
231
+ assert_equal "current", ext.configuration["modules"]["branch"]
226
232
 
227
- assert capture !~ /WARNING:/
228
- assert capture !~ /rm\s+-rf?\s+vendor.rails/
229
- assert main_project.ignore_contains?("vendor/rails")
230
- assert capture.scan(/rm/).size == 0
233
+ assert capture !~ /WARNING:/
234
+ assert capture !~ /rm\s+-rf?\s+vendor.rails/
235
+ assert main_project.ignore_contains?("vendor/rails")
236
+ assert capture.scan(/rm/).size == 0
231
237
 
232
- assert File.read(File.join('modules', 'modules.txt')) !~
233
- /line 2 of modules.txt ... this is branch2!/
234
- assert File.read(File.join('modules', 'modules.txt')) =~ /line1 of/
235
- end
238
+ assert File.read(File.join('modules', 'modules.txt')) !~
239
+ /line 2 of modules.txt ... this is branch2!/
240
+ assert File.read(File.join('modules', 'modules.txt')) =~ /line1 of/
236
241
  end
237
242
  end
238
243
  end
239
- end
240
-
241
- def test_update_with_missing_subproject_git
242
- Dir.chdir File.join(root_dir, 'test') do
243
- Dir.chdir 'workdir' do
244
- `mkdir update`
245
- Dir.chdir 'update' do
246
- source = with_svn_branches_repository_url
247
- if windows?
248
- source = source.gsub(/\\/, "/")
249
- end
250
-
251
-
252
- puts "About to checkout #{source}"
253
- Ext.run "checkout", "--svn", "-b", "current", source, 'rails_app'
254
-
255
- Dir.chdir 'rails_app' do
256
- pretests = proc do
257
- assert File.exists?('.svn')
258
- assert !File.exists?(File.join('vendor', 'plugins', 'ssl_requirement', 'lib'))
259
- assert File.read(".externals") =~ /rails/
260
- assert File.read(".externals") !~ /ssl_requirement/
261
- end
262
-
263
- pretests.call
264
-
265
- #add a project
266
- Dir.chdir File.join(root_dir, 'test') do
267
- `mkdir rails_app`
268
- Dir.chdir 'workdir' do
269
- Ext.run "checkout", "--svn", "-b", "current", source, 'rails_app'
270
244
 
271
- Dir.chdir "rails_app" do
272
- #install a new project
273
- Ext.run "install", File.join(root_dir, 'test', 'cleanreps', 'ssl_requirement.git')
245
+ def test_export_with_subproject
246
+ mode = "export"
274
247
 
275
- SvnProject.add_all
248
+ repository = RailsAppSvnBranches.new
249
+ repository.prepare
276
250
 
277
- puts `svn commit -m "added another subproject (ssl_requirement)"`
278
- end
279
- end
280
- end
251
+ assert File.exists?(File.join(repository.clean_dir, "db"))
281
252
 
282
- pretests.call
253
+ workdir = File.join(root_dir, 'test', "tmp", "workdir", mode, "svn", "branch_test")
254
+ mkdir_p workdir
283
255
 
284
- #update the project and make sure ssl_requirement was added and checked out
285
- Ext.run "update"
286
- assert File.read(".externals") =~ /ssl_requirement/
287
- assert File.exists?(File.join('vendor', 'plugins', 'ssl_requirement', 'lib'))
288
- end
289
- end
256
+ if File.exists?(File.join(workdir,"rails_app"))
257
+ rm_r File.join(workdir, "rails_app")
290
258
  end
291
- end
292
- end
293
-
294
- def test_update_with_missing_subproject_by_revision_git
295
- subproject = "ssl_requirement"
296
- revision = "aa2dded823f8a9b378c22ba0159971508918928a"
297
-
298
- Dir.chdir File.join(root_dir, 'test') do
299
- Dir.chdir 'workdir' do
300
- `mkdir update`
301
- Dir.chdir 'update' do
302
- source = with_svn_branches_repository_url
303
-
304
- puts "About to checkout #{source}"
305
- Ext.run "checkout", "--svn", source, "-b", "current", 'rails_app'
306
-
307
- Dir.chdir 'rails_app' do
308
- pretests = proc do
309
- assert File.exists?('.svn')
310
- assert !File.exists?(File.join('vendor', 'plugins', subproject, 'lib'))
311
- assert File.read(".externals") =~ /rails/
312
- assert File.read(".externals") !~ /#{subproject}/
313
- end
314
-
315
- pretests.call
316
-
317
- #add a project
318
- Dir.chdir File.join(root_dir, 'test') do
319
- Dir.chdir File.join('workdir') do
320
- Ext.run "checkout", "--svn", source, "-b", "current", 'rails_app'
321
-
322
- Dir.chdir File.join("rails_app") do
323
- #install a new project
324
- Ext.run "install", File.join(root_dir, 'test', 'cleanreps', "#{subproject}.git")
325
- Dir.chdir File.join("vendor",'plugins', subproject) do
326
- assert `git show HEAD` !~ /^\s*commit\s*#{revision}\s*$/i
327
- end
328
- #freeze it to a revision
329
- Ext.run "freeze", subproject, revision
330
- Dir.chdir File.join("vendor",'plugins', subproject) do
331
- regex = /^\s*commit\s*#{revision}\s*$/i
332
- output = `git show HEAD`
333
- result = output =~ regex
334
- unless result
335
- puts "Expecting output to match #{regex} but it was: #{output}"
336
- end
337
- assert result
338
- end
339
-
340
- SvnProject.add_all
341
-
342
- puts `svn commit -m "added another subproject (#{subproject}) frozen to #{revision}"`
343
- end
344
-
345
- `rm -rf rails_app`
346
- end
347
- end
348
259
 
349
- pretests.call
260
+ Dir.chdir workdir do
261
+ source = repository.clean_url
262
+ if windows?
263
+ source = source.gsub(/\\/, "/")
264
+ end
350
265
 
351
- #update the project and make sure ssl_requirement was added and checked out at the right revision
352
- Ext.run "update"
353
- assert File.read(".externals") =~ /ssl_requirement/
266
+ puts "About to #{mode} #{source}"
267
+ Ext.run mode, "--svn", source, "-b", "current", 'rails_app'
354
268
 
355
- assert File.exists?(File.join('vendor', 'plugins', subproject, 'lib'))
269
+ Dir.chdir 'rails_app' do
270
+ assert !File.exists?('.svn')
356
271
 
357
- Dir.chdir File.join("vendor",'plugins', subproject) do
358
- assert `git show HEAD` =~ /^\s*commit\s*#{revision}\s*$/i
359
- end
272
+ %w(redhillonrails_core).each do |proj|
273
+ assert !File.exists?(File.join('vendor', 'plugins',proj, '.svn'))
360
274
  end
361
- end
362
- end
363
- end
364
- end
365
-
366
- def test_update_with_missing_subproject_svn
367
- Dir.chdir File.join(root_dir, 'test') do
368
- Dir.chdir 'workdir' do
369
- `mkdir update`
370
- Dir.chdir 'update' do
371
- source = with_svn_branches_repository_url
372
-
373
- puts "About to checkout #{source}"
374
- Ext.run "checkout", "--svn", "-b", "current", source, 'rails_app'
375
-
376
- Dir.chdir 'rails_app' do
377
- pretests = proc do
378
- assert File.exists?('.svn')
379
- assert !File.exists?(File.join('vendor', 'plugins', 'empty_plugin', 'lib'))
380
- assert File.read(".externals") =~ /rails/
381
- assert File.read(".externals") !~ /empty_plugin/
382
- end
383
275
 
384
- pretests.call
276
+ %w(redhillonrails_core acts_as_list engines).each do |proj|
277
+ assert File.exists?(File.join('vendor', 'plugins', proj, 'lib'))
278
+ end
385
279
 
386
- #add a project
387
- Dir.chdir File.join(root_dir, 'test') do
388
- `mkdir rails_app`
389
- Dir.chdir 'workdir' do
390
- Ext.run "checkout", "--svn", "-b", "current", source, 'rails_app'
280
+ assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
391
281
 
392
- Dir.chdir "rails_app" do
393
- #install a new project
394
- Ext.run "install", "--svn",
395
- "file:///#{File.join(root_dir, 'test', 'cleanreps', 'empty_plugin')}"
282
+ assert File.exists?(File.join('vendor', 'rails', '.git'))
396
283
 
397
- SvnProject.add_all
284
+ assert File.exists?(File.join('modules', 'modules.txt'))
398
285
 
399
- puts `svn commit -m "added another subproject (empty_plugin)"`
400
- end
401
- end
402
- end
286
+ assert File.read(File.join('modules', 'modules.txt')) =~ /line1 of/
403
287
 
404
- pretests.call
288
+ ext = Ext.new
289
+ assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
290
+ assert_equal "current", ext.configuration["modules"]["branch"]
405
291
 
406
- #update the project and make sure ssl_requirement was added and checked out
407
- Ext.run "update"
408
- assert File.read(".externals") =~ /empty_plugin/
409
- assert File.exists?(File.join('vendor', 'plugins', 'empty_plugin', 'lib'))
410
- end
292
+ assert !File.exists?(File.join(%w(vendor plugins ssl_requirement)))
293
+ assert !File.exists?(File.join(%w(vendor plugins empty_plugin)))
411
294
  end
412
295
  end
413
296
  end
414
- end
415
-
416
- def test_export_with_subproject
417
- Dir.chdir File.join(root_dir, 'test') do
418
- Dir.chdir 'workdir' do
419
- `mkdir export`
420
- Dir.chdir 'export' do
421
- source = with_svn_branches_repository_url
422
-
423
- puts "About to export #{source}"
424
- Ext.run "export", "--svn", "-b", "current", source, 'rails_app'
425
297
 
426
- Dir.chdir 'rails_app' do
427
- assert File.exists?('.svn')
298
+ def test_uninstall
299
+ repository = RailsAppSvnBranches.new
300
+ repository.prepare
428
301
 
429
- %w(foreign_key_migrations redhillonrails_core acts_as_list).each do |proj|
430
- puts(ignore_text = `svn propget svn:ignore vendor/plugins`)
431
- assert(ignore_text =~ /^#{proj}$/)
432
- end
433
-
434
- puts(ignore_text = `svn propget svn:ignore vendor`)
435
- assert(ignore_text =~ /^rails$/)
302
+ assert File.exists?(File.join(repository.clean_dir, "db"))
436
303
 
437
- Dir.chdir File.join('vendor', 'rails') do
438
- #can't check this if it's local. It seems --depth 1 is ignored for
439
- #repositories on the local machine.
440
- #assert `git show 92f944818eece9fe4bc62ffb39accdb71ebc32be` !~ /azimux/
441
- end
304
+ workdir = File.join(root_dir, 'test', "tmp", "workdir","uninstall","svn","branches")
305
+ mkdir_p workdir
442
306
 
443
- %w(foreign_key_migrations redhillonrails_core acts_as_list).each do |proj|
444
- puts "filethere? #{proj}: #{File.exists?(File.join('vendor', 'plugins', proj, 'lib'))}"
445
- if !File.exists?(File.join('vendor', 'plugins', proj, 'lib'))
446
- puts "here"
447
- end
448
- assert File.exists?(File.join('vendor', 'plugins', proj, 'lib'))
449
- end
450
-
451
- %w(foreign_key_migrations redhillonrails_core).each do |proj|
452
- assert !File.exists?(File.join('vendor', 'plugins',proj, '.svn'))
453
- end
454
-
455
- assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
456
- end
457
- end
307
+ if File.exists?(File.join(workdir,"rails_app"))
308
+ rm_r File.join(workdir, "rails_app")
458
309
  end
459
- end
460
- end
461
310
 
462
- def test_uninstall
463
- Dir.chdir File.join(root_dir, 'test') do
464
- Dir.chdir 'workdir' do
465
- `mkdir checkout`
466
- Dir.chdir 'checkout' do
467
- source = with_svn_branches_repository_url
311
+ Dir.chdir workdir do
312
+ source = repository.clean_url
468
313
 
469
- puts "About to checkout #{source}"
470
- Ext.run "checkout", "--svn", "-b", "current", source, "rails_app"
314
+ puts "About to checkout #{source}"
315
+ Ext.run "checkout", "--svn", "-b", "current", source, "rails_app"
471
316
 
472
- Dir.chdir 'rails_app' do
473
- mp = Ext.new.main_project
317
+ Dir.chdir 'rails_app' do
318
+ mp = Ext.new.main_project
474
319
 
475
- projs = %w(foreign_key_migrations redhillonrails_core acts_as_list)
476
- projs_i = projs.dup
477
- projs_ni = []
320
+ projs = %w(redhillonrails_core acts_as_list)
321
+ projs_i = projs.dup
322
+ projs_ni = []
478
323
 
479
- #let's uninstall acts_as_list
480
- Ext.run "uninstall", "acts_as_list"
324
+ #let's uninstall acts_as_list
325
+ Ext.run "uninstall", "acts_as_list"
481
326
 
482
- projs_ni << projs_i.delete('acts_as_list')
327
+ projs_ni << projs_i.delete('acts_as_list')
483
328
 
484
- mp.assert_e_dne_i_ni proc{|a|assert(a)}, projs, [], projs_i, projs_ni
329
+ mp.assert_e_dne_i_ni proc{|a|assert(a)}, projs, [], projs_i, projs_ni
485
330
 
486
- Ext.run "uninstall", "-f", "foreign_key_migrations"
331
+ Ext.run "uninstall", "-f", "redhillonrails_core"
487
332
 
488
- projs_ni << projs_i.delete('foreign_key_migrations')
333
+ projs_ni << projs_i.delete('redhillonrails_core')
489
334
 
490
- projs_dne = []
491
- projs_dne << projs.delete('foreign_key_migrations')
335
+ projs_dne = []
336
+ projs_dne << projs.delete('redhillonrails_core')
492
337
 
493
- mp.assert_e_dne_i_ni proc{|a|assert(a)}, projs, projs_dne, projs_i, projs_ni
494
- end
338
+ mp.assert_e_dne_i_ni proc{|a|assert(a)}, projs, projs_dne, projs_i, projs_ni
495
339
  end
496
340
  end
497
341
  end
498
- end
499
342
 
343
+ end
500
344
  end
501
345
  end