paraduct 0.0.1.beta13 → 0.0.1.beta14

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.
@@ -7,7 +7,8 @@ module Paraduct
7
7
  @formatter = ActiveSupport::Logger::SimpleFormatter.new
8
8
  end
9
9
 
10
- [:debug, :info, :warn, :error, :fatal].each do |severity|
10
+ SEVERITIES = [:debug, :info, :warn, :error, :fatal]
11
+ SEVERITIES.each do |severity|
11
12
  define_method "#{severity}_with_label" do |message|
12
13
  message.each_line do |line|
13
14
  send "#{severity}_without_label", "#{@label} #{line.strip}" unless line.blank?
@@ -1,6 +1,7 @@
1
1
  module Paraduct
2
2
  module Errors
3
3
  class TestFailureError < StandardError; end
4
+ class DirtyExitError < StandardError; end
4
5
 
5
6
  class ProcessError < StandardError
6
7
  attr_reader :status
@@ -32,6 +32,7 @@ START matrix test
32
32
  stdout = runner.perform
33
33
  successful = true
34
34
  rescue Paraduct::Errors::ProcessError => e
35
+ runner.logger.error "exitstatus=#{e.status}, #{e.inspect}"
35
36
  stdout = e.message
36
37
  successful = false
37
38
  end
@@ -51,6 +52,8 @@ START matrix test
51
52
  pool.shutdown
52
53
  end
53
54
 
55
+ raise Paraduct::Errors::DirtyExitError unless test_response.jobs_count == product_variables.count
56
+
54
57
  test_response
55
58
  end
56
59
  end
@@ -1,6 +1,5 @@
1
1
  module Paraduct
2
- require "colorize"
3
- require "open3"
2
+ require "pty"
4
3
 
5
4
  class Runner
6
5
  attr_reader :script, :params, :base_job_dir
@@ -69,20 +68,24 @@ module Paraduct
69
68
  end
70
69
 
71
70
  private
72
- def run_command(command)
73
- lines = ""
74
71
 
75
- IO.popen(command) do |io|
76
- while line = io.gets
77
- logger.info(line)
78
- lines << line
72
+ def run_command(command)
73
+ full_stdout = ""
74
+
75
+ PTY.spawn(command) do |stdin, _stdout, pid|
76
+ begin
77
+ stdin.each do |line|
78
+ line.strip!
79
+ logger.info line
80
+ full_stdout << "#{line}\n"
81
+ end
82
+ rescue Errno::EIO
79
83
  end
84
+ exit_status = PTY.check(pid)
85
+ raise Paraduct::Errors::ProcessError.new(full_stdout, exit_status) unless exit_status.success?
80
86
  end
81
87
 
82
- status = $?
83
- raise Paraduct::Errors::ProcessError.new(lines, status) unless status.success?
84
-
85
- lines
88
+ full_stdout
86
89
  end
87
90
  end
88
91
  end
@@ -6,7 +6,7 @@ module Paraduct
6
6
  @jobs = []
7
7
  end
8
8
 
9
- delegate :push, to: :jobs, prefix: true
9
+ delegate :push, :count, to: :jobs, prefix: true
10
10
 
11
11
  def successful?
12
12
  @jobs.all?{ |result| result[:successful] }
@@ -1,3 +1,3 @@
1
1
  module Paraduct
2
- VERSION = "0.0.1.beta13"
2
+ VERSION = "0.0.1.beta14"
3
3
  end
data/lib/paraduct.rb CHANGED
@@ -3,6 +3,7 @@ require "active_support/deprecation"
3
3
  require "active_support/core_ext"
4
4
  require "pathname"
5
5
  require 'paraduct/version'
6
+ require "colorize"
6
7
 
7
8
  module Paraduct
8
9
  autoload :ColoredLabelLogger, 'paraduct/colored_label_logger'
data/spec/spec_helper.rb CHANGED
@@ -20,6 +20,8 @@ require 'rspec/temp_dir'
20
20
  require 'rspec/its'
21
21
  require 'pry'
22
22
 
23
+ is_verbose = ENV["VERBOSE"].present?
24
+
23
25
  def spec_dir
24
26
  Pathname(File.dirname(__FILE__))
25
27
  end
@@ -118,7 +120,12 @@ RSpec.configure do |config|
118
120
  config.order = :random
119
121
 
120
122
  config.before do
121
- # quiet
122
- allow(Paraduct.logger).to receive(:info)
123
+ unless is_verbose
124
+ # quiet all logs
125
+ Paraduct::ColoredLabelLogger::SEVERITIES.each do |severity|
126
+ allow(Paraduct.logger).to receive(severity)
127
+ allow_any_instance_of(Paraduct::ColoredLabelLogger).to receive(severity)
128
+ end
129
+ end
123
130
  end
124
131
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paraduct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.beta13
4
+ version: 0.0.1.beta14
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-24 00:00:00.000000000 Z
12
+ date: 2014-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -369,7 +369,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
369
369
  version: '0'
370
370
  segments:
371
371
  - 0
372
- hash: -2366476400975561829
372
+ hash: -1455455327285807628
373
373
  required_rubygems_version: !ruby/object:Gem::Requirement
374
374
  none: false
375
375
  requirements: