autobuild 1.6.5 → 1.7.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,15 +37,24 @@ module Autobuild
37
37
  def self.message(*args)
38
38
  return if silent?
39
39
  display_lock.synchronize do
40
- if @last_progress_msg
41
- puts
42
- @last_progress_msg = nil
40
+ display_message(*args)
41
+ end
42
+ end
43
+
44
+ def self.display_message(*args)
45
+ msg =
46
+ if args.empty? then ""
47
+ else "#{color(*args)}"
43
48
  end
44
- if args.empty?
45
- puts
46
- else
47
- puts "#{color(*args)}"
49
+
50
+ size =
51
+ if @last_progress_msg then @last_progress_msg.size
52
+ else 0
48
53
  end
54
+
55
+ puts "\r#{msg}#{" " * [size - msg.size, 0].max}"
56
+ if @last_progress_msg
57
+ print "#{@last_progress_msg}"
49
58
  end
50
59
  end
51
60
 
@@ -84,8 +93,10 @@ module Autobuild
84
93
  if options[:done_message]
85
94
  progress(key, *options[:done_message])
86
95
  end
87
- ensure
88
- progress_done(key)
96
+ progress_done(key, true)
97
+ rescue Exception => e
98
+ progress_done(key, false)
99
+ raise
89
100
  end
90
101
  end
91
102
  end
@@ -106,35 +117,101 @@ module Autobuild
106
117
  display_progress
107
118
  end
108
119
  end
109
- def self.progress_done(key)
120
+ def self.progress_done(key, display_last = true)
110
121
  found = false
111
122
  display_lock.synchronize do
123
+ last_msg = nil
112
124
  progress_messages.delete_if do |msg_key, msg|
113
125
  if msg_key == key
114
126
  found = true
127
+ last_msg = msg
115
128
  end
116
129
  end
117
130
  if found && @last_progress_msg
118
- puts
131
+ display_message(" #{last_msg}") if display_last && last_msg
119
132
  display_progress
120
133
  end
121
134
  end
122
135
  found
123
136
  end
124
137
 
125
- def self.display_progress
126
- msg = "#{progress_messages.map(&:last).join(" | ")}"
127
- if @last_progress_msg
128
- if !silent?
129
- print "\r" + " " * @last_progress_msg.length
138
+ def self.find_common_prefix(msg, other_msg)
139
+ msg = msg.split(" ")
140
+ other_msg = other_msg.split(" ")
141
+ msg.each_with_index do |token, idx|
142
+ if other_msg[idx] != token
143
+ prefix = msg[0..(idx - 1)].join(" ")
144
+ if !prefix.empty?
145
+ prefix << " "
146
+ end
147
+ return prefix
130
148
  end
131
149
  end
150
+ return msg
151
+ end
152
+
153
+ def self.format_progress_message(messages)
154
+ messages = messages.sort
155
+
156
+ groups = Array.new
157
+ groups << ["", (0...messages.size)]
158
+ messages.each_with_index do |msg, idx|
159
+ prefix, grouping = nil, false
160
+ messages[(idx + 1)..-1].each_with_index do |other_msg, other_idx|
161
+ other_idx += idx + 1
162
+ prefix ||= find_common_prefix(msg, other_msg)
163
+ break if !other_msg.start_with?(prefix)
164
+
165
+ if grouping
166
+ break if prefix != groups.last[0]
167
+ groups.last[1] << other_idx
168
+ else
169
+ current_prefix, current_group = groups.last
170
+ if prefix.size > current_prefix.size # create a new group from there
171
+ groups.last[1] = (current_group.first..[idx-1,current_group.last].min)
172
+ groups << [prefix, [idx, other_idx]]
173
+ grouping = true
174
+ else break
175
+ end
176
+ end
177
+ end
178
+ end
179
+ if groups.last.last.last < messages.size
180
+ groups << ["", (groups.last.last.last + 1)...(messages.size)]
181
+ end
182
+
183
+ result = []
184
+ groups.each do |prefix, indexes|
185
+ if prefix.empty?
186
+ indexes.each do |index|
187
+ result << messages[index]
188
+ end
189
+ else
190
+ grouped_messages = []
191
+ indexes.each do |index|
192
+ grouped_messages << messages[index][(prefix.size)..-1]
193
+ end
194
+ if !grouped_messages.empty?
195
+ result << "#{prefix}#{grouped_messages.join(", ")}"
196
+ end
197
+ end
198
+ end
199
+ result.join(" | ")
200
+ end
201
+
202
+ def self.display_progress
203
+ msg = format_progress_message(progress_messages.map(&:last))
204
+ last_msg_length =
205
+ if @last_progress_msg then @last_progress_msg.length
206
+ else 0
207
+ end
132
208
 
133
209
  if msg.empty?
134
- print "\r" if !silent?
210
+ print "\r" + " " * last_msg_length if !silent?
135
211
  @last_progress_msg = nil
136
212
  else
137
- print "\r #{msg}" if !silent?
213
+ msg = " #{msg}"
214
+ print "\r#{msg}#{" " * [last_msg_length - msg.length, 0].max}" if !silent?
138
215
  @last_progress_msg = msg
139
216
  end
140
217
  end
@@ -70,6 +70,11 @@ module Autobuild
70
70
  if @processor_count
71
71
  return @processor_count
72
72
  end
73
+
74
+ #No parralel build on windows yet, since CPU detection is not easy do able
75
+ if(RbConfig::CONFIG["host_os"] =~%r!(msdos|mswin|djgpp|mingw|[Ww]indows)!)
76
+ return 1
77
+ end
73
78
 
74
79
  if File.file?('/proc/cpuinfo')
75
80
  cpuinfo = File.readlines('/proc/cpuinfo')
@@ -163,7 +168,7 @@ module Autobuild::Subprocess
163
168
  options[:working_directory] ||= target.working_directory
164
169
  end
165
170
 
166
- logname = File.join(logdir, "#{target_name}-#{phase}.log")
171
+ logname = File.join(logdir, "#{target_name.gsub(/[:]/,'_')}-#{phase.to_s.gsub(/[:]/,'_')}.log")
167
172
  if !File.directory?(File.dirname(logname))
168
173
  FileUtils.mkdir_p File.dirname(logname)
169
174
  end
@@ -206,7 +211,23 @@ module Autobuild::Subprocess
206
211
  end
207
212
  cread, cwrite = IO.pipe # to control that exec goes well
208
213
 
209
- cwrite.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
214
+ if Autoproj::OSDependencies.operating_system[0].include?("windows")
215
+ olddir = Dir.pwd
216
+ if options[:working_directory] && (options[:working_directory] != Dir.pwd)
217
+ Dir.chdir(options[:working_directory])
218
+ end
219
+ system(*command)
220
+ result=$?.success?
221
+ if(!result)
222
+ error = Autobuild::SubcommandFailed.new(target, command.join(" "), logname, "Systemcall")
223
+ error.phase = phase
224
+ raise error
225
+ end
226
+ Dir.chdir(olddir)
227
+ return
228
+ end
229
+
230
+ cwrite.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
210
231
 
211
232
  pid = fork do
212
233
  begin
@@ -324,3 +345,5 @@ module Autobuild::Subprocess
324
345
 
325
346
  end
326
347
 
348
+
349
+
@@ -1,5 +1,5 @@
1
1
  module Autobuild
2
- VERSION = "1.6.5" unless defined? Autobuild::VERSION
2
+ VERSION = "1.7.0.rc1" unless defined? Autobuild::VERSION
3
3
  end
4
4
 
5
5
 
@@ -0,0 +1,55 @@
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
15
+
16
+ def test_format_progress_message_does_not_touch_messages_without_prefix
17
+ assert_equal "a | b | c",
18
+ Autobuild.format_progress_message(%w{a b c})
19
+ end
20
+ def test_format_progress_message_find_common_prefix_at_beginning
21
+ assert_equal "X a, b | c",
22
+ Autobuild.format_progress_message(["X a", "X b", "c"])
23
+ end
24
+ def test_format_progress_message_picks_up_bigger_prefix
25
+ assert_equal "X a | X y b, c | d",
26
+ Autobuild.format_progress_message(["X a", "X y b", "X y c", "d"])
27
+ end
28
+ def test_format_progress_message_prefix_comparison_uses_string_length
29
+ assert_equal "X mmmmmmmmmm a, b | X my x c | d",
30
+ Autobuild.format_progress_message(["X mmmmmmmmmm a", "X mmmmmmmmmm b", "X my x c", "d"])
31
+ end
32
+ def test_package_message_with_marker_inside_token
33
+ package = Autobuild::Package.new('pkg')
34
+ assert_equal 'patching pkg: unapplying', package.process_formatting_string('patching %s: unapplying')
35
+ end
36
+ def test_package_message_with_marker_at_beginning
37
+ package = Autobuild::Package.new('pkg')
38
+ assert_equal 'pkg unapplying', package.process_formatting_string('%s unapplying')
39
+ end
40
+ def test_package_message_with_marker_at_end
41
+ package = Autobuild::Package.new('pkg')
42
+ assert_equal 'patching pkg', package.process_formatting_string('patching %s')
43
+ end
44
+ def test_package_message_without_formatting
45
+ flexmock(Autobuild).should_receive('color').never
46
+ package = Autobuild::Package.new('pkg')
47
+ assert_equal 'patching a package pkg', package.process_formatting_string('patching a package %s')
48
+ end
49
+ def test_package_message_with_formatting
50
+ flexmock(Autobuild).should_receive('color').with('patching a package', :bold, :red).and_return('|patching a package|').once
51
+ package = Autobuild::Package.new('pkg')
52
+ assert_equal '|patching a package| pkg', package.process_formatting_string('patching a package %s', :bold, :red)
53
+ end
54
+ end
55
+
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autobuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.5
5
- prerelease:
4
+ version: 1.7.0.rc1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Sylvain Joyeux
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-27 00:00:00.000000000 Z
12
+ date: 2012-11-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &21792800 !ruby/object:Gem::Requirement
16
+ requirement: &10716440 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.9.0
21
+ version: 0.7.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *21792800
24
+ version_requirements: *10716440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: utilrb
27
- requirement: &21792360 !ruby/object:Gem::Requirement
27
+ requirement: &10716000 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 1.6.0
32
+ version: 1.3.3
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *21792360
35
+ version_requirements: *10716000
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: highline
38
- requirement: &21791920 !ruby/object:Gem::Requirement
38
+ requirement: &10715560 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *21791920
46
+ version_requirements: *10715560
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &21791460 !ruby/object:Gem::Requirement
49
+ requirement: &10715120 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '3.10'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *21791460
57
+ version_requirements: *10715120
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: hoe
60
- requirement: &21791000 !ruby/object:Gem::Requirement
60
+ requirement: &10714680 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '3.3'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *21791000
68
+ version_requirements: *10714680
69
69
  description: Collection of classes to handle build systems (CMake, autotools, ...)
70
70
  and import mechanisms (tarballs, CVS, SVN, git, ...). It also offers a Rake integration
71
71
  to import and build such software packages. It is the backbone of the autoproj (http://rock-robotics.org/autoproj)
@@ -121,6 +121,7 @@ files:
121
121
  - test/test_import_tar.rb
122
122
  - test/test_subcommand.rb
123
123
  - test/tools.rb
124
+ - test/test_reporting.rb
124
125
  - .gemtest
125
126
  homepage: http://rock-robotics.org/stable/documentation/autoproj
126
127
  licenses: []
@@ -139,9 +140,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
139
140
  required_rubygems_version: !ruby/object:Gem::Requirement
140
141
  none: false
141
142
  requirements:
142
- - - ! '>='
143
+ - - ! '>'
143
144
  - !ruby/object:Gem::Version
144
- version: '0'
145
+ version: 1.3.1
145
146
  requirements: []
146
147
  rubyforge_project: autobuild
147
148
  rubygems_version: 1.8.11
@@ -150,6 +151,7 @@ specification_version: 3
150
151
  summary: Library to handle build systems and import mechanisms
151
152
  test_files:
152
153
  - test/test_import_cvs.rb
154
+ - test/test_reporting.rb
153
155
  - test/test_subcommand.rb
154
156
  - test/test_import_svn.rb
155
157
  - test/test_import_tar.rb