diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index 80be507a1..291352988 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -9,8 +9,8 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- - uses: ruby/setup-ruby@d5126b9b3579e429dd52e51e68624dda2e05be25 # v1.267.0
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - uses: ruby/setup-ruby@09a7688d3b55cf0e976497ff046b70949eeaccfd # v1.288.0
with:
ruby-version: '3.0'
- name: Install dependencies
diff --git a/.github/workflows/dependabot_automerge.yml b/.github/workflows/dependabot_automerge.yml
index b27b76f57..a3cb63ba4 100644
--- a/.github/workflows/dependabot_automerge.yml
+++ b/.github/workflows/dependabot_automerge.yml
@@ -13,11 +13,11 @@ jobs:
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'ruby/rake'
steps:
- name: Dependabot metadata
- uses: dependabot/fetch-metadata@08eff52bf64351f401fb50d4972fa95b9f2c2d1b # v2.4.0
+ uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # v2.5.0
id: metadata
- name: Wait for status checks
- uses: lewagon/wait-on-check-action@3603e826ee561ea102b58accb5ea55a1a7482343 # v1.4.1
+ uses: lewagon/wait-on-check-action@74049309dfeff245fe8009a0137eacf28136cb3c # v1.5.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.pull_request.head.sha || github.sha }}
diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml
index e8b2d5bff..8ac5b4940 100644
--- a/.github/workflows/gh-pages.yml
+++ b/.github/workflows/gh-pages.yml
@@ -19,9 +19,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Ruby
- uses: ruby/setup-ruby@d5126b9b3579e429dd52e51e68624dda2e05be25 # v1.267.0
+ uses: ruby/setup-ruby@09a7688d3b55cf0e976497ff046b70949eeaccfd # v1.288.0
with:
ruby-version: '3.2'
bundler-cache: true
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index adf400050..baffc10cd 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -10,8 +10,8 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- - uses: ruby/setup-ruby@d5126b9b3579e429dd52e51e68624dda2e05be25 # v1.267.0
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - uses: ruby/setup-ruby@09a7688d3b55cf0e976497ff046b70949eeaccfd # v1.288.0
with:
ruby-version: '3.0'
bundler-cache: true
diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml
index 108049f35..b408b4aa5 100644
--- a/.github/workflows/push_gem.yml
+++ b/.github/workflows/push_gem.yml
@@ -23,14 +23,14 @@ jobs:
steps:
- name: Harden Runner
- uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
+ uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit
- - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Ruby
- uses: ruby/setup-ruby@d5126b9b3579e429dd52e51e68624dda2e05be25 # v1.267.0
+ uses: ruby/setup-ruby@09a7688d3b55cf0e976497ff046b70949eeaccfd # v1.288.0
with:
bundler-cache: true
ruby-version: "ruby"
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 6743160b6..1a3b45632 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -10,8 +10,8 @@ jobs:
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
with:
min_version: 2.3
- engine: cruby-jruby
- versions: '["truffleruby"]'
+ engine: cruby
+ versions: '["truffleruby", "jruby"]'
test:
needs: ruby-versions
@@ -31,13 +31,11 @@ jobs:
ruby: 2.3
- os: windows-latest
ruby: truffleruby
- - os: windows-latest
- ruby: jruby-head
- os: windows-latest
ruby: jruby
steps:
- - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- - uses: ruby/setup-ruby@d5126b9b3579e429dd52e51e68624dda2e05be25 # v1.267.0
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - uses: ruby/setup-ruby@09a7688d3b55cf0e976497ff046b70949eeaccfd # v1.288.0
with:
ruby-version: ${{ matrix.ruby }}
- name: Install dependencies
diff --git a/doc/command_line_usage.rdoc b/doc/command_line_usage.rdoc
index c1ff39d5b..a4a0bd794 100644
--- a/doc/command_line_usage.rdoc
+++ b/doc/command_line_usage.rdoc
@@ -6,10 +6,10 @@ Rake is invoked from the command line using:
Options are:
-[name=value]
+[name=value]
Set the environment variable name to value
during the execution of the rake command. You can access
- the value by using ENV['name'].
+ the value by using ENV['name'].
[--all (-A)]
Used in combination with the -T and -D options, will force
@@ -105,12 +105,12 @@ Options are:
Require _name_ before executing the Rakefile.
[--rules]
- Trace the rules resolution.
+ Trace the resolution of rules used to create tasks.
[--silent (-s)]
Like --quiet, but also suppresses the 'in directory' announcement.
-[--suppress-backtrace _pattern_ ]
+[--suppress-backtrace _pattern_]
Line matching the regular expression _pattern_ will be removed
from the backtrace output. Note that the --backtrace option is the
full backtrace without these lines suppressed.
diff --git a/doc/rakefile.rdoc b/doc/rakefile.rdoc
index 4014306a1..949e40d6f 100644
--- a/doc/rakefile.rdoc
+++ b/doc/rakefile.rdoc
@@ -360,6 +360,19 @@ The following rule might be used for Java files ...
*NOTE:* +java_compile+ is a hypothetical method that invokes the
java compiler.
+=== Implicit File Tasks
+
+When a task is not defined but a file with that name exists, Rake
+automatically creates an implicit file task for it. For example:
+
+ $ rake hello_world # Error: task not found
+ $ touch hello_world # Create a file with the same name
+ $ rake hello_world # Now succeeds automatically
+
+Use the --rules command line option to trace how rules are
+resolved when searching for tasks; note that creation of implicit file
+tasks is not traced.
+
== Importing Dependencies
Any ruby file (including other rakefiles) can be included with a
diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb
index 1510d95c3..c52091715 100644
--- a/lib/rake/file_utils.rb
+++ b/lib/rake/file_utils.rb
@@ -48,7 +48,7 @@ def sh(*cmd, &block)
verbose = options.delete :verbose
noop = options.delete(:noop) || Rake::FileUtilsExt.nowrite_flag
- Rake.rake_output_message sh_show_command cmd if verbose
+ Rake.rake_output_message sh_show_command(cmd, options) if verbose
unless noop
res = (Hash === cmd.last) ? system(*cmd) : system(*cmd, options)
@@ -68,7 +68,7 @@ def create_shell_runner(cmd) # :nodoc:
end
private :create_shell_runner
- def sh_show_command(cmd) # :nodoc:
+ def sh_show_command(cmd, options = nil) # :nodoc:
cmd = cmd.dup
if Hash === cmd.first
@@ -77,7 +77,12 @@ def sh_show_command(cmd) # :nodoc:
cmd[0] = env
end
- cmd.join " "
+ cmd = cmd.join " "
+ if options and chdir = options[:chdir]
+ "(cd #{chdir} && #{cmd})"
+ else
+ cmd
+ end
end
private :sh_show_command
diff --git a/lib/rake/file_utils_ext.rb b/lib/rake/file_utils_ext.rb
index 687d80584..7860b65ee 100644
--- a/lib/rake/file_utils_ext.rb
+++ b/lib/rake/file_utils_ext.rb
@@ -53,6 +53,7 @@ def #{name}(*args, **options, &block)
def verbose(value=nil)
oldvalue = FileUtilsExt.verbose_flag
FileUtilsExt.verbose_flag = value unless value.nil?
+ ENV["TESTOPTS"] = "-v" if value
if block_given?
begin
yield
diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb
index 7cf1ece5d..29f546b51 100644
--- a/lib/rake/testtask.rb
+++ b/lib/rake/testtask.rb
@@ -109,8 +109,6 @@ def define
desc @description
task @name => Array(deps) do
FileUtilsExt.verbose(@verbose) do
- puts "Use TESTOPTS=\"--verbose\" to pass --verbose" \
- ", etc. to runners." if ARGV.include? "--verbose"
args =
"#{ruby_opts_string} #{run_code} " +
"#{file_list_string} #{option_list}"
diff --git a/test/helper.rb b/test/helper.rb
index 537d7e3a2..3d92dbf88 100644
--- a/test/helper.rb
+++ b/test/helper.rb
@@ -29,7 +29,7 @@ class TaskManager
include Rake::TaskManager
end
- RUBY = File.realpath(ENV["RUBY"] || Gem.ruby)
+ RUBY = (ENV["RUBY"] || Gem.ruby)
def setup
ARGV.clear
@@ -122,5 +122,9 @@ def jruby9?
jruby? && (JRUBY_VERSION >= "9.0.0.0")
end
+ def jruby90?
+ jruby? && JRUBY_VERSION.start_with?("9.0.")
+ end
+
include RakefileDefinitions
end
diff --git a/test/test_rake_file_utils.rb b/test/test_rake_file_utils.rb
index 97b6ea83b..771e78f0f 100644
--- a/test/test_rake_file_utils.rb
+++ b/test/test_rake_file_utils.rb
@@ -12,6 +12,7 @@ def teardown
FileUtils::LN_SUPPORTED[0] = true
RakeFileUtils.verbose_flag = Rake::FileUtilsExt::DEFAULT
ENV["RAKE_TEST_SH"] = @rake_test_sh
+ ENV["TESTOPTS"] = nil
super
end
@@ -106,8 +107,13 @@ def test_safe_ln_fails_on_script_error
def test_verbose
verbose true
assert_equal true, verbose
+ assert_equal "-v", ENV["TESTOPTS"]
+
+ ENV["TESTOPTS"] = nil
verbose false
assert_equal false, verbose
+ assert_equal nil, ENV["TESTOPTS"]
+
verbose(true) {
assert_equal true, verbose
}
@@ -181,7 +187,7 @@ def test_sh_with_multiple_arguments
end
def test_sh_with_spawn_options
- omit "JRuby does not support spawn options" if jruby?
+ omit "JRuby does not support spawn options" if jruby90?
echocommand
@@ -239,10 +245,24 @@ def test_sh_noop
assert true, "should not fail"
end
+ def test_sh_chdir
+ omit "JRuby does not support spawn options" if jruby90?
+
+ Dir.mkdir "chdir_test"
+ out, err = capture_output do
+ verbose(true) {
+ sh "echo ok", chdir: "chdir_test", verbose: true, noop: true
+ }
+ end
+
+ assert_equal "(cd chdir_test && echo ok)\n", err
+ assert_empty out
+ end
+
def test_sh_bad_option
# Skip on JRuby because option checking is performed by spawn via system
# now.
- omit "JRuby does not support spawn options" if jruby?
+ omit "JRuby does not support spawn options" if jruby90?
shellcommand
@@ -387,7 +407,7 @@ def assert_echoes_fully
end
def test_ruby_with_multiple_arguments
- omit if jruby9? # https://github.com/jruby/jruby/issues/3653
+ omit if jruby90? # https://github.com/jruby/jruby/issues/3653
check_no_expansion
diff --git a/test/test_rake_functional.rb b/test/test_rake_functional.rb
index 3854c5751..1298a3235 100644
--- a/test/test_rake_functional.rb
+++ b/test/test_rake_functional.rb
@@ -420,13 +420,6 @@ def test_test_task_when_verbose_unless_verbose_passed_not_prompt_testopts
refute_match exp, @out
end
- def test_test_task_when_verbose_passed_prompts_testopts
- rakefile_test_task
- rake "--verbose", "unit"
- exp = /TESTOPTS="--verbose" to pass --verbose/
- assert_match exp, @out
- end
-
def test_comment_before_task_acts_like_desc
rakefile_comments
diff --git a/test/test_rake_rake_test_loader.rb b/test/test_rake_rake_test_loader.rb
index 67b51e745..800e496b0 100644
--- a/test/test_rake_rake_test_loader.rb
+++ b/test/test_rake_rake_test_loader.rb
@@ -54,7 +54,7 @@ def test_load_error_raised_implicitly
load @loader
end
- assert_match /.* -- superkalifragilisticoespialidoso/, exc.message
+ assert_match(/.* -- superkalifragilisticoespialidoso/, exc.message)
end
assert_empty out
assert_empty err