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

ruby-changes:62406

From: Benoit <ko1@a...>
Date: Tue, 28 Jul 2020 04:43:11 +0900 (JST)
Subject: [ruby-changes:62406] 126fd5f15c (master): Update to ruby/spec@07164da

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

From 126fd5f15cff0d3bf314d90d8c21a3ae25ae8e68 Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Mon, 27 Jul 2020 21:41:08 +0200
Subject: Update to ruby/spec@07164da


diff --git a/spec/ruby/.mspec.constants b/spec/ruby/.mspec.constants
index d7e09ca..3e3bdbe 100644
--- a/spec/ruby/.mspec.constants
+++ b/spec/ruby/.mspec.constants
@@ -152,6 +152,7 @@ RegexpSpecsSubclassTwo https://github.com/ruby/ruby/blob/trunk/spec/ruby/.mspec.constants#L152
 Reline
 RescueInClassExample
 Resolv
+Ripper
 SHA1Constants
 SHA256Constants
 SHA384Constants
diff --git a/spec/ruby/.rubocop.yml b/spec/ruby/.rubocop.yml
index 5370d99..5db9256 100644
--- a/spec/ruby/.rubocop.yml
+++ b/spec/ruby/.rubocop.yml
@@ -92,6 +92,7 @@ Lint/UnreachableCode: https://github.com/ruby/ruby/blob/trunk/spec/ruby/.rubocop.yml#L92
   Exclude:
     - 'core/enumerator/lazy/fixtures/classes.rb'
     - 'core/kernel/catch_spec.rb'
+    - 'core/kernel/raise_spec.rb'
     - 'core/kernel/throw_spec.rb'
     - 'language/break_spec.rb'
     - 'language/fixtures/break.rb'
diff --git a/spec/ruby/.rubocop_todo.yml b/spec/ruby/.rubocop_todo.yml
index 8d9cd82..7a5f9f7 100644
--- a/spec/ruby/.rubocop_todo.yml
+++ b/spec/ruby/.rubocop_todo.yml
@@ -59,6 +59,7 @@ Lint/InheritException: https://github.com/ruby/ruby/blob/trunk/spec/ruby/.rubocop_todo.yml#L59
     - 'core/enumerator/lazy/fixtures/classes.rb'
     - 'core/exception/fixtures/common.rb'
     - 'core/module/fixtures/autoload_ex1.rb'
+    - 'shared/kernel/raise.rb'
 
 # Offense count: 72
 # Cop supports --auto-correct.
@@ -115,6 +116,7 @@ Lint/RescueException: https://github.com/ruby/ruby/blob/trunk/spec/ruby/.rubocop_todo.yml#L116
     - 'core/exception/cause_spec.rb'
     - 'core/exception/no_method_error_spec.rb'
     - 'core/kernel/fixtures/autoload_frozen.rb'
+    - 'core/kernel/raise_spec.rb'
     - 'core/module/autoload_spec.rb'
     - 'core/mutex/sleep_spec.rb'
     - 'core/thread/abort_on_exception_spec.rb'
diff --git a/spec/ruby/CONTRIBUTING.md b/spec/ruby/CONTRIBUTING.md
index 8d18f11..9a2a341 100644
--- a/spec/ruby/CONTRIBUTING.md
+++ b/spec/ruby/CONTRIBUTING.md
@@ -136,11 +136,11 @@ Here is a list of the most commonly-used guards: https://github.com/ruby/ruby/blob/trunk/spec/ruby/CONTRIBUTING.md#L136
 #### Version guards
 
 ```ruby
-ruby_version_is ""..."2.6 do
+ruby_version_is ""..."2.6" do
   # Specs for RUBY_VERSION < 2.6
 end
 
-ruby_version_is "2.6 do
+ruby_version_is "2.6" do
   # Specs for RUBY_VERSION >= 2.6
 end
 ```
diff --git a/spec/ruby/command_line/dash_r_spec.rb b/spec/ruby/command_line/dash_r_spec.rb
index b29895b..46c000b 100644
--- a/spec/ruby/command_line/dash_r_spec.rb
+++ b/spec/ruby/command_line/dash_r_spec.rb
@@ -7,7 +7,22 @@ describe "The -r command line option" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/dash_r_spec.rb#L7
   end
 
   it "requires the specified file" do
-    result = ruby_exe(@script, options: "-r #{@test_file}")
-    result.should include(@test_file + ".rb")
+    out = ruby_exe(@script, options: "-r #{@test_file}")
+    out.should include("REQUIRED")
+    out.should include(@test_file + ".rb")
+  end
+
+  it "requires the file before parsing the main script" do
+    out = ruby_exe(fixture(__FILE__, "bad_syntax.rb"), options: "-r #{@test_file}", args: "2>&1")
+    $?.should_not.success?
+    out.should include("REQUIRED")
+    out.should include("syntax error")
+  end
+
+  it "does not require the file if the main script file does not exist" do
+    out = `#{ruby_exe.to_a.join(' ')} -r #{@test_file} #{fixture(__FILE__, "does_not_exist.rb")} 2>&1`
+    $?.should_not.success?
+    out.should_not.include?("REQUIRED")
+    out.should.include?("No such file or directory")
   end
 end
diff --git a/spec/ruby/command_line/fixtures/test_file.rb b/spec/ruby/command_line/fixtures/test_file.rb
index 961e3c0..30a8322 100644
--- a/spec/ruby/command_line/fixtures/test_file.rb
+++ b/spec/ruby/command_line/fixtures/test_file.rb
@@ -1 +1 @@
-"test file"
+puts "REQUIRED"
diff --git a/spec/ruby/core/array/fill_spec.rb b/spec/ruby/core/array/fill_spec.rb
index 96c8862..6745bc8 100644
--- a/spec/ruby/core/array/fill_spec.rb
+++ b/spec/ruby/core/array/fill_spec.rb
@@ -207,8 +207,9 @@ describe "Array#fill with (filler, index, length)" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/fill_spec.rb#L207
 
   not_supported_on :opal do
     it "raises an ArgumentError or RangeError for too-large sizes" do
+      error_types = [RangeError, ArgumentError]
       arr = [1, 2, 3]
-      -> { arr.fill(10, 1, fixnum_max) }.should raise_error(ArgumentError)
+      -> { arr.fill(10, 1, fixnum_max) }.should raise_error { |err| error_types.should include(err.class) }
       -> { arr.fill(10, 1, bignum_value) }.should raise_error(RangeError)
     end
   end
diff --git a/spec/ruby/core/exception/backtrace_spec.rb b/spec/ruby/core/exception/backtrace_spec.rb
index 2d68251..3f74c4c 100644
--- a/spec/ruby/core/exception/backtrace_spec.rb
+++ b/spec/ruby/core/exception/backtrace_spec.rb
@@ -43,7 +43,7 @@ describe "Exception#backtrace" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/exception/backtrace_spec.rb#L43
       # This regexp is deliberately imprecise to account for the need to abstract out
       # the paths of the included mspec files and the desire to avoid specifying in any
       # detail what the in `...' portion looks like.
-      line.should =~ /^[^ ]+\:\d+(:in `[^`]+')?$/
+      line.should =~ /^.+:\d+:in `[^`]+'$/
     end
   end
 
diff --git a/spec/ruby/core/kernel/__dir___spec.rb b/spec/ruby/core/kernel/__dir___spec.rb
index 64b4391..0686b31 100644
--- a/spec/ruby/core/kernel/__dir___spec.rb
+++ b/spec/ruby/core/kernel/__dir___spec.rb
@@ -5,6 +5,13 @@ describe "Kernel#__dir__" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/__dir___spec.rb#L5
     __dir__.should == File.realpath(File.dirname(__FILE__))
   end
 
+  it "returns the expanded path of the directory when used in the main script" do
+    fixtures_dir = File.dirname(fixture(__FILE__, '__dir__.rb'))
+    Dir.chdir(fixtures_dir) do
+      ruby_exe("__dir__.rb").should == "__dir__.rb\n#{fixtures_dir}\n"
+    end
+  end
+
   context "when used in eval with a given filename" do
     it "returns File.dirname(filename)" do
       eval("__dir__", nil, "foo.rb").should == "."
diff --git a/spec/ruby/core/kernel/at_exit_spec.rb b/spec/ruby/core/kernel/at_exit_spec.rb
index 21149f9..7bdb539 100644
--- a/spec/ruby/core/kernel/at_exit_spec.rb
+++ b/spec/ruby/core/kernel/at_exit_spec.rb
@@ -23,7 +23,7 @@ describe "Kernel.at_exit" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/at_exit_spec.rb#L23
   it "gives access to the last raised exception" do
     code = <<-EOC
       at_exit do
-        puts "The exception matches: \#{$! == $exception}"
+        puts "The exception matches: \#{$! == $exception} (message=\#{$!.message})"
       end
 
       begin
@@ -33,10 +33,35 @@ describe "Kernel.at_exit" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/at_exit_spec.rb#L33
       end
     EOC
 
-    result = ruby_exe(code, args: "2>&1", escape: true)
-    result.should =~ /The exception matches: true/
+    result = ruby_exe(code, args: "2>&1")
+    result.lines.should.include?("The exception matches: true (message=foo)\n")
   end
 
+  it "both exceptions in at_exit and in the main script are printed" do
+    result = ruby_exe('at_exit { raise "at_exit_error" }; raise "main_script_error"', args: "2>&1")
+    result.should.include?('at_exit_error (RuntimeError)')
+    result.should.include?('main_script_error (RuntimeError)')
+  end
+
+  it "decides the exit status if both at_exit and the main script raise SystemExit" do
+    ruby_exe('at_exit { exit 43 }; exit 42', args: "2>&1")
+    $?.exitstatus.should == 43
+  end
+
+  it "runs all at_exit even if some raise exceptions" do
+    code = 'at_exit { STDERR.puts "last" }; at_exit { exit 43 }; at_exit { STDERR.puts "first" }; exit 42'
+    result = ruby_exe(code, args: "2>&1")
+    result.should == "first\nlast\n"
+    $?.exitstatus.should == 43
+  end
+
+  it "runs at_exit handlers even if the main script fails to parse" do
+    script = fixture(__FILE__, "at_exit.rb")
+    result = ruby_exe('{', options: "-r#{script}", args: "2>&1")
+    $?.should_not.success?
+    result.should.include?("at_exit ran\n")
+    result.should.include?("syntax error")
+  end
 end
 
 describe "Kernel#at_exit" do
diff --git a/spec/ruby/core/kernel/fixtures/__dir__.rb b/spec/ruby/core/kernel/fixtures/__dir__.rb
new file mode 100644
index 0000000..bf9a15e
--- /dev/null
+++ b/spec/ruby/core/kernel/fixtures/__dir__.rb
@@ -0,0 +1,2 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/fixtures/__dir__.rb#L1
+puts __FILE__
+puts __dir__
diff --git a/spec/ruby/core/kernel/fixtures/at_exit.rb b/spec/ruby/core/kernel/fixtures/at_exit.rb
new file mode 100644
index 0000000..9c11a7a
--- /dev/null
+++ b/spec/ruby/core/kernel/fixtures/at_exit.rb
@@ -0,0 +1,3 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/fixtures/at_exit.rb#L1
+at_exit do
+  STDERR.puts "at_exit ran"
+end
diff --git a/spec/ruby/core/kernel/fixtures/warn_require.rb b/spec/ruby/core/kernel/fixtures/warn_require.rb
new file mode 100644
index 0000000..c4b0733
--- /dev/null
+++ b/spec/ruby/core/kernel/fixtures/warn_require.rb
@@ -0,0 +1 @@
+warn 'warn-require-warning', uplevel: 1
diff --git a/spec/ruby/core/kernel/fixtures/warn_require_caller.rb b/spec/ruby/core/kernel/fixtures/warn_require_caller.rb
new file mode 100644
index 0000000..35a0f96
--- /dev/null
+++ b/spec/ruby/core/kernel/fixtures/warn_require_caller.rb
@@ -0,0 +1,2 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/fixtures/warn_require_caller.rb#L1
+# Use a different line than just 1
+require "#{__dir__}/warn_require"
diff --git a/spec/ruby/core/kernel/raise_spec.rb b/spec/ruby/core/kernel/raise_spec.rb
index bf26560..591daa0 100644
--- a/spec/ruby/cor (... truncated)

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

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