autobuild 1.8.3 → 1.9.0.b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/Manifest.txt +16 -7
  3. data/Rakefile +2 -0
  4. data/lib/autobuild/config.rb +21 -6
  5. data/lib/autobuild/configurable.rb +2 -2
  6. data/lib/autobuild/environment.rb +52 -27
  7. data/lib/autobuild/exceptions.rb +48 -22
  8. data/lib/autobuild/import/archive.rb +37 -16
  9. data/lib/autobuild/import/cvs.rb +26 -28
  10. data/lib/autobuild/import/darcs.rb +9 -8
  11. data/lib/autobuild/import/git.rb +324 -217
  12. data/lib/autobuild/import/hg.rb +6 -9
  13. data/lib/autobuild/import/svn.rb +190 -47
  14. data/lib/autobuild/importer.rb +80 -35
  15. data/lib/autobuild/package.rb +16 -35
  16. data/lib/autobuild/packages/autotools.rb +8 -8
  17. data/lib/autobuild/packages/cmake.rb +18 -12
  18. data/lib/autobuild/packages/genom.rb +1 -1
  19. data/lib/autobuild/packages/gnumake.rb +11 -12
  20. data/lib/autobuild/packages/orogen.rb +1 -1
  21. data/lib/autobuild/packages/ruby.rb +9 -5
  22. data/lib/autobuild/reporting.rb +10 -6
  23. data/lib/autobuild/subcommand.rb +110 -50
  24. data/lib/autobuild/test.rb +104 -0
  25. data/lib/autobuild/timestamps.rb +3 -3
  26. data/lib/autobuild/tools.rb +1 -1
  27. data/lib/autobuild/utility.rb +22 -10
  28. data/lib/autobuild/version.rb +1 -1
  29. data/test/data/gitrepo-with-extra-commit-and-tag.tar +0 -0
  30. data/test/data/gitrepo.tar +0 -0
  31. data/test/data/gitrepo/test +0 -0
  32. data/test/data/gitrepo/test2 +0 -0
  33. data/test/data/gitrepo/test3 +0 -0
  34. data/test/data/svnroot.tar +0 -0
  35. data/test/import/test_cvs.rb +51 -0
  36. data/test/import/test_git.rb +364 -0
  37. data/test/import/test_svn.rb +144 -0
  38. data/test/import/test_tar.rb +76 -0
  39. data/test/suite.rb +7 -0
  40. data/test/test_config.rb +1 -5
  41. data/test/test_environment.rb +88 -0
  42. data/test/test_reporting.rb +2 -14
  43. data/test/test_subcommand.rb +7 -22
  44. metadata +17 -14
  45. data/test/test_import_cvs.rb +0 -59
  46. data/test/test_import_svn.rb +0 -56
  47. data/test/test_import_tar.rb +0 -83
  48. data/test/tools.rb +0 -44
@@ -0,0 +1,144 @@
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
+
@@ -0,0 +1,76 @@
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_tar_valid_url
29
+ assert_raises(ConfigException) {
30
+ TarImporter.new 'ccc://localhost/files/tarimport.tar.gz', :cachedir => @cachedir
31
+ }
32
+ end
33
+
34
+ def web_server
35
+ s = HTTPServer.new :Port => 2000, :DocumentRoot => tempdir
36
+ s.mount("/files", HTTPServlet::FileHandler, tempdir)
37
+ webrick = Thread.new { s.start }
38
+
39
+ yield
40
+
41
+ ensure
42
+ s.shutdown
43
+ end
44
+
45
+ def test_tar_remote
46
+ web_server do
47
+ # Try to get the file through the http server
48
+ pkg = Package.new 'tarimport'
49
+ pkg.srcdir = File.join(tempdir, 'tarimport')
50
+ importer = TarImporter.new 'http://localhost:2000/files/data/tarimport.tar.gz',
51
+ cachedir: @cachedir,
52
+ update_cached_file: true
53
+
54
+ importer.checkout(pkg)
55
+ assert(File.directory?(pkg.srcdir))
56
+ assert(!importer.update_cache(pkg))
57
+
58
+ sleep 2 # The Time class have a 1-second resolution
59
+ FileUtils.touch @tarfile
60
+ assert(importer.update_cache(pkg))
61
+ assert(!importer.update_cache(pkg))
62
+ end
63
+ end
64
+
65
+ def test_tar_remote_notfound
66
+ web_server do
67
+ # Try to get the file through the http server
68
+ pkg = Package.new 'tarimport'
69
+ pkg.srcdir = File.join(tempdir, 'tarimport')
70
+ importer = TarImporter.new 'http://localhost:2000/files/data/tarimport-nofile.tar.gz', :cachedir => @cachedir
71
+
72
+ assert_raises(Autobuild::SubcommandFailed) { importer.checkout(pkg) }
73
+ end
74
+ end
75
+ end
76
+
data/test/suite.rb ADDED
@@ -0,0 +1,7 @@
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'
data/test/test_config.rb CHANGED
@@ -1,5 +1,4 @@
1
- require 'minitest/spec'
2
- require 'autobuild'
1
+ require 'autobuild/test'
3
2
  require 'fakefs/safe'
4
3
  require 'flexmock'
5
4
 
@@ -27,9 +26,6 @@ describe Autobuild do
27
26
  end
28
27
 
29
28
  describe "tool_in_path" do
30
- include FlexMock::ArgumentTypes
31
- include FlexMock::MockContainer
32
-
33
29
  before do
34
30
  FakeFS.activate!
35
31
  flexmock(Autobuild).should_receive(:tool).with('bla').and_return('a_test_name').by_default
@@ -0,0 +1,88 @@
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,18 +1,6 @@
1
- $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
3
- require 'test/unit'
4
- require 'tools'
5
-
6
- require 'autobuild'
7
- require 'tmpdir'
8
- require 'fileutils'
9
- require 'flexmock/test_unit'
10
-
11
- class TC_Reporting < Test::Unit::TestCase
12
- def teardown
13
- Autobuild::Package.clear
14
- end
1
+ require 'autobuild/test'
15
2
 
3
+ class TC_Reporting < Minitest::Test
16
4
  def test_format_progress_message_does_not_touch_messages_without_prefix
17
5
  assert_equal "a | b | c",
18
6
  Autobuild.format_progress_message(%w{a b c})
@@ -1,14 +1,6 @@
1
- $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
3
- require 'test/unit'
4
- require 'tools'
1
+ require 'autobuild/test'
5
2
 
6
- require 'autobuild'
7
- require 'tmpdir'
8
- require 'fileutils'
9
- require 'flexmock/test_unit'
10
-
11
- class TC_Subcommand < Test::Unit::TestCase
3
+ class TC_Subcommand < Minitest::Test
12
4
  EXAMPLE_1 = <<EOF
13
5
  This is a file
14
6
  It will be the first part of the two-part cat
@@ -18,24 +10,17 @@ EXAMPLE_2 = <<EOF
18
10
  This is another file
19
11
  It will be the second part of the two-part cat
20
12
  EOF
21
-
22
- attr_reader :tmpdir
23
13
  attr_reader :source1, :source2
24
14
  def setup
25
- @tmpdir = Autobuild.logdir = TestTools.tempdir
15
+ super
16
+
17
+ Autobuild.logdir = tempdir
26
18
 
27
19
  # Write example files
28
- @source1 = File.join(tmpdir, 'source1')
29
- @source2 = File.join(tmpdir, 'source2')
20
+ @source1 = File.join(tempdir, 'source1')
21
+ @source2 = File.join(tempdir, 'source2')
30
22
  File.open(source1, 'w+') { |f| f.write(EXAMPLE_1) }
31
23
  File.open(source2, 'w+') { |f| f.write(EXAMPLE_2) }
32
-
33
- super
34
- end
35
-
36
- def teardown
37
- super
38
- TestTools.clean
39
24
  end
40
25
 
41
26
  def test_behaviour_on_unexpected_error
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autobuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ version: 1.9.0.b1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Joyeux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-10 00:00:00.000000000 Z
11
+ date: 2015-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -129,21 +129,29 @@ files:
129
129
  - lib/autobuild/rake_task_extension.rb
130
130
  - lib/autobuild/reporting.rb
131
131
  - lib/autobuild/subcommand.rb
132
+ - lib/autobuild/test.rb
132
133
  - lib/autobuild/timestamps.rb
133
134
  - lib/autobuild/tools.rb
134
135
  - lib/autobuild/utility.rb
135
136
  - lib/autobuild/version.rb
136
137
  - samples/openrobots.autobuild
137
138
  - test/data/cvsroot.tar
139
+ - test/data/gitrepo-with-extra-commit-and-tag.tar
140
+ - test/data/gitrepo.tar
141
+ - test/data/gitrepo/test
142
+ - test/data/gitrepo/test2
143
+ - test/data/gitrepo/test3
138
144
  - test/data/svnroot.tar
139
145
  - test/data/tarimport.tar.gz
146
+ - test/import/test_cvs.rb
147
+ - test/import/test_git.rb
148
+ - test/import/test_svn.rb
149
+ - test/import/test_tar.rb
150
+ - test/suite.rb
140
151
  - test/test_config.rb
141
- - test/test_import_cvs.rb
142
- - test/test_import_svn.rb
143
- - test/test_import_tar.rb
152
+ - test/test_environment.rb
144
153
  - test/test_reporting.rb
145
154
  - test/test_subcommand.rb
146
- - test/tools.rb
147
155
  homepage: http://rock-robotics.org/stable/documentation/autoproj
148
156
  licenses:
149
157
  - BSD
@@ -161,9 +169,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
169
  version: 1.9.2
162
170
  required_rubygems_version: !ruby/object:Gem::Requirement
163
171
  requirements:
164
- - - ">="
172
+ - - ">"
165
173
  - !ruby/object:Gem::Version
166
- version: '0'
174
+ version: 1.3.1
167
175
  requirements: []
168
176
  rubyforge_project:
169
177
  rubygems_version: 2.2.2
@@ -171,9 +179,4 @@ signing_key:
171
179
  specification_version: 4
172
180
  summary: Library to handle build systems and import mechanisms
173
181
  test_files:
174
- - test/test_config.rb
175
- - test/test_import_cvs.rb
176
- - test/test_import_svn.rb
177
- - test/test_import_tar.rb
178
- - test/test_reporting.rb
179
- - test/test_subcommand.rb
182
+ - test/suite.rb