autobuild 1.10.0.b4 → 1.10.0.rc1

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,144 +0,0 @@
1
- require 'autobuild/test'
2
-
3
- describe Autobuild::SVN do
4
- attr_reader :svnrepo, :svnroot, :pkg_svn
5
-
6
- before do
7
- untar('svnroot.tar')
8
- @svnrepo = File.join(tempdir, 'svnroot')
9
- @svnroot = "file://#{svnrepo}/svn"
10
- @pkg_svn = Autobuild::Package.new 'svn'
11
- pkg_svn.srcdir = File.join(tempdir, 'svn')
12
- end
13
-
14
- describe "checkout" do
15
- it "checks out the repository if the working copy does not exist" do
16
- importer = Autobuild.svn(svnroot)
17
- importer.import(pkg_svn)
18
- assert File.exist?(File.join(pkg_svn.srcdir, 'test'))
19
- end
20
-
21
- it "fails if the repository does not exist" do
22
- importer = Autobuild.svn("file:///does/not/exist")
23
- assert_raises(Autobuild::SubcommandFailed) { importer.import(pkg_svn) }
24
- end
25
-
26
- it "checks out a specific revision" do
27
- importer = Autobuild.svn(svnroot, revision: 1)
28
- importer.import(pkg_svn)
29
- assert_equal 1, importer.svn_revision(pkg_svn)
30
- end
31
- end
32
-
33
- describe "update" do
34
- it "fails with SubcommandFailed if the repository does not exist" do
35
- importer = Autobuild.svn(svnroot)
36
- importer.import(pkg_svn)
37
- FileUtils.rm_rf svnrepo
38
- assert_raises(Autobuild::SubcommandFailed) { importer.import(pkg_svn) }
39
- end
40
-
41
- it "fails if the working copy is not a svn working copy" do
42
- importer = Autobuild.svn(svnroot)
43
- FileUtils.mkdir_p pkg_svn.srcdir
44
- assert_raises(Autobuild::SubcommandFailed) { importer.import(pkg_svn) }
45
- end
46
-
47
- it "updates the working copy" do
48
- importer = Autobuild.svn(svnroot, revision: 1)
49
- importer.import(pkg_svn)
50
- importer.relocate(importer.svnroot, revision: nil)
51
- importer.import(pkg_svn)
52
- assert_equal 3, importer.svn_revision(pkg_svn)
53
- end
54
-
55
- it "updates if the target revision is not present even if reset is false" do
56
- importer = Autobuild.svn(svnroot, revision: 1)
57
- importer.import(pkg_svn)
58
- importer.relocate(importer.svnroot, revision: 2)
59
- importer.import(pkg_svn, reset: false)
60
- assert_equal 2, importer.svn_revision(pkg_svn)
61
- end
62
-
63
- it "does nothing if the target revision is present and reset is false" do
64
- importer = Autobuild.svn(svnroot, revision: 2)
65
- importer.import(pkg_svn)
66
- importer.relocate(importer.svnroot, revision: 1)
67
- importer.import(pkg_svn, reset: false)
68
- assert_equal 2, importer.svn_revision(pkg_svn)
69
- end
70
-
71
- it "resets to the specified revision if reset is true" do
72
- importer = Autobuild.svn(svnroot, revision: 2)
73
- importer.import(pkg_svn)
74
- importer.relocate(importer.svnroot, revision: 1)
75
- importer.import(pkg_svn, reset: true)
76
- assert_equal 1, importer.svn_revision(pkg_svn)
77
- end
78
-
79
- it "fails if the svnroot is not the same than the WC's svnroot" do
80
- importer = Autobuild.svn(svnroot, revision: 1)
81
- importer.import(pkg_svn)
82
- FileUtils.mv svnrepo, "#{svnrepo}.2"
83
- importer = Autobuild.svn("file://#{svnrepo}.2/svn")
84
- assert_raises(Autobuild::ConfigException) { importer.import(pkg_svn) }
85
- end
86
- end
87
-
88
- describe "svn_revision" do
89
- it "returns the current checkout revision" do
90
- importer = Autobuild.svn(svnroot, revision: 2)
91
- importer.import(pkg_svn)
92
- assert_equal 2, importer.svn_revision(pkg_svn)
93
- end
94
- end
95
-
96
- describe "status" do
97
- it "lists the log entries that are on the remote but not locally" do
98
- importer = Autobuild.svn(svnroot, revision: 1)
99
- importer.import(pkg_svn)
100
- importer.relocate(importer.svnroot, revision: nil)
101
- status = importer.status(pkg_svn)
102
- assert_equal 2, status.remote_commits.size
103
- assert(/second revision/ === status.remote_commits[0], status.remote_commits[0])
104
- end
105
-
106
- it "indicates if there are no local modifications" do
107
- importer = Autobuild.svn(svnroot, revision: 1)
108
- importer.import(pkg_svn)
109
- assert !importer.status(pkg_svn).uncommitted_code
110
- end
111
-
112
- it "indicates if there are modified files" do
113
- importer = Autobuild.svn(svnroot)
114
- importer.import(pkg_svn)
115
- File.open(File.join(pkg_svn.srcdir, "test"), 'a') do |io|
116
- io.puts "newline"
117
- end
118
- assert importer.status(pkg_svn).uncommitted_code
119
- end
120
-
121
- it "indicates if there are added files" do
122
- importer = Autobuild.svn(svnroot)
123
- importer.import(pkg_svn)
124
- FileUtils.touch File.join(pkg_svn.srcdir, "test3")
125
- importer.run_svn(pkg_svn, "add", "test3")
126
- assert importer.status(pkg_svn).uncommitted_code
127
- end
128
-
129
- it "indicates if there are removed files" do
130
- importer = Autobuild.svn(svnroot)
131
- importer.import(pkg_svn)
132
- importer.run_svn(pkg_svn, "rm", "test")
133
- assert importer.status(pkg_svn).uncommitted_code
134
- end
135
-
136
- it "indicates if there are moved files" do
137
- importer = Autobuild.svn(svnroot)
138
- importer.import(pkg_svn)
139
- importer.run_svn(pkg_svn, "mv", "test", 'test3')
140
- assert importer.status(pkg_svn).uncommitted_code
141
- end
142
- end
143
- end
144
-
@@ -1,95 +0,0 @@
1
- require 'autobuild/test'
2
- require 'webrick'
3
-
4
- class TC_TarImporter < Minitest::Test
5
- include Autobuild
6
- include WEBrick
7
-
8
- def setup
9
- super
10
-
11
- Autobuild.logdir = "#{tempdir}/log"
12
- FileUtils.mkdir_p(Autobuild.logdir)
13
-
14
- @datadir = File.join(tempdir, 'data')
15
- FileUtils.mkdir_p(@datadir)
16
- @tarfile = File.join(@datadir, 'tarimport.tar.gz')
17
- FileUtils.cp(File.join(data_dir, 'tarimport.tar.gz'), @tarfile)
18
-
19
- @cachedir = File.join(tempdir, 'cache')
20
- end
21
-
22
- def test_tar_mode
23
- assert_equal(TarImporter::Plain, TarImporter.filename_to_mode('tarfile.tar'))
24
- assert_equal(TarImporter::Gzip, TarImporter.filename_to_mode('tarfile.tar.gz'))
25
- assert_equal(TarImporter::Bzip, TarImporter.filename_to_mode('tarfile.tar.bz2'))
26
- end
27
-
28
- def test_it_sets_the_repository_id_to_the_normalized_URL
29
- importer = TarImporter.new "FILE://test/file"
30
- assert_equal "file://test/file", importer.repository_id.to_str
31
- end
32
-
33
- def test_it_sets_the_source_id_to_the_normalized_URL
34
- importer = TarImporter.new "FILE://test/file"
35
- assert_equal "file://test/file", importer.source_id.to_str
36
- end
37
-
38
- def test_it_does_not_delete_a_locally_specified_archive_on_error
39
- dummy_tar = File.join(@datadir, "dummy.tar")
40
- FileUtils.touch dummy_tar
41
- importer = TarImporter.new "file://#{dummy_tar}"
42
- pkg = Package.new 'tarimport'
43
- assert_raises(Autobuild::SubcommandFailed) { importer.checkout(pkg) }
44
- assert File.file?(dummy_tar)
45
- end
46
-
47
- def test_tar_valid_url
48
- assert_raises(ConfigException) {
49
- TarImporter.new 'ccc://localhost/files/tarimport.tar.gz', :cachedir => @cachedir
50
- }
51
- end
52
-
53
- def web_server
54
- s = HTTPServer.new :Port => 2000, :DocumentRoot => tempdir
55
- s.mount("/files", HTTPServlet::FileHandler, tempdir)
56
- webrick = Thread.new { s.start }
57
-
58
- yield
59
-
60
- ensure
61
- s.shutdown
62
- end
63
-
64
- def test_tar_remote
65
- web_server do
66
- # Try to get the file through the http server
67
- pkg = Package.new 'tarimport'
68
- pkg.srcdir = File.join(tempdir, 'tarimport')
69
- importer = TarImporter.new 'http://localhost:2000/files/data/tarimport.tar.gz',
70
- cachedir: @cachedir,
71
- update_cached_file: true
72
-
73
- importer.checkout(pkg)
74
- assert(File.directory?(pkg.srcdir))
75
- assert(!importer.update_cache(pkg))
76
-
77
- sleep 2 # The Time class have a 1-second resolution
78
- FileUtils.touch @tarfile
79
- assert(importer.update_cache(pkg))
80
- assert(!importer.update_cache(pkg))
81
- end
82
- end
83
-
84
- def test_tar_remote_notfound
85
- web_server do
86
- # Try to get the file through the http server
87
- pkg = Package.new 'tarimport'
88
- pkg.srcdir = File.join(tempdir, 'tarimport')
89
- importer = TarImporter.new 'http://localhost:2000/files/data/tarimport-nofile.tar.gz', :cachedir => @cachedir
90
-
91
- assert_raises(Autobuild::SubcommandFailed) { importer.checkout(pkg) }
92
- end
93
- end
94
- end
95
-
@@ -1,7 +0,0 @@
1
- require 'autobuild/test'
2
- require 'test/test_reporting'
3
- require 'test/test_subcommand'
4
- require 'test/import/test_cvs'
5
- require 'test/import/test_git'
6
- require 'test/import/test_svn'
7
- require 'test/import/test_tar'
@@ -1,79 +0,0 @@
1
- require 'autobuild/test'
2
- require 'fakefs/safe'
3
- require 'flexmock'
4
-
5
- describe Autobuild do
6
-
7
- describe "tool" do
8
- after do
9
- Autobuild.programs.delete('test')
10
- end
11
-
12
- it "should return the tool name by default" do
13
- assert_equal 'a_test_name', Autobuild.tool('a_test_name')
14
- end
15
- it "should return the default tool name as a string" do
16
- assert_equal 'a_test_name', Autobuild.tool(:a_test_name)
17
- end
18
- it "should be indifferent whether a tool is overriden using symbols or strings" do
19
- Autobuild.programs['test'] = 'a_test_name'
20
- assert_equal 'a_test_name', Autobuild.tool('test')
21
- assert_equal 'a_test_name', Autobuild.tool(:test)
22
- Autobuild.programs[:test] = 'a_test_name'
23
- assert_equal 'a_test_name', Autobuild.tool('test')
24
- assert_equal 'a_test_name', Autobuild.tool(:test)
25
- end
26
- end
27
-
28
- describe "tool_in_path" do
29
- before do
30
- FakeFS.activate!
31
- flexmock(Autobuild).should_receive(:tool).with('bla').and_return('a_test_name').by_default
32
- flexmock(ENV).should_receive('[]').with('PATH').and_return('/a/path')
33
- flexmock(ENV).should_receive('[]').with(any).pass_thru
34
- FileUtils.mkdir_p('/a/path')
35
- end
36
- after do
37
- FakeFS.deactivate!
38
- FakeFS::FileSystem.clear
39
- Autobuild.programs_in_path.delete('bla')
40
- end
41
-
42
- it "should raise ArgumentError if the tool is not present in path" do
43
- assert_raises(ArgumentError) { Autobuild.tool_in_path('bla') }
44
- end
45
- it "should raise ArgumentError if the tool is present in path but is not a file" do
46
- FileUtils.mkdir_p('/a/path/a_test_name')
47
- assert_raises(ArgumentError) { Autobuild.tool_in_path('bla') }
48
- end
49
- it "should raise ArgumentError if the tool is present in path but is not executable" do
50
- FileUtils.touch('/a/path/a_test_name')
51
- FileUtils.chmod(0, '/a/path/a_test_name')
52
- assert_raises(ArgumentError) { Autobuild.tool_in_path('bla') }
53
- end
54
- it "should return the full path to the resolved tool ArgumentError if the tool is present in path but is not executable" do
55
- FileUtils.touch('/a/path/a_test_name')
56
- FileUtils.chmod(0755, '/a/path/a_test_name')
57
- assert_equal '/a/path/a_test_name', Autobuild.tool_in_path('bla')
58
- end
59
- it "should update the cache to the resolved value" do
60
- FileUtils.touch('/a/path/a_test_name')
61
- FileUtils.chmod(0755, '/a/path/a_test_name')
62
- Autobuild.tool_in_path('bla')
63
- assert_equal ['/a/path/a_test_name', 'a_test_name', ENV['PATH']], Autobuild.programs_in_path['bla'], "cached value mismatch"
64
- end
65
- it "should not re-hit the filesystem if the cache is up to date" do
66
- Autobuild.programs_in_path['bla'] = ['bla', 'a_test_name', ENV['PATH']]
67
- assert_equal 'bla', Autobuild.tool_in_path('bla')
68
- end
69
- it "should work fine if the tool is set to a full path" do
70
- flexmock(Autobuild).should_receive(:tool).with('bla').and_return('/another/path/a_test_name')
71
- FileUtils.mkdir_p('/another/path')
72
- FileUtils.touch('/another/path/a_test_name')
73
- FileUtils.chmod(0755, '/another/path/a_test_name')
74
- assert_equal '/another/path/a_test_name', Autobuild.tool_in_path('bla')
75
- end
76
- end
77
- end
78
-
79
-
@@ -1,88 +0,0 @@
1
- require 'autobuild/test'
2
-
3
- describe 'Autobuild environment management' do
4
- after do
5
- Autobuild.env_reset 'AUTOBUILD_TEST'
6
- Autobuild.env_inherit 'AUTOBUILD_TEST', false
7
- end
8
-
9
- describe "an inherited environment variable" do
10
- before do
11
- Autobuild::ORIGINAL_ENV['AUTOBUILD_TEST'] = "val1:val0"
12
- Autobuild.env_inherit 'AUTOBUILD_TEST'
13
- end
14
- describe "#env_push_path" do
15
- it "does not re-read the inherited environment" do
16
- end
17
- it "adds the new path at the beginning of the variable, before the inherited environment" do
18
- Autobuild.env_push_path 'AUTOBUILD_TEST', 'newval1'
19
- Autobuild.env_push_path 'AUTOBUILD_TEST', 'newval0'
20
- assert_equal 'newval1:newval0:val1:val0',
21
- ENV['AUTOBUILD_TEST']
22
- end
23
- end
24
- describe "#env_add_path" do
25
- it "does not re-read the inherited environment" do
26
- Autobuild::ORIGINAL_ENV['AUTOBUILD_TEST'] = 'val2:val3'
27
- Autobuild.env_add_path 'AUTOBUILD_TEST', 'newval'
28
- assert_equal 'newval:val1:val0',
29
- ENV['AUTOBUILD_TEST']
30
- end
31
- it "adds the new path at the end of the variable, before the inherited environment" do
32
- Autobuild.env_add_path 'AUTOBUILD_TEST', 'newval0'
33
- Autobuild.env_add_path 'AUTOBUILD_TEST', 'newval1'
34
- assert_equal 'newval1:newval0:val1:val0',
35
- ENV['AUTOBUILD_TEST']
36
- end
37
- end
38
- describe "#env_set" do
39
- it "does not reinitialize the inherited environment" do
40
- Autobuild::ORIGINAL_ENV['AUTOBUILD_TEST'] = 'val2:val3'
41
- Autobuild.env_set 'AUTOBUILD_TEST', 'newval'
42
- assert_equal 'newval:val1:val0', ENV['AUTOBUILD_TEST']
43
- end
44
- it "resets the current value to the expected one" do
45
- Autobuild.env_set 'AUTOBUILD_TEST', 'newval0', 'newval1'
46
- assert_equal 'newval0:newval1:val1:val0', ENV['AUTOBUILD_TEST']
47
- Autobuild.env_set 'AUTOBUILD_TEST', 'newval2', 'newval3'
48
- assert_equal 'newval2:newval3:val1:val0', ENV['AUTOBUILD_TEST']
49
- end
50
- end
51
- describe "#env_clear" do
52
- it "completely unsets the variable" do
53
- Autobuild.env_clear 'AUTOBUILD_TEST'
54
- assert !ENV.include?('AUTOBUILD_TEST')
55
- end
56
- end
57
- end
58
-
59
- describe "a not-inherited environment variable" do
60
- before do
61
- Autobuild::ORIGINAL_ENV['AUTOBUILD_TEST'] = "val1:val0"
62
- Autobuild.env_reset 'AUTOBUILD_TEST'
63
- end
64
-
65
- describe "#env_push_path" do
66
- it "adds the new path at the beginning of the variable" do
67
- Autobuild.env_push_path 'AUTOBUILD_TEST', 'newval1'
68
- Autobuild.env_push_path 'AUTOBUILD_TEST', 'newval0'
69
- assert_equal 'newval1:newval0',
70
- ENV['AUTOBUILD_TEST']
71
- end
72
- end
73
- describe "#env_add_path" do
74
- it "adds the new path at the end of the variable" do
75
- Autobuild.env_add_path 'AUTOBUILD_TEST', 'newval0'
76
- Autobuild.env_add_path 'AUTOBUILD_TEST', 'newval1'
77
- assert_equal 'newval1:newval0',
78
- ENV['AUTOBUILD_TEST']
79
- end
80
- end
81
- describe "#env_clear" do
82
- it "completely unsets the variable" do
83
- Autobuild.env_clear 'AUTOBUILD_TEST'
84
- assert !ENV.include?('AUTOBUILD_TEST')
85
- end
86
- end
87
- end
88
- end
@@ -1,43 +0,0 @@
1
- require 'autobuild/test'
2
-
3
- class TC_Reporting < Minitest::Test
4
- def test_format_progress_message_does_not_touch_messages_without_prefix
5
- assert_equal "a | b | c",
6
- Autobuild.format_progress_message(%w{a b c})
7
- end
8
- def test_format_progress_message_find_common_prefix_at_beginning
9
- assert_equal "X a, b | c",
10
- Autobuild.format_progress_message(["X a", "X b", "c"])
11
- end
12
- def test_format_progress_message_picks_up_bigger_prefix
13
- assert_equal "X a | X y b, c | d",
14
- Autobuild.format_progress_message(["X a", "X y b", "X y c", "d"])
15
- end
16
- def test_format_progress_message_prefix_comparison_uses_string_length
17
- assert_equal "X mmmmmmmmmm a, b | X my x c | d",
18
- Autobuild.format_progress_message(["X mmmmmmmmmm a", "X mmmmmmmmmm b", "X my x c", "d"])
19
- end
20
- def test_package_message_with_marker_inside_token
21
- package = Autobuild::Package.new('pkg')
22
- assert_equal 'patching pkg: unapplying', package.process_formatting_string('patching %s: unapplying')
23
- end
24
- def test_package_message_with_marker_at_beginning
25
- package = Autobuild::Package.new('pkg')
26
- assert_equal 'pkg unapplying', package.process_formatting_string('%s unapplying')
27
- end
28
- def test_package_message_with_marker_at_end
29
- package = Autobuild::Package.new('pkg')
30
- assert_equal 'patching pkg', package.process_formatting_string('patching %s')
31
- end
32
- def test_package_message_without_formatting
33
- flexmock(Autobuild).should_receive('color').never
34
- package = Autobuild::Package.new('pkg')
35
- assert_equal 'patching a package pkg', package.process_formatting_string('patching a package %s')
36
- end
37
- def test_package_message_with_formatting
38
- flexmock(Autobuild).should_receive('color').with('patching a package', :bold, :red).and_return('|patching a package|').once
39
- package = Autobuild::Package.new('pkg')
40
- assert_equal '|patching a package| pkg', package.process_formatting_string('patching a package %s', :bold, :red)
41
- end
42
- end
43
-