wwtd 0.5.3 → 0.5.4

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: 2b2f6dec282d80a8cdaf53008e2dfff1e89264af
4
- data.tar.gz: 778218ac2e072752b8ac7bc27328c1d01f05a324
3
+ metadata.gz: 5b1e832c599a16052d46aa694de0b9464c794f73
4
+ data.tar.gz: 96c4a480a1bc405dc7db98c9b14e89e86dec0daa
5
5
  SHA512:
6
- metadata.gz: 6cd6dd3d26f1127be7245841bc50f4bd05be9c34b92bc2b916d332811102ca271b7dfe5fe6ae24acb5936f764eb91f706cdadc0ba406828aa835b20640cc0c5a
7
- data.tar.gz: 1dc94f737ee7be9d707136f5fca76bbe1da0520e85f0c412d4ab187f5666cb3cc1b8b4d44d91f44d7b15f4c11047023ed907a85ae0556cb71325cedfeefc95dc
6
+ metadata.gz: a1ad70dbdf2bd82a827d115ba107effcfc4a360ade2a5931b288d1078f04150d41860c217b724888918b7f723a52a7868dbedc00a9b4c777393cb2fc3e66691a
7
+ data.tar.gz: acdc3ea7a6d24c9818687ec442d209aa8e4a7b849324888eabb9c4dc4c4e722e07f846fd5ad7548030f7e61b760b7f3693a8920f9ca18cd1f159c7e4bae7590a
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -52,6 +52,23 @@ module WWTD
52
52
  end
53
53
  end
54
54
 
55
+ # internal api
56
+ def escaped_env(env)
57
+ env.map {|k,v| "#{k}=#{Shellwords.escape(v)}" }.join(" ")
58
+ end
59
+
60
+ # internal api
61
+ def sh(env, cmd=nil)
62
+ cmd, env = env, {} unless cmd
63
+ env = if env.any?
64
+ escaped_env(env) + " "
65
+ else
66
+ ""
67
+ end
68
+ puts cmd
69
+ system("#{env}#{cmd}")
70
+ end
71
+
55
72
  private
56
73
 
57
74
  def with_clean_dot_bundle
@@ -89,17 +106,6 @@ module WWTD
89
106
  matrix.map! { |c| config.merge(c) }
90
107
  end
91
108
 
92
- def sh(env, cmd=nil)
93
- cmd, env = env, {} unless cmd
94
- env = if env.any?
95
- env.map {|k,v| "export #{k}=#{Shellwords.escape(v)}" }.join(" && ") + " && "
96
- else
97
- ""
98
- end
99
- puts cmd
100
- system("#{env}#{cmd}")
101
- end
102
-
103
109
  def with_clean_env(&block)
104
110
  if defined?(Bundler)
105
111
  Bundler.with_clean_env(&block)
@@ -19,21 +19,37 @@ module WWTD
19
19
  end
20
20
  end
21
21
 
22
- # Summary
23
- if results.size > 1
24
- puts "\nResults:"
25
- puts results.map { |state, config| info_line(state, config, matrix) }
26
- end
22
+ print_summary(matrix, results)
23
+ print_rerun(results)
27
24
 
28
25
  results.all? { |state, config| state == :success } ? 0 : 1
29
26
  end
30
27
 
31
28
  private
32
29
 
30
+ def print_rerun(results)
31
+ failed = results.select { |s, c| s == :failure }
32
+ if failed.any?
33
+ puts "\nFailed:"
34
+ failed.each do |state, config|
35
+ runner = WWTD::Run.new(config.merge(:rerun => true), {}, nil)
36
+ env, cmd = runner.env_and_command
37
+ env = (env.empty? ? "" : WWTD.escaped_env(env) + " ")
38
+ puts colorize(:red, env + cmd)
39
+ end
40
+ end
41
+ end
42
+
43
+ def print_summary(matrix, results)
44
+ if results.size > 1
45
+ puts "\nResults:"
46
+ results.each { |state, config| puts info_line(state, config, matrix) }
47
+ end
48
+ end
49
+
33
50
  def protect_against_nested_runs
34
51
  env = (defined?(Bundler) ? Bundler::ORIGINAL_ENV : ENV)
35
52
 
36
- r = rand
37
53
  raise "Already running WWTD" if env["INSIDE_WWTD"]
38
54
  env['INSIDE_WWTD'] = "1"
39
55
  yield
@@ -67,6 +83,7 @@ module WWTD
67
83
  def info_line(state, config, matrix)
68
84
  config_info = config_info(matrix, config)
69
85
  color = STATE_COLOR_MAP[state] || :red
86
+
70
87
  "#{colorize(color, state.to_s.upcase)} #{config_info}"
71
88
  end
72
89
 
@@ -8,12 +8,20 @@ module WWTD
8
8
  # - rvm: "rvm xxx do"
9
9
  # - others: env hash
10
10
  # - unknown: nil
11
- def switch_statement(version)
11
+ def switch_statement(version, options={})
12
12
  return unless version
13
13
  version = normalize_ruby_version(version)
14
14
  if rvm_executable
15
15
  command = "rvm #{version} do "
16
16
  command if cache_command("#{command} ruby -v")
17
+ elsif options[:rerun]
18
+ if rbenv_executable
19
+ # cannot call different ruby from inside ruby, but ok for copy-paste
20
+ "RBENV_VERSION=#{version} "
21
+ else
22
+ # don't print giant path hack :/
23
+ "USE-RUBY-#{version}"
24
+ end
17
25
  else
18
26
  if ruby_root = ENV["RUBY_ROOT"] # chruby or RUBY_ROOT set
19
27
  switch_via_env(File.dirname(ruby_root), version)
@@ -19,10 +19,21 @@ module WWTD
19
19
  [state, config]
20
20
  end
21
21
 
22
+ # internal api
23
+ def env_and_command
24
+ default_command = (wants_bundle? ? "bundle exec rake" : "rake")
25
+ command = config["script"] || default_command
26
+ command = command.join(" && ") if Array === command
27
+ command = "#{switch}#{command}"
28
+
29
+ [env, command]
30
+ end
31
+
22
32
  private
23
33
 
24
34
  attr_reader :config, :env, :lock, :switch
25
35
 
36
+
26
37
  def success?
27
38
  if wants_bundle?
28
39
  flock File.join(lock, (config["rvm"] || "rvm").to_s) do
@@ -32,12 +43,7 @@ module WWTD
32
43
  end
33
44
  end
34
45
 
35
- default_command = (wants_bundle? ? "bundle exec rake" : "rake")
36
- command = config["script"] || default_command
37
- command = command.join(" && ") if Array === command
38
- command = "#{switch}#{command}"
39
-
40
- sh(env, command)
46
+ sh(*env_and_command)
41
47
  end
42
48
 
43
49
  def wants_bundle?
@@ -49,7 +55,7 @@ module WWTD
49
55
  end
50
56
 
51
57
  def build_switch_statement
52
- switch_ruby = Ruby.switch_statement(config["rvm"])
58
+ switch_ruby = Ruby.switch_statement(config["rvm"], :rerun => config[:rerun])
53
59
  if switch_ruby.is_a?(Hash)
54
60
  env.merge!(switch_ruby)
55
61
  switch_ruby = nil
@@ -1,3 +1,3 @@
1
1
  module WWTD
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wwtd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
@@ -30,7 +30,7 @@ cert_chain:
30
30
  F5etKHZg0j3eHO31/i2HnswY04lqGImUu6aM5EnijFTB7PPW2KwKKM4+kKDYFdlw
31
31
  /0WV1Ng2/Y6qsHwmqGg2VlYj2h4=
32
32
  -----END CERTIFICATE-----
33
- date: 2014-06-27 00:00:00.000000000 Z
33
+ date: 2014-07-08 00:00:00.000000000 Z
34
34
  dependencies: []
35
35
  description:
36
36
  email: michael@grosser.it
metadata.gz.sig CHANGED
Binary file