autobuild 1.11.2 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7312415bcb69bcece2a0aa8e681e1dd4529b4c80
4
- data.tar.gz: d7a7524b339349a1ad8ac04b82b23cb93ef201a8
3
+ metadata.gz: 2aa8495a7fa559f22d689834414b45c31f51fb5b
4
+ data.tar.gz: 8e4d55676e5c79de59a77157501aa7e2f3c7af8a
5
5
  SHA512:
6
- metadata.gz: 0b08b2582d59d9ad3e8624f4cc15a065fc7c3570320f0561c5a9e2b76092408cbd07aad538bf30b6095558b6a9d29303aa8e0d0f374b3bd57ebe0df36a506679
7
- data.tar.gz: c7dbe5e4248e8ef9a74fc9a10fa6186aa822cf29c0e7d231ddca22e7f27bce7fd0065bedac712b08762dedb4b119be4cec263a702d6bbfc0868211f2ef01c2fb
6
+ metadata.gz: aedbeb75280b0ec1bae6a57bb2c35268d47709af81823f7e06e706ee36046f83433e66745a2bbe3546078daed1769c5997019353677275edb12653706ef1ddf9
7
+ data.tar.gz: 9bbcf11269f27b6939cd4641e56f7db9eefbce5a292b9888a5422c875a8e504ab1933c70b70263b05147df450858aca136d00e6c7b3d982fa87e0a9ff97b1e37
@@ -699,6 +699,8 @@ def self.env=(env)
699
699
  @env = env
700
700
  end
701
701
 
702
+ @env = nil
703
+
702
704
  def self.env
703
705
  if !@env
704
706
  @env = Environment.new
@@ -289,6 +289,7 @@ def initialize(url, options = Hash.new)
289
289
  :source_id, :repository_id, :filename, :mode
290
290
  super(options)
291
291
 
292
+ @filename = nil
292
293
  if !@options.has_key?(:update_cached_file)
293
294
  @options[:update_cached_file] = false
294
295
  end
@@ -46,7 +46,9 @@ def self.display_message(*args)
46
46
  end
47
47
 
48
48
  if !Autobuild.progress_display_enabled?
49
- io.puts msg
49
+ if !silent?
50
+ io.puts msg
51
+ end
50
52
  return
51
53
  end
52
54
 
@@ -270,9 +272,8 @@ def to_s
270
272
  end
271
273
  end
272
274
 
273
- ## The reporting module provides the framework
274
- # to run commands in autobuild and report errors
275
- # to the user
275
+ ## The reporting module provides the framework # to run commands in
276
+ # autobuild and report errors # to the user
276
277
  #
277
278
  # It does not use a logging framework like Log4r, but it should ;-)
278
279
  module Reporting
@@ -280,10 +281,12 @@ module Reporting
280
281
 
281
282
  ## Run a block and report known exception
282
283
  # If an exception is fatal, the program is terminated using exit()
283
- def self.report
284
+ def self.report(on_package_failures: default_report_on_package_failures)
284
285
  begin yield
285
- rescue Interrupt
286
- interrupted = true
286
+ rescue Interrupt => e
287
+ interrupted = e
288
+ rescue Autobuild::Exception => e
289
+ return report_finish_on_error([e], on_package_failures: on_package_failures, interrupted_by: interrupted)
287
290
  end
288
291
 
289
292
  # If ignore_erorrs is true, check if some packages have failed
@@ -294,23 +297,62 @@ def self.report
294
297
  errors.concat(pkg.failures)
295
298
  end
296
299
 
297
- if !errors.empty?
298
- raise CompositeException.new(errors)
299
- elsif interrupted
300
- raise Interrupt
300
+ report_finish_on_error(errors, on_package_failures: on_package_failures, interrupted_by: interrupted)
301
+ end
302
+
303
+ # @api private
304
+ #
305
+ # Helper that returns the default for on_package_failures
306
+ #
307
+ # The result depends on the value for Autobuild.debug. It is either
308
+ # :exit if debug is false, or :raise if it is true
309
+ def self.default_report_on_package_failures
310
+ if Autobuild.debug then :raise
311
+ else :exit
312
+ end
313
+ end
314
+
315
+ # @api private
316
+ #
317
+ # Handle how Reporting.report is meant to finish in case of error(s)
318
+ #
319
+ # @param [Symbol] on_package_failures how does the reporting should behave.
320
+ #
321
+ def self.report_finish_on_error(errors, on_package_failures: default_report_on_package_failures, interrupted_by: nil)
322
+ if ![:raise, :report_silent, :exit_silent].include?(on_package_failures)
323
+ errors.each { |e| error(e) }
324
+ end
325
+ fatal = errors.any?(&:fatal?)
326
+ if !fatal
327
+ if interrupted_by
328
+ raise interrupted_by
329
+ else
330
+ return errors
331
+ end
301
332
  end
302
333
 
303
- rescue Autobuild::Exception => e
304
- error(e)
305
- if e.fatal?
306
- if Autobuild.debug
307
- raise
334
+ if on_package_failures == :raise
335
+ if interrupted_by
336
+ raise interrupted_by
337
+ end
338
+
339
+ e = if errors.size == 1 then errors.first
340
+ else CompositeException.new(errors)
341
+ end
342
+ raise e
343
+ elsif [:report_silent, :report].include?(on_package_failures)
344
+ if interrupted_by
345
+ raise interrupted_by
308
346
  else
309
- exit 1
347
+ return errors
310
348
  end
349
+ elsif [:exit, :exit_silent].include?(on_package_failures)
350
+ exit 1
351
+ else
352
+ raise ArgumentError, "unexpected value for on_package_failures: #{on_package_failures}"
311
353
  end
312
354
  end
313
-
355
+
314
356
  ## Reports a successful build to the user
315
357
  def self.success
316
358
  each_reporter { |rep| rep.success }
@@ -334,9 +376,9 @@ def self.clear_reporters
334
376
  @@reporters.clear
335
377
  end
336
378
 
337
- def self.each_reporter(&iter)
338
- @@reporters.each(&iter)
339
- end
379
+ def self.each_reporter(&iter)
380
+ @@reporters.each(&iter)
381
+ end
340
382
 
341
383
  ## Iterate on all log files
342
384
  def self.each_log(&block)
@@ -363,4 +405,3 @@ def success
363
405
  end
364
406
  end
365
407
  end
366
-
@@ -160,6 +160,16 @@ def initialize(status, do_retry)
160
160
  CONTROL_UNEXPECTED = 2
161
161
  CONTROL_INTERRUPT = 3
162
162
 
163
+ @transparent_mode = false
164
+
165
+ def self.transparent_mode?
166
+ @transparent_mode
167
+ end
168
+
169
+ def self.transparent_mode=(flag)
170
+ @transparent_mode = flag
171
+ end
172
+
163
173
  # Run a subcommand and return its standard output
164
174
  #
165
175
  # The command's standard and error outputs, as well as the full command line
@@ -383,15 +393,15 @@ def self.run(target, phase, *command)
383
393
  line = line.chomp
384
394
  subcommand_output << line
385
395
 
386
- if Autobuild.verbose
387
- STDOUT.puts line
388
- end
389
396
  logfile.puts line
390
- # Do not yield the line if Autobuild.verbose is true, as it
391
- # would mix the progress output with the actual command
392
- # output. Assume that if the user wants the command output,
393
- # the autobuild progress output is unnecessary
394
- if !Autobuild.verbose && block_given?
397
+
398
+ if Autobuild.verbose || transparent_mode?
399
+ STDOUT.puts "#{target_name}:#{phase}: #{line}"
400
+ elsif block_given?
401
+ # Do not yield
402
+ # would mix the progress output with the actual command
403
+ # output. Assume that if the user wants the command output,
404
+ # the autobuild progress output is unnecessary
395
405
  yield(line)
396
406
  end
397
407
  end
@@ -1,5 +1,3 @@
1
1
  module Autobuild
2
- VERSION = "1.11.2" unless defined? Autobuild::VERSION
2
+ VERSION = "1.12.0" unless defined? Autobuild::VERSION
3
3
  end
4
-
5
-
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.11.2
4
+ version: 1.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Joyeux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-19 00:00:00.000000000 Z
11
+ date: 2017-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -247,4 +247,3 @@ signing_key:
247
247
  specification_version: 4
248
248
  summary: Library to handle build systems and import mechanisms
249
249
  test_files: []
250
- has_rdoc: