benchmark_driver 0.10.6 → 0.10.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a333f4b3eda58e21fb18b0ee0bbe2e8e6c215b60759c5951aa345a98f3c76eac
4
- data.tar.gz: 5faaec82e758406b42f3305ddf5f188c8ff3bc14a26df54e0935fb2a7aabb653
3
+ metadata.gz: 8346d596ab14db8378d9575ecd00a9efae898170b890c4627cb603d60290c19c
4
+ data.tar.gz: 21879bf897e059878da0bae0ef0c68dd622fe6086d948d33e18822c36582597d
5
5
  SHA512:
6
- metadata.gz: dc1904907ed3ad571494030a894935cb4f9c3742b266af6977326ee566381026d45e819ddbd3a89ee0b6231b47070ff831f9592f56d72cd576162a202acbfe47
7
- data.tar.gz: dbcc9e041a6f50599fbe7582a21b37f5dd6bd81612936b17c455a4548166ae36d2b16b18b717bcc974fbb354686e6c7dc74fe5a5822116a52eb8cf12a8f58e10
6
+ metadata.gz: 2d612ff00aceaea804a3b0ebaa39c7c6dd5bcd219d26e1e9c855049069e65271c1aa4dfd897502326713cd1e447054ddb39ba47061a0f604402c6b0c039b8107
7
+ data.tar.gz: 1be94a52f4d63a438bbec19e9c787b2b7c202367102b516784ad7a7d30afc33a3457ad7b3a434012fb739a2be6f95b9289417607d613defe741d4847f6a85a3b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v0.10.7
2
+
3
+ - Pass `$RBENV_VERSION` for `command_stdout` runner with --rbenv option
4
+
1
5
  # v0.10.6
2
6
 
3
7
  - Fix TypeError on Ruby <= 2.3
data/exe/benchmark-driver CHANGED
@@ -35,7 +35,7 @@ config = BenchmarkDriver::Config.new.tap do |c|
35
35
  name, spec = full_spec.split('::', 2)
36
36
  spec ||= name # if `::` is not given, regard whole string as spec
37
37
  version, *args = spec.split(',')
38
- executables << BenchmarkDriver::Config::Executable.new(
38
+ executables << BenchmarkDriver::Config::RbenvExecutable.new(
39
39
  name: name,
40
40
  command: [BenchmarkDriver::Rbenv.ruby_path(version), *args],
41
41
  )
@@ -36,4 +36,17 @@ module BenchmarkDriver
36
36
  Config.defaults[:executables] = [
37
37
  BenchmarkDriver::Config::Executable.new(name: RUBY_VERSION, command: [RbConfig.ruby]),
38
38
  ]
39
+
40
+ class Config::RbenvExecutable < Config::Executable
41
+ def freeze
42
+ rbenv_version # avoid `can't modify frozen xxx`
43
+ super
44
+ end
45
+
46
+ def rbenv_version
47
+ return @rbenv_version if defined?(@rbenv_version)
48
+ match = command.first.match(%r[/(?<version>[^/]+)/bin/ruby\z])
49
+ @rbenv_version = match && match[:version]
50
+ end
51
+ end
39
52
  end
@@ -1,5 +1,6 @@
1
1
  require 'benchmark_driver/struct'
2
2
  require 'benchmark_driver/metrics'
3
+ require 'benchmark_driver/rbenv'
3
4
  require 'tempfile'
4
5
  require 'shellwords'
5
6
  require 'open3'
@@ -61,7 +62,7 @@ class BenchmarkDriver::Runner::CommandStdout
61
62
  @config.executables.each do |exec|
62
63
  best_value = with_repeat(metrics_type) do
63
64
  stdout = with_chdir(job.working_directory) do
64
- execute(*exec.command, *job.command)
65
+ with_rbenv_version(exec) { execute(*exec.command, *job.command) }
65
66
  end
66
67
  StdoutToMetrics.new(
67
68
  stdout: stdout,
@@ -83,6 +84,20 @@ class BenchmarkDriver::Runner::CommandStdout
83
84
 
84
85
  private
85
86
 
87
+ def with_rbenv_version(executable, &block)
88
+ if executable.is_a?(BenchmarkDriver::Config::RbenvExecutable) && executable.rbenv_version
89
+ begin
90
+ env = ENV.to_h.dup
91
+ ENV['RBENV_VERSION'] = executable.rbenv_version
92
+ block.call
93
+ ensure
94
+ ENV.replace(env)
95
+ end
96
+ else
97
+ block.call
98
+ end
99
+ end
100
+
86
101
  def with_chdir(working_directory, &block)
87
102
  if working_directory
88
103
  Dir.chdir(working_directory) { block.call }
@@ -1,3 +1,3 @@
1
1
  module BenchmarkDriver
2
- VERSION = '0.10.6'
2
+ VERSION = '0.10.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchmark_driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.6
4
+ version: 0.10.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-25 00:00:00.000000000 Z
11
+ date: 2018-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler