ext 1.1.3 → 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,176 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') if $0 == __FILE__
2
- require 'ext_test_case'
3
- require 'externals/ext'
4
- require 'rails_app_git_repository'
5
- require 'basic_git_repository'
6
- require 'modules_svn_branches_repository'
7
-
8
- module Externals
9
- module Test
10
- class TestFreezeToRevision < ::Test::Unit::TestCase
11
- include ExtTestCase
12
-
13
- def test_freeze_to_revision
14
- repository = RailsAppGitRepository.new
15
- repository.prepare
16
-
17
- assert File.exist?(repository.clean_dir)
18
-
19
- workdir = File.join(root_dir, 'test', "tmp", "workdir", "checkout", "git")
20
- mkdir_p workdir
21
-
22
- Dir.chdir workdir do
23
- rm_r repository.name if File.exist?(repository.name)
24
- source = repository.clean_dir
25
- puts "About to checkout #{source}"
26
- Ext.run "checkout", "--git", source
27
-
28
- Dir.chdir repository.name do
29
- assert File.exist?('.git')
30
-
31
- assert File.exist?('.gitignore')
32
-
33
- %w(foreign_key_migrations redhillonrails_core acts_as_list).each do |proj|
34
- assert(File.read('.gitignore') =~ /^vendor[\/\\]plugins[\/\\]#{proj}$/)
35
- end
36
-
37
- Dir.chdir File.join('vendor', 'plugins') do
38
- Dir.chdir 'acts_as_list' do
39
- %w(8771a632dc26a7782800347993869c964133ea29
40
- 27a941c80ccaa8afeb9bfecb84c0ff098d8ba962
41
- 9baff190a52c05cc542bfcaa7f77a91ce669f2f8
42
- ).each do |hash|
43
- assert `git show #{hash}` =~ /^commit\s*#{hash}$/i
44
- raise unless $? == 0
45
- end
46
- end
47
-
48
- Dir.chdir 'foreign_key_migrations' do
49
- assert `svn info` =~ /^.*:\s*2\s*$/i
50
- end
51
- end
52
-
53
- ext = Ext.new
54
- acts_as_list = ext.subproject("acts_as_list")
55
-
56
- assert `git show HEAD` !~ /^\s*commit\s*8771a632dc26a7782800347993869c964133ea29\s*$/i
57
- raise unless $? == 0
58
- r = repository.dependents[:acts_as_list].attributes[:revision]
59
- assert r =~ /^[a-f0-9]{40}$/
60
- assert_equal r,
61
- acts_as_list.current_revision
62
- `git show HEAD` =~ /^\s*commit\s*#{r}\s*$/i
63
- raise unless $? == 0
64
-
65
- %w(foreign_key_migrations redhillonrails_core acts_as_list).each do |proj|
66
- assert File.exist?(File.join('vendor', 'plugins', proj, 'lib'))
67
- end
68
- end
69
- end
70
- end
71
-
72
- def test_svn_freeze_with_branch
73
- repository = BasicGitRepository.new
74
- repository.prepare
75
-
76
- sub_repository = ModulesSvnBranchesRepository.new
77
- sub_repository.prepare
78
-
79
- assert File.exist?(repository.clean_dir)
80
-
81
- workdir = File.join(root_dir, 'test', "tmp", "workdir", "checkout", "git")
82
- mkdir_p workdir
83
-
84
- Dir.chdir workdir do
85
- rm_r repository.name if File.exist?(repository.name)
86
- source = repository.clean_dir
87
-
88
- puts "About to checkout #{source}"
89
- `git clone #{source}`
90
- raise unless $? == 0
91
-
92
-
93
- Dir.chdir repository.name do
94
- Ext.run "init"
95
-
96
- sub_source = sub_repository.clean_url
97
- Ext.run "install", "--svn", sub_source, "-b", "branches/branch2", "modules"
98
-
99
- ext = Ext.new
100
- subproject = ext.subproject_by_name_or_path("modules")
101
-
102
- assert_equal subproject.current_branch, "branches/branch2"
103
- assert_equal subproject.current_revision, "4"
104
-
105
- # let's freeze the revision to 3
106
- Ext.run "freeze", "modules", "3"
107
- assert_equal subproject.current_revision, "3"
108
-
109
- # let's check this stuff in to test checking it out...
110
- `git add .gitignore .externals`
111
- raise unless $? == 0
112
-
113
- repository.mark_dirty
114
-
115
- `git commit -m "froze modules to revision 3"`
116
- raise unless $? == 0
117
- `git push`
118
- raise unless $? == 0
119
- end
120
- end
121
-
122
- rm_rf workdir
123
- mkdir_p workdir
124
-
125
- Dir.chdir workdir do
126
- rm_r repository.name if File.exist?(repository.name)
127
- source = repository.clean_dir
128
-
129
- puts "About to checkout #{source}"
130
- Ext.run "checkout", "--git", source
131
-
132
- Dir.chdir repository.name do
133
- ext = Ext.new
134
- subproject = ext.subproject_by_name_or_path("modules")
135
-
136
- assert_equal subproject.current_branch, "branches/branch2"
137
- assert_equal subproject.current_revision, "3"
138
-
139
- # now let's test unfreezing...
140
- Ext.run "unfreeze", "modules"
141
- assert_equal subproject.current_branch, "branches/branch2"
142
- assert_equal subproject.current_revision, "4"
143
-
144
- # Check it in to make sure it sticks
145
- `git add .externals`
146
- raise unless $? == 0
147
- `git commit -m "unfreezing modules"`
148
- raise unless $? == 0
149
- `git push`
150
- raise unless $? == 0
151
- end
152
- end
153
-
154
- rm_rf workdir
155
- mkdir_p workdir
156
-
157
- Dir.chdir workdir do
158
- rm_r repository.name if File.exist?(repository.name)
159
- source = repository.clean_dir
160
-
161
- puts "About to checkout #{source}"
162
- Ext.run "checkout", "--git", source
163
-
164
- Dir.chdir repository.name do
165
- ext = Ext.new
166
- subproject = ext.subproject_by_name_or_path("modules")
167
-
168
- assert_equal subproject.current_branch, "branches/branch2"
169
- assert_equal subproject.current_revision, "4"
170
- end
171
- end
172
- end
173
-
174
- end
175
- end
176
- end
@@ -1,20 +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 TestGitProjectExtractName < ::Test::Unit::TestCase
9
- include ExtTestCase
10
-
11
- def test_extract_name
12
- project = Externals::GitProject.new({})
13
- assert_equal "test", project.extract_name("git://domain.com/test.git")
14
- assert_equal "test", project.extract_name("git@domain.com:test.git")
15
- assert_equal "test", project.extract_name("test.git")
16
- assert_equal "test", project.extract_name("test")
17
- end
18
- end
19
- end
20
- end
data/test/test_help.rb DELETED
@@ -1,27 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') if $0 == __FILE__
2
- require 'ext_test_case'
3
- require 'externals/ext'
4
- require 'basic_git_repository'
5
-
6
- module Externals
7
- module Test
8
- class TestHelp < ::Test::Unit::TestCase
9
- include ExtTestCase
10
-
11
- def test_help
12
- capture = StringIO.new
13
- begin
14
- $stdout = capture
15
-
16
- Ext.run "help"
17
- ensure
18
- $stdout = STDOUT
19
- end
20
- capture = capture.string
21
-
22
-
23
- assert capture =~ /ext \[OPTIONS\] <command>/
24
- end
25
- end
26
- end
27
- end
@@ -1,62 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') if $0 == __FILE__
2
- require 'ext_test_case'
3
- require 'externals/ext'
4
- require 'basic_git_repository'
5
-
6
- module Externals
7
- module Test
8
- class TestInitGit < ::Test::Unit::TestCase
9
- include ExtTestCase
10
-
11
- def setup
12
- repository = BasicGitRepository.new
13
- repository.prepare
14
-
15
- assert File.exist?(repository.clean_dir)
16
-
17
- workdir = File.join(root_dir, 'test', "tmp", "workdir")
18
- mkdir_p workdir
19
-
20
- Dir.chdir workdir do
21
- delete_if_dirty(repository.name)
22
- if !File.exist?(repository.name)
23
- `git clone #{repository.clean_dir} #{repository.name}`
24
- raise unless $? == 0
25
- end
26
-
27
- mark_dirty(repository.name)
28
- end
29
-
30
- @workdir = workdir
31
- @repository = repository
32
- end
33
-
34
- def test_init
35
- Dir.chdir @workdir do
36
- Dir.chdir @repository.name do
37
- assert !File.exist?('.externals')
38
-
39
- rescue_exit { Ext.run "init" }
40
-
41
- config = Externals::Configuration::Configuration.new(File.read('.externals'))
42
- assert_equal(config['.']['scm'], 'git')
43
- end
44
- end
45
- end
46
-
47
- def test_init_rails_project
48
- Dir.chdir @workdir do
49
- Dir.chdir @repository.name do
50
- assert !File.exist?('.externals')
51
-
52
- rescue_exit { Ext.run "init", "--type", "rails" }
53
-
54
- config = Externals::Configuration::Configuration.new(File.read('.externals'))
55
- assert_equal(config['.']['scm'], 'git')
56
- assert_equal(config['.']['type'], 'rails')
57
- end
58
- end
59
- end
60
- end
61
- end
62
- end
@@ -1,83 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') if $0 == __FILE__
2
- require 'ext_test_case'
3
- require 'externals/ext'
4
- require 'simple_git_with_sub'
5
-
6
- module Externals
7
- module Test
8
- class TestOutOfDateGitSubproject < ::Test::Unit::TestCase
9
- include ExtTestCase
10
-
11
- def test_out_of_date_sub
12
- repository = SimpleGitWithSub.new
13
- repository.prepare
14
-
15
- assert File.exist?(repository.clean_dir)
16
-
17
- workdir = File.join(root_dir, 'test', "tmp", "workdir")
18
- mkdir_p workdir
19
-
20
- Dir.chdir workdir do
21
- if File.exist?(repository.name)
22
- rm_rf repository.name
23
- end
24
-
25
- Ext.run "checkout", "--git", repository.clean_dir
26
-
27
- assert !File.exist?(File.join(repository.name, "readme.txt"))
28
- assert File.exist?(File.join(repository.name, "simple_readme.txt"))
29
- assert !File.exist?(File.join(
30
- repository.name, "subs", repository.dependents[:basic].name, "simple_readme.txt")
31
- )
32
- assert File.exist?(File.join(
33
- repository.name, "subs", repository.dependents[:basic].name, "readme.txt")
34
- )
35
-
36
- readme = File.read(File.join(
37
- repository.name, "subs", repository.dependents[:basic].name, "readme.txt"))
38
-
39
- assert readme =~ /Line 4/i
40
- assert readme !~ /Line 5/i
41
-
42
- # let's update the subproject and make sure that ext update works.
43
-
44
- tmp = "tmp_update_sub"
45
- rm_rf tmp
46
- mkdir tmp
47
- Dir.chdir tmp do
48
- `git clone #{repository.dependents[:basic].clean_dir}`
49
- raise unless $? == 0
50
-
51
- repository.dependents[:basic].mark_dirty
52
-
53
- Dir.chdir repository.dependents[:basic].name do
54
- open 'readme.txt', 'a' do |f|
55
- f.write "line 5"
56
- end
57
-
58
- `git add .`
59
- raise unless $? == 0
60
- `git commit -m "added line 5 to readme.txt"`
61
- raise unless $? == 0
62
- `git push`
63
- raise unless $? == 0
64
- end
65
- end
66
-
67
- rm_rf tmp
68
-
69
- Dir.chdir repository.name do
70
- Ext.run "update"
71
-
72
- readme = File.read(File.join(
73
- "subs", repository.dependents[:basic].name, "readme.txt"))
74
-
75
- assert readme =~ /Line 4/i
76
- assert readme =~ /Line 5/i
77
- assert readme !~ /Line 6/i
78
- end
79
- end
80
- end
81
- end
82
- end
83
- end
@@ -1,148 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') if $0 == __FILE__
2
- require 'ext_test_case'
3
- require 'externals/ext'
4
-
5
- module Externals
6
- module Test
7
- class TestProjects < ::Test::Unit::TestCase
8
- include ExtTestCase
9
-
10
- def test_project_scm
11
- assert_equal "svn", SvnProject.scm
12
- assert_equal "git", GitProject.scm
13
- assert_raise RuntimeError do
14
- Project.scm
15
- end
16
- end
17
-
18
- def test_svn_global_opts
19
- Dir.chdir File.join(root_dir, 'test') do
20
- rm_rf "test_svn_global_opts" if File.exist?("test_svn_global_opts")
21
- mkdir "test_svn_global_opts"
22
-
23
- begin
24
- Dir.chdir 'test_svn_global_opts' do
25
- open '.externals', 'w' do |f|
26
- f.write "[.]
27
- scm = git
28
- type = rails
29
-
30
- [vendor/plugins/acts_as_list]
31
- scm = git
32
- repository = git://github.com/rails/acts_as_list.git
33
- branch = edge
34
-
35
- [vendor/plugins/foreign_key_migrations]
36
- scm = svn
37
- repository = svn://rubyforge.org/var/svn/redhillonrails/trunk/vendor/plugins/foreign_key_migrations
38
- "
39
- end
40
-
41
- #test no scm_opts set...
42
-
43
- ext = Ext.new
44
-
45
- assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts, nil
46
- assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts_co, nil
47
- assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts_up, nil
48
- assert_equal ext.main_project.scm_opts, nil
49
- assert_equal ext.main_project.scm_opts_co, nil
50
- assert_equal ext.main_project.scm_opts_up, nil
51
- assert_equal ext.main_project.git_opts, nil
52
- assert_equal ext.main_project.svn_opts, nil
53
- assert_equal ext.main_project.git_opts_up, nil
54
- assert_equal ext.main_project.svn_opts_up, nil
55
-
56
-
57
- open '.externals', 'w' do |f|
58
- f.write "[.]
59
- scm = git
60
- type = rails
61
-
62
- [vendor/plugins/acts_as_list]
63
- scm_opts = --verbose
64
- scm = git
65
- repository = git://github.com/rails/acts_as_list.git
66
- branch = edge
67
-
68
- [vendor/plugins/foreign_key_migrations]
69
- scm_opts = --trust-server-cert --non-interactive
70
- scm = svn
71
- repository = svn://rubyforge.org/var/svn/redhillonrails/trunk/vendor/plugins/foreign_key_migrations
72
- "
73
- end
74
-
75
- #test scm_opts set... no _co, _up, etc.
76
-
77
- ext = Ext.new
78
-
79
- assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts, "--verbose"
80
- assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts_co, "--verbose"
81
- assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts_up, "--verbose"
82
- assert_equal ext.subproject_by_name_or_path('foreign_key_migrations').scm_opts,
83
- "--trust-server-cert --non-interactive"
84
- assert_equal ext.subproject_by_name_or_path('foreign_key_migrations').scm_opts_co,
85
- "--trust-server-cert --non-interactive"
86
- assert_equal ext.subproject_by_name_or_path('foreign_key_migrations').scm_opts_up,
87
- "--trust-server-cert --non-interactive"
88
- assert_equal ext.main_project.scm_opts, nil
89
- assert_equal ext.main_project.scm_opts_co, nil
90
- assert_equal ext.main_project.scm_opts_up, nil
91
- assert_equal ext.main_project.git_opts, nil
92
- assert_equal ext.main_project.svn_opts, nil
93
- assert_equal ext.main_project.git_opts_up, nil
94
- assert_equal ext.main_project.svn_opts_up, nil
95
-
96
- #test global options and specific action options
97
- open '.externals', 'w' do |f|
98
- f.write "[.]
99
- scm = git
100
- type = rails
101
- svn_opts = --trust-server-cert
102
- svn_opts_up = --svn-up
103
- git_opts = --verbose
104
- scm_opts = --main-project-opts
105
-
106
- [vendor/plugins/acts_as_list]
107
- scm_opts_up = --made-up-option
108
- scm = git
109
- repository = git://github.com/rails/acts_as_list.git
110
- branch = edge
111
-
112
- [vendor/plugins/foreign_key_migrations]
113
- scm_opts_co = --non-interactive
114
- scm = svn
115
- repository = svn://rubyforge.org/var/svn/redhillonrails/trunk/vendor/plugins/foreign_key_migrations
116
- "
117
- end
118
-
119
- ext = Ext.new
120
-
121
- assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts, "--verbose"
122
- assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts_co, "--verbose"
123
- assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts_up,
124
- "--made-up-option --verbose"
125
- assert_equal ext.subproject_by_name_or_path('foreign_key_migrations').scm_opts,
126
- "--trust-server-cert"
127
- assert_equal ext.subproject_by_name_or_path('foreign_key_migrations').scm_opts_co,
128
- "--non-interactive --trust-server-cert"
129
- assert_equal ext.subproject_by_name_or_path('foreign_key_migrations').scm_opts_up,
130
- "--svn-up --trust-server-cert"
131
- assert_equal ext.main_project.scm_opts, "--main-project-opts --verbose"
132
- assert_equal ext.main_project.scm_opts_co, "--main-project-opts --verbose"
133
- assert_equal ext.main_project.scm_opts_up, "--main-project-opts --verbose"
134
- assert_equal ext.main_project.git_opts, "--verbose"
135
- assert_equal ext.main_project.svn_opts, "--trust-server-cert"
136
- assert_equal ext.main_project.git_opts_up, "--verbose"
137
- assert_equal ext.main_project.svn_opts_up, "--svn-up --trust-server-cert"
138
-
139
- end
140
- ensure
141
- rm_rf "test_svn_global_opts" if File.exist?("test_svn_global_opts")
142
- end
143
-
144
- end
145
- end
146
- end
147
- end
148
- end
@@ -1,23 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__),'..','lib') if $0 == __FILE__
2
-
3
- require 'ext_test_case'
4
- require 'externals/ext'
5
- require 'rails_app_unmanaged'
6
-
7
- module Externals
8
- module Test
9
- class TestRailsDetection < ::Test::Unit::TestCase
10
- include ExtTestCase
11
-
12
- def test_detection
13
- repository = RailsAppUnmanaged.new
14
- detector = Ext.project_type_detector('rails')
15
-
16
- assert !detector.detected?
17
- Dir.chdir(repository.clean_dir) do
18
- assert detector.detected?
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,51 +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 TestStringExtensions < ::Test::Unit::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
17
-
18
- def test_lines_by_width
19
- assert_equal [
20
- "this",
21
- "is a",
22
- "test"
23
- ],
24
- "this is a test".lines_by_width(4)
25
-
26
- assert_equal [
27
- "this",
28
- "is",
29
- "a",
30
- "test"
31
- ],
32
- "this is a test".lines_by_width(2)
33
-
34
- assert_equal ["this is a test"], "this is a test".lines_by_width
35
-
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
46
- cannot execute ext from the main project's directory (or if it's just inconvenient, such as in a script
47
- or in a Capistrano task)".lines_by_width
48
- end
49
- end
50
- end
51
- end