[前][次][番号順一覧][スレッド一覧]

ruby-changes:60976

From: Benoit <ko1@a...>
Date: Sat, 2 May 2020 23:06:18 +0900 (JST)
Subject: [ruby-changes:60976] a68ddf4287 (master): Update to ruby/mspec@ee29a34

https://git.ruby-lang.org/ruby.git/commit/?id=a68ddf4287

From a68ddf42879005905176bc38285906fe01707aff Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Sat, 2 May 2020 16:03:12 +0200
Subject: Update to ruby/mspec@ee29a34


diff --git a/spec/mspec/lib/mspec/helpers/ruby_exe.rb b/spec/mspec/lib/mspec/helpers/ruby_exe.rb
index 6d5470b..075a8aa 100644
--- a/spec/mspec/lib/mspec/helpers/ruby_exe.rb
+++ b/spec/mspec/lib/mspec/helpers/ruby_exe.rb
@@ -153,5 +153,7 @@ def ruby_cmd(code, opts = {}) https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/helpers/ruby_exe.rb#L153
     body = "-e #{code.inspect}"
   end
 
-  [RUBY_EXE, opts[:options], body, opts[:args]].compact.join(' ')
+  command = [RUBY_EXE, opts[:options], body, opts[:args]].compact.join(' ')
+  STDERR.puts "\nruby_cmd: #{command}" if ENV["DEBUG_MSPEC_RUBY_CMD"] == "true"
+  command
 end
diff --git a/spec/mspec/lib/mspec/helpers/tmp.rb b/spec/mspec/lib/mspec/helpers/tmp.rb
index df242f7..5062991 100644
--- a/spec/mspec/lib/mspec/helpers/tmp.rb
+++ b/spec/mspec/lib/mspec/helpers/tmp.rb
@@ -4,25 +4,13 @@ https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/helpers/tmp.rb#L4
 # directory is empty when the process exits.
 
 SPEC_TEMP_DIR_PID = Process.pid
-SPEC_TEMP_DIR_LIST = []
-if tmpdir = ENV['SPEC_TEMP_DIR']
-  temppath = File.realdirpath(tmpdir) + "/"
-else
-  tmpdir = File.realdirpath("rubyspec_temp")
-  temppath = tmpdir + "/#{SPEC_TEMP_DIR_PID}"
-  SPEC_TEMP_DIR_LIST << tmpdir
-end
-SPEC_TEMP_DIR_LIST << temppath
-SPEC_TEMP_DIR = temppath
+SPEC_TEMP_DIR = File.expand_path(ENV["SPEC_TEMP_DIR"] || "rubyspec_temp/#{SPEC_TEMP_DIR_PID}")
 SPEC_TEMP_UNIQUIFIER = "0"
 
 at_exit do
   begin
     if SPEC_TEMP_DIR_PID == Process.pid
-      while temppath = SPEC_TEMP_DIR_LIST.pop
-        next unless File.directory? temppath
-        Dir.delete temppath
-      end
+      Dir.delete SPEC_TEMP_DIR if File.directory? SPEC_TEMP_DIR
     end
   rescue SystemCallError
     STDERR.puts <<-EOM
@@ -30,7 +18,7 @@ at_exit do https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/helpers/tmp.rb#L18
 -----------------------------------------------------
 The rubyspec temp directory is not empty. Ensure that
 all specs are cleaning up temporary files:
-  #{temppath}
+  #{SPEC_TEMP_DIR}
 -----------------------------------------------------
 
     EOM
diff --git a/spec/mspec/lib/mspec/runner/formatters.rb b/spec/mspec/lib/mspec/runner/formatters.rb
index d085031..66f515d 100644
--- a/spec/mspec/lib/mspec/runner/formatters.rb
+++ b/spec/mspec/lib/mspec/runner/formatters.rb
@@ -7,6 +7,7 @@ require 'mspec/runner/formatters/summary' https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/runner/formatters.rb#L7
 require 'mspec/runner/formatters/unit'
 require 'mspec/runner/formatters/spinner'
 require 'mspec/runner/formatters/method'
+require 'mspec/runner/formatters/stats'
 require 'mspec/runner/formatters/yaml'
 require 'mspec/runner/formatters/profile'
 require 'mspec/runner/formatters/junit'
diff --git a/spec/mspec/lib/mspec/runner/formatters/stats.rb b/spec/mspec/lib/mspec/runner/formatters/stats.rb
new file mode 100644
index 0000000..8cff96d
--- /dev/null
+++ b/spec/mspec/lib/mspec/runner/formatters/stats.rb
@@ -0,0 +1,57 @@ https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/runner/formatters/stats.rb#L1
+require 'mspec/runner/formatters/base'
+
+class StatsPerFileFormatter < BaseFormatter
+  def initialize(out = nil)
+    super(out)
+    @data = {}
+    @root = File.expand_path(MSpecScript.get(:prefix) || '.')
+  end
+
+  def register
+    super
+    MSpec.register :load, self
+    MSpec.register :unload, self
+  end
+
+  # Resets the tallies so the counts are only for this file.
+  def load
+    tally.counter.examples = 0
+    tally.counter.errors = 0
+    tally.counter.failures = 0
+    tally.counter.tagged = 0
+  end
+
+  def unload
+    file = format_file MSpec.file
+
+    raise if @data.key?(file)
+    @data[file] = {
+      examples: tally.counter.examples,
+      errors: tally.counter.errors,
+      failures: tally.counter.failures,
+      tagged: tally.counter.tagged,
+    }
+  end
+
+  def finish
+    width = @data.keys.max_by(&:size).size
+    f = "%3d"
+    @data.each_pair do |file, data|
+      total = data[:examples]
+      passing = total - data[:errors] - data[:failures] - data[:tagged]
+      puts "#{file.ljust(width)}  #{f % passing}/#{f % total}"
+    end
+
+    require 'yaml'
+    yaml = YAML.dump(@data)
+    File.write "results-#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}.yml", yaml
+  end
+
+  private def format_file(file)
+    if file.start_with?(@root)
+      file[@root.size+1..-1]
+    else
+      raise file
+    end
+  end
+end
diff --git a/spec/mspec/lib/mspec/utils/options.rb b/spec/mspec/lib/mspec/utils/options.rb
index 886707e..cb466f6 100644
--- a/spec/mspec/lib/mspec/utils/options.rb
+++ b/spec/mspec/lib/mspec/utils/options.rb
@@ -274,6 +274,8 @@ class MSpecOptions https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/utils/options.rb#L274
         config[:formatter] = SpinnerFormatter
       when 't', 'method'
         config[:formatter] = MethodFormatter
+      when 'e', 'stats'
+        config[:formatter] = StatsPerFileFormatter
       when 'y', 'yaml'
         config[:formatter] = YamlFormatter
       when 'p', 'profile'
@@ -300,6 +302,7 @@ class MSpecOptions https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/utils/options.rb#L302
     doc "       m, summary               SummaryFormatter"
     doc "       a, *, spin               SpinnerFormatter"
     doc "       t, method                MethodFormatter"
+    doc "       e, stats                 StatsPerFileFormatter"
     doc "       y, yaml                  YamlFormatter"
     doc "       p, profile               ProfileFormatter"
     doc "       j, junit                 JUnitFormatter\n"
@@ -467,8 +470,6 @@ class MSpecOptions https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/utils/options.rb#L470
   end
 
   def all
-    # Generated with:
-    # puts File.read(__FILE__).scan(/def (\w+).*\n\s*on\(/)
     configure {}
     targets
     formatters
@@ -481,6 +482,7 @@ class MSpecOptions https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/utils/options.rb#L482
     repeat
     verbose
     interrupt
+    timeout
     verify
     action_filters
     actions
diff --git a/spec/mspec/spec/utils/options_spec.rb b/spec/mspec/spec/utils/options_spec.rb
index ef85c41..f3a7046 100644
--- a/spec/mspec/spec/utils/options_spec.rb
+++ b/spec/mspec/spec/utils/options_spec.rb
@@ -1283,3 +1283,22 @@ describe "The -d, --debug option" do https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/utils/options_spec.rb#L1283
     end
   end
 end
+
+describe "MSpecOptions#all" do
+  it "includes all options" do
+    meth = MSpecOptions.instance_method(:all)
+    file, line = meth.source_location
+    contents = File.read(file)
+    lines = contents.lines
+
+    from = line
+    to = from
+    to += 1 until /^\s*end\s*$/ =~ lines[to]
+    calls = lines[from...to].map(&:strip)
+
+    option_methods = contents.scan(/def (\w+).*\n\s*on\(/).map(&:first)
+    option_methods[0].sub!("configure", "configure {}")
+
+    calls.should == option_methods
+  end
+end
diff --git a/spec/mspec/tool/sync/sync-rubyspec.rb b/spec/mspec/tool/sync/sync-rubyspec.rb
index c1218bb..8a66217 100644
--- a/spec/mspec/tool/sync/sync-rubyspec.rb
+++ b/spec/mspec/tool/sync/sync-rubyspec.rb
@@ -18,7 +18,7 @@ IMPLS = { https://github.com/ruby/ruby/blob/trunk/spec/mspec/tool/sync/sync-rubyspec.rb#L18
 MSPEC = ARGV.delete('--mspec')
 
 CHECK_LAST_MERGE = ENV['CHECK_LAST_MERGE'] != 'false'
-TEST_TRUNK = ENV['TEST_TRUNK'] != 'false'
+TEST_MASTER = ENV['TEST_MASTER'] != 'false'
 
 MSPEC_REPO = File.expand_path("../../..", __FILE__)
 raise MSPEC_REPO if !Dir.exist?(MSPEC_REPO) or !Dir.exist?("#{MSPEC_REPO}/.git")
@@ -172,7 +172,7 @@ def test_new_specs https://github.com/ruby/ruby/blob/trunk/spec/mspec/tool/sync/sync-rubyspec.rb#L172
 
     run_test[min_version]
     run_test[max_version]
-    run_test["trunk"] if TEST_TRUNK
+    run_test["master"] if TEST_MASTER
   end
 end
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]