diff --git a/.gemtest b/.gemtest deleted file mode 100644 index e69de29bb..000000000 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 000000000..2dbc56a36 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,22 @@ +name: macos + +on: [push] + +jobs: + build: + runs-on: macos-latest + strategy: + matrix: + ruby: [ '2.6.x', '2.5.x', '2.4.x' ] + steps: + - uses: actions/checkout@master + - name: Set up Ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - name: Install dependencies + run: gem install minitest + - name: Run test + env: + COVERALLS: "yes" + run: ruby -Ilib exe/rake diff --git a/.github/workflows/ubuntu-rvm.yml b/.github/workflows/ubuntu-rvm.yml new file mode 100644 index 000000000..cf3d1d05b --- /dev/null +++ b/.github/workflows/ubuntu-rvm.yml @@ -0,0 +1,28 @@ +name: ubuntu-rvm + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + ruby: [ 'jruby-head', 'jruby-9.2.9.0', 'ruby-head', '2.3.8', '2.2.10' ] + steps: + - uses: actions/checkout@master + - name: Set up RVM + run: | + curl -sSL https://get.rvm.io | bash + - name: Set up Ruby + run: | + source $HOME/.rvm/scripts/rvm + rvm install ${{ matrix.ruby }} --binary + rvm --default use ${{ matrix.ruby }} + - name: Install dependencies + run: | + source $HOME/.rvm/scripts/rvm + gem install minitest + - name: Run test + run: | + source $HOME/.rvm/scripts/rvm + ruby -Ilib exe/rake diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 000000000..b67130ad8 --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,20 @@ +name: ubuntu + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + ruby: [ '2.6.x', '2.5.x', '2.4.x' ] + steps: + - uses: actions/checkout@master + - name: Set up Ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - name: Install dependencies + run: gem install minitest + - name: Run test + run: ruby -Ilib exe/rake diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 000000000..5ced11c45 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,20 @@ +name: windows + +on: [push] + +jobs: + build: + runs-on: windows-latest + strategy: + matrix: + ruby: [ '2.6.x', '2.5.x', '2.4.x' ] + steps: + - uses: actions/checkout@master + - name: Set up Ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - name: Install dependencies + run: gem install minitest + - name: Run test + run: ruby -Ilib exe/rake diff --git a/.gitignore b/.gitignore index 415d69ced..f0cd1f570 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,14 @@ -.rbx -xxx-* *.bak -*.patch *.rbc *.swp *~ .#* +.DS_Store .idea +.rbx +/.rdoc /TAGS /coverage /html /pkg - -.DS_Store +Gemfile.lock diff --git a/.rubocop.yml b/.rubocop.yml index 6d2bfcdbd..84d6a7c5b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,27 +1,58 @@ -StringLiterals: - Enabled: false +AllCops: + TargetRubyVersion: 2.3 + DisabledByDefault: true + Exclude: + - doc/**/*.rb + - rake.gemspec + - bin/* + +Metrics/LineLength: + Enabled: true + Max: 120 + +Style/HashSyntax: + Enabled: true + +Style/StringLiterals: + Enabled: true + EnforcedStyle: double_quotes + +Style/MultilineIfThen: + Enabled: true + +Style/MethodDefParentheses: + Enabled: true + +Style/BracesAroundHashParameters: + Enabled: true -MultilineBlocks: - Enabled: false +Layout/IndentationWidth: + Enabled: true -SingleLineBlocks: - Enabled: false +Layout/Tab: + Enabled: true -NewLambdaLiteral: - Enabled: false +Layout/EmptyLines: + Enabled: true -SpaceAroundEqualsInParameterDefault: - Enabled: false +Layout/TrailingBlankLines: + Enabled: true -HashSyntax: - Enabled: false +Layout/TrailingWhitespace: + Enabled: true -LineLength: +Layout/SpaceBeforeBlockBraces: Enabled: true - Max: 90 -WhileUntilModifier: - Enabled: false +Layout/SpaceInsideBlockBraces: + Enabled: true -IfUnlessModifier: - Enabled: false +Layout/SpaceInsideHashLiteralBraces: + Enabled: true + +Layout/CaseIndentation: + Enabled: true + +Layout/EndAlignment: + Enabled: true + EnforcedStyleAlignWith: variable diff --git a/.togglerc b/.togglerc deleted file mode 100644 index c8c5a0a97..000000000 --- a/.togglerc +++ /dev/null @@ -1,7 +0,0 @@ -(add-to-list - 'toggle-mapping-styles - '(rake . ( - ("test/test_rake_\\1.rb" . "lib/rake/\\1.rb") - ) )) - -(buffer-toggle-style 'rake) diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 48b0a62e0..000000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: ruby -env: - - CI=true -rvm: -# - 1.8.7 # Needs mini-test -# - rbx-19mode # Time comparison fails - - jruby # 2 failures - - 1.9.3 - - 2.0.0 \ No newline at end of file diff --git a/CHANGES b/CHANGES deleted file mode 100644 index 35f73d65a..000000000 --- a/CHANGES +++ /dev/null @@ -1,530 +0,0 @@ -= Rake Changelog - -NOTE: Refer to the individual release documents (in the - doc/release_notes directory) for changes after in version 0.9.4 - and later. - -== Master (for 0.9.3) - -* The rake test loader now removes arguments it has processed. Issue #51 -* Rake::TaskArguments now responds to #values_at -* RakeFileUtils.verbose_flag = nil silences output the same as 0.8.7 -* Rake tests are now directory-independent -* Rake tests are no longer require flexmock -* Commands constant is no longer polluting top level namespace. -* Show only the interesting portion of the backtrace by default (James M. Lawrence). -* Added --reduce-compat optiont to remove backward compatible DSL hacks (James M. Lawrence). -* lib/rake/file_list.rb (Rake::FileList#egrep): there is no need to - open files in binary mode. (NAKAMURA Usaku) - -== Version 0.9.2 - -* Unknown - -== Version 0.9.1 - -* Added deprecation warnings to the Rake DSL methods. - -== Version 0.9.0 - -* *Incompatible* *change*: Rake DSL commands ('task', 'file', etc.) are - no longer private methods in Object. If you need to call 'task :xzy' inside - your class, include Rake::DSL into the class. The DSL is still available at - the top level scope (via the top level object which extends Rake::DSL). - -* Rake now warns when the deprecated :needs syntax used. - -* Rake history is now UTF-8 encoded. - -* Rake now uses case-insensitive comparisons to find the Rakefile on Windows. - Based on patch by Roger Pack. - -* Rake now requires (instead of loads) files in the test task. Patch by Cezary - Baginski. - -* Fixed typos. Patches by Sean Scot August Moon and R.T. Lechow. - -* Rake now prints the Rakefile directory only when it's different from the - current directory. Patch by Alex Chaffee. - -* Improved rakefile_location discovery on Windows. Patch by James Tucker. - -* Rake now recognizes "Windows Server" as a windows system. Patch by Matthias - Lüdtke - -* Rake::RDocTask is deprecated. Use RDoc::Task from RDoc 2.4.2+ (require - 'rdoc/task') - -* Rake::GemPackageTask is deprecated. Use Gem::PackageTask (require - 'rubygems/package_task') - -* Rake now outputs various messages to $stderr instead of $stdout. - -* Rake no longer emits warnings for Config. Patch by Santiago Pastorino. - -* Split rake.rb into individual files. - -* Support for the --where (-W) flag for showing where a task is defined. - -* Fixed quoting in test task. - (http://onestepback.org/redmine/issues/show/44, - http://www.pivotaltracker.com/story/show/1223138) - -* Fixed the silent option parsing problem. - (http://onestepback.org/redmine/issues/show/47) - -* Fixed :verbose=>false flag on sh and ruby commands. - -* Rake command line options may be given by default in a RAKEOPT - environment variable. - -* Errors in Rake will now display the task invocation chain in effect - at the time of the error. - -* Accepted change by warnickr to not expand test patterns in shell - (allowing more files in the test suite). - -* Fixed that file tasks did not perform prereq lookups in scope - (Redmine #57). - -== Version 0.8.7 - -* Fixed EXEEXT for JRuby on windows. - -== Version 0.8.6 - -* Minor fixes to the RDoc generation (removed dependency on darkfish - and removed inline source option). - -== PreVersion 0.8.6 - -* Now allow # comments to comment a task definition. - -== Version 0.8.5 - -* Better support for the system command on Windows. - -== Version 0.8.4 - -* Preserve case when locating rakefiles (patch from James - M. Lawrence/quix) - -* Better support for windows paths in the test task (patch from Simon - Chiang/bahuvrihi) - -* Windows system dir search order is now: HOME, HOMEDRIVE + HOMEPATH, - APPDATA, USERPROFILE (patch from Luis Lavena) - -* MingGW is now recognized as a windows platform. (patch from Luis - Lavena) - -* Numerous fixes to the windows test suite (patch from Luis Lavena). - -* Improved Rakefile case insensitivity testing (patch from Luis - Lavena). - -* Fixed stray ARGV option problem that was interfering with - Test::Unit::Runner. - -* Fixed default verbose mode (was accidently changed to false). - -* Removed reference to manage_gem to fix the warning produced by the - gem package task. - -== Version 0.8.3 - -* Enhanced the system directory detection in windows. We now check - HOMEDRIVE/HOMEPATH and USERPROFILE if APPDATA isn't found. (Patch - supplied by James Tucker). Rake no long aborts if it can't find the - directory. - -* Added fix to handle ruby installations in directories with spaces in - their name. - -== Version 0.8.2 - -* Fixed bug in package task so that it will include the subdir - directory in the package for testing. (Bug found by Adam Majer) - -* Added ENV var to rakefile to prevent OS X from including extended - attribute junk in a tar file. (Bug found by Adam Majer) - -* Fixed filename dependency order bug in test_inspect_pending and - test_to_s_pending. (Bug found by Adam Majer) - -* Fixed check for file utils options to make them immune to the - symbol/string differences. (Patch supplied by Edwin Pratomo) - -* Fixed bug with rules involving multiple source (Patch supplied by - Emanuel Indermühle) - -* Switched from getoptlong to optparse (patches supplied by Edwin - Pratomo) - -* The -T option will now attempt to dynamically sense the size of the - terminal. RAKE_COLUMNS will override any dynamic sensing. - -* FileList#clone and FileList#dup have better sematics w.r.t. taint - and freeze. - -* Added ability clear prerequisites, and/or actions from an existing - task. - -* Added the ability to reenable a task to be invoked a second time. - -* Changed RDoc test task to have no default template. This makes it - easier for the tempate to pick up the template from the environment. - -* Changed from using Mutex to Monitor. Evidently Mutex causes thread - join errors when Ruby is compiled with -disable-pthreads. (Patch - supplied by Ittay Dror) - -* Fixed bug in makefile parser that had problems with extra spaces in - file task names. (Patch supplied by Ittay Dror) - -* Added a performance patch for reading large makefile dependency - files. (Patch supplied by Ittay Dror) - -* Default values for task arguments can easily be specified with the - :with_defaults method. (Idea for default argument merging supplied - by (Adam Q. Salter) - -* The -T output will only self-truncate if the output is a tty. - However, if RAKE_COLUMNS is explicitly set, it will be honored in - any case. (Patch provided by Gavin Stark). - -* Numerous fixes for running under windows. A big thanks to Bheeshmar - Redheendran for spending a good part of the afternoon at the - Lonestar Ruby Conference to help me work out these issues. - -== Version 0.8.1 - -* Removed requires on parsedate.rb (in Ftptools) -* Removed ftools from rake.rb. Made it options in sys.rb - -== Version 0.8.0 - -* Added task parameters (e.g. "rake build[version7]") -* Made task parameters passable to prerequisites. -* Comments are limited to 80 columns or so (suggested by Jamis Buck). -* Added -D to display full comments (suggested by Jamis Buck). -* The rake program will set the status value used in any explicit - exit(n) calls. (patch provided by Stephen Touset) -* Fixed error in functional tests that were not including session (and - silently skipping the functionl tests. -* Removed --usage and make -h the same as -H. -* Make a prettier inspect for tasks. - -== Version 0.7.3 - -* Added existing and existing! methods to FileList -* FileLists now claim to be Arrays (via is_a?) to get better support - from the FileUtil module. -* Added init and top_level for custom rake applications. - -== Version 0.7.2 - -* Error messages are now send to stderr rather than stdout (from - Payton Quackenbush). -* Better error handling on invalid command line arguments (from Payton - Quackenbush). -* Added rcov task and updated unit testing for better code coverage. -* Fixed some bugs where the application object was going to the global - appliation instead of using its own data. -* Added square and curly bracket patterns to FileList#include (Tilman - Sauerbeck). -* Added plain filename support to rule dependents (suggested by Nobu - Nakada). -* Added pathmap support to rule dependents. -* Added a 'tasks' method to a namespace to get a list of tasks - associated with the namespace. -* Fixed the method name leak from FileUtils (bug found by Glenn - Vanderburg). -* Added rake_extension to handle detection of extension collisions. -* Added test for noop, bad_option and verbose flags to sh command. -* Removed dependency on internal fu_xxx functions from FileUtils. -* Added a 'shame' task to the Rakefile. -* Added tar_command and zip_command options to the Package task. -* Added a description to the gem task in GemPackageTask. -* Fixed a bug when rules have multiple prerequisites (patch by Joel - VanderWerf) -* Added a protected 'require "rubygems"' to test/test_application to - unbreak cruisecontrol.rb. -* Added the handful of RakeFileUtils to the private method as well. -* Added block based exclusion. -* The clean task will no longer delete 'core' if it is a directory. -* Removed rake_dup. Now we just simply rescue a bad dup. -* Refactored the FileList reject logic to remove duplication. -* Removed if __FILE__ at the end of the rake.rb file. - -== Version 0.7.1 - -* Added optional filter parameter to the --tasks command line option. -* Added flatten to allow rule transform procs to return lists of - prereqs (Joel VanderWerf provided patch). -* Added pathmap to String and FileList. -* The -r option will now load .rake files (but a straight require - doesn't yet). NOTE: This is experimental ... it may be - discontinued. -* The -f option without a value will disable the search for a - Rakefile. The assumption is that the -r files are adequate. -* Fixed the safe_ln function to fall back to cp in more error - scenarios. - -== Version 0.7.0 - -* Added Rake.original_dir to return the original starting directory of - the rake application. -* Added safe_ln support for openAFS (from Ludvig Omholt). -* Added --trace reminder on short exception messages (David Heinemeier - Hansson suggestion). -* Added multitask declaration that executes prerequisites in - parallel. (Doug Young providied an initial implementation). -* Fixed missing_const hack to be compatible with Rails. (Jamis Buck - supplied test case). -* Made the RDoc task default to internal (in-process) RDoc formatting. - The old behavior is still available by setting the +external+ flag - to true. -* Rakefiles are now loaded with the expanded path to prevent - accidental polution from the Ruby load path. -* The +namespace+ command now returns a NameSpace object that can be - used to lookup tasks defined in that namespace. This allows for - better anonymous namespace behavior. -* Task objects my now be used in prerequisite lists directly. - -== Version 0.6.1 - -* Rebuilt 0.6.0 gem without signing. - -== Version 0.6.0 - -* Fixed file creation bug in the unit tests (caused infinite loop on - windows). -* Fixed bug where session based functional tests were run under - windows. -* Fixed bug in directory tasks so that updating a directory will not - retrigger file tasks depending on the directory (see - FileCreationTask and EarlyTime). -* Added egrep to FileList -* ruby command now runs same ruby version as rake. -* Added investigation to task object. (suggested by Martin Fowler) -* Added ruby_opts to the test task to allow arbitrary ruby options to - be passed to the test script. (Greg Fast) -* Fixed the test loader to ignore options. (Greg Fast) -* Moved Task, FileTask, FileCreationTask and RakeApp into the Rake - module namespace. Old style namespace behavior can be invoked via - the --classic-namespace option. (requested by Kelly Felkins). -* GemTask is now sensitive to the gem platform (Masao Mutoh). -* A non-existing file prerequisite will no longer cause an exception - (Philipp Neubeck). -* Multiple prerequisites on Rake rules now allowed (initial patch - supplied by Stuart Jansen). - -== Version 0.5.4 - -* Added double quotes to the test runner. -* Added .svn to default ignore list. -* Updated FileList#include to support nested arrays and filelists. - -== Version 0.5.3 - -* Added support for importing Rakefile and other dependencies. -* Fixed bug so that now rules can chain off of existing tasks as well - as existing files. -* Fixed verbose flag bug in the testing task. Shortened some failure - messages. -* Make FileUtils methods private at the top level module to avoid - accidental method leaking into other objects. -* Added test loader option to test task. "testrb" is no longer the - default test loader. It is now eating syntax errors that should - halt the unit tests. -* Revamped FileList so that it works more like and array (addressed - flatten bug). Added many tests around file list. -* Added +ext+ method to both String and FileList. - -== Version 0.5.0 - -* Fixed documentation that was lacking the Rake module name (Tilman - Sauerbeck). -* Added tar.gz and tar.bz2 support to package task (Tilman Sauerbeck). -* Recursive rules are now supported (Tilman Sauerbeck). -* Added warning option for the Test Task (requested by Eric Hodel). -* The jamis rdoc template is only used if it exists. -* Added fix for Ruby 1.8.2 test/unit and rails problem. -* Added contributed rake man file (Jani Monoses). -* Added Brian Candler's fix for problems in --trace and --dry-run - mode. - -== Version 0.4.15 - -* Fixed a bug that prevented the TESTOPTS flag from working with the - revised for 1.8.2 test task. -* Updated the docs on --trace to indicate that it also enables a full - backtrace on errors. - -== Version 0.4.14 - -* Modified the TestTask to workaround the Ruby 1.8.2 change in - autoexecuting unit tests. - -== Version 0.4.13 - -* Fixed the dry-run flag so it is operating again. -* Multiple arguments to sh and ruby commands will not be interpreted - by the shell (patch provided by Jonathan Paisley). - -== Version 0.4.12 - -* Added --silent (-s) to suppress the (in directory) rake message. - -== Version 0.4.11 - -* Changed the "don't know how to rake" message (finally) -* Changes references to a literal "Rakefile" to reference the global - variable $rakefile (which contains the actual name of the rakefile). - -== Version 0.4.10 - -* Added block support to the "sh" command, allowing users to take - special actions on the result of the system call. E.g. - - sh "shell_command" do |ok, res| - puts "Program returned #{res.exitstatus}" if ! ok - end - -== Version 0.4.9 - -* Switched to Jamis Buck's RDoc template. -* Removed autorequire from Rake's gem spec. This prevents the Rake - libraries from loading while using rails. - -== Version 0.4.8 - -* Added support for .rb versions of Rakefile. -* Removed \\\n's from test task. -* Fixed Ruby 1.9 compatibility issue with FileList. - -== Version 0.4.7 - -* Fixed problem in FileList that caused Ruby 1.9 to go into infinite - recursion. Since to_a was removed from Object, it does not need to - added back into the list of methods to rewrite in FileList. (Thanks - to Kent Sibilev for pointing this out). - -== Version 0.4.6 -* Removed test version of ln in FileUtils that prevented safe_ln from - using ln. - -== Version 0.4.5 -* Upgraded comments in TestTask. -* FileList to_s and inspect now automatically resolve pending changes. -* FileList#exclude properly returns the FileList. - -== Version 0.4.4 -* Fixed initialization problem with @comment. -* Now using multi -r technique in TestTask. Switch Rakefile back to - using the built-in test task macros because the rake runtime is no - longer needed. -* Added 'TEST=filename' and 'TESTOPTS=options' to the Test Task - macros. -* Allow a +test_files+ attribute in test tasks. This allows more - flexibility in specifying test files. - -== Version 0.4.3 -* Fixed Comment leakage. - -== Version 0.4.2 -* Added safe_ln that falls back to a copy if a file link is not supported. -* Package builder now uses safe_ln. - -== Version 0.4.1 -* Task comments are now additive, combined with "/". -* Works with (soon to be released) rubygems 0.6.2 (or 0.7.0) - -== Version 0.4.0 -* FileList now uses deferred loading. The file system is not searched - until the first call that needs the file names. -* VAR=VALUE options are now accepted on the command line and are - treated like environment variables. The values may be tested in a - Rakefile by referencing ENV['VAR']. -* File.mtime is now used (instead of File.new().mtime). - -== Version 0.3.2.x - -* Removed some hidden dependencies on rubygems. Tests now will test - gems only if they are installed. -* Removed Sys from some example files. I believe that is that last - reference to Sys outside of the contrib area. -* Updated all copyright notices to include 2004. - -== Version 0.3.2 - -* GEM Installation now works with the application stub. - -== Version 0.3.1 - -* FileLists now automatically ignore CVS, .bak, ! -* GEM Installation now works. - -== Version 0.3.0 - -Promoted 0.2.10. - -== Version 0.2.10 -General - -* Added title to Rake's rdocs -* Contrib packages are no longer included in the documentation. - -RDoc Issues - -* Removed default for the '--main' option -* Fixed rendering of the rdoc options -* Fixed clean/clobber confusion with rerdoc -* 'title' attribute added - -Package Task Library Issues - -* Version (or explicit :noversion) is required. -* +package_file+ attribute is now writable - -FileList Issues - -* Dropped bang version of exclude. Now using ant-like include/exclude semantics. -* Enabled the "yield self" idiom in FileList#initialize. - -== Version 0.2.9 - -This version contains numerous changes as the RubyConf.new(2003) -presentation was being prepared. The changes include: - -* The monolithic rubyapp task library is in the process of being - dropped in favor of lighter weight task libraries. - -== Version 0.2.7 - -* Added "desc" for task descriptions. -* -T will now display tasks with descriptions. -* -P will display tasks and prerequisites. -* Dropped the Sys module in favor of the 1.8.x FileUtils module. Sys - is still supported in the contrib area. - -== Version 0.2.6 - -* Moved to RubyForge - -== Version 0.2.5 - -* Switched to standard ruby app builder. -* Added no_match option to file matcher. - -== Version 0.2.4 - -* Fixed indir, which neglected to actually change directories. - -== Version 0.2.3 - -* Added rake module for a help target -* Added 'for_files' to Sys -* Added a $rakefile constant -* Added test for selecting proper rule with multiple targets. diff --git a/CONTRIBUTING.rdoc b/CONTRIBUTING.rdoc new file mode 100644 index 000000000..e8430ddb4 --- /dev/null +++ b/CONTRIBUTING.rdoc @@ -0,0 +1,43 @@ += Source Repository + +Rake is currently hosted at github. The github web page is +https://github.com/ruby/rake . The public git clone URL is + + https://github.com/ruby/rake.git + += Running the Rake Test Suite + +If you wish to run the unit and functional tests that come with Rake: + +* +cd+ into the top project directory of rake. +* Install gem dependency using bundler: + + $ bundle install # Install bundler, minitest and rdoc + +* Run the test suite + + $ rake + += Rubocop + +Rake uses Rubocop to enforce a consistent style on new changes being +proposed. You can check your code with Rubocop using: + + $ ./bin/rubocop + += Issues and Bug Reports + +Feel free to submit commits or feature requests. If you send a patch, +remember to update the corresponding unit tests. In fact, I prefer +new feature to be submitted in the form of new unit tests. + +For other information, feel free to ask on the ruby-talk mailing list. + +If you have found a bug in rake please try with the latest version of rake +before filing an issue. Also check History.rdoc for bug fixes that may have +addressed your issue. + +When submitting pull requests please check the rake Travis-CI page for test +failures: + + https://travis-ci.org/ruby/rake diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000..8bcbf50a7 --- /dev/null +++ b/Gemfile @@ -0,0 +1,10 @@ +source "https://rubygems.org" + +gemspec + +group :development do + gem "bundler" + gem "minitest" + gem "coveralls" + gem "rubocop" +end diff --git a/History.rdoc b/History.rdoc new file mode 100644 index 000000000..119747c66 --- /dev/null +++ b/History.rdoc @@ -0,0 +1,2368 @@ +=== 13.0.1 + +==== Bug fixes + +* Fixed bug: Reenabled task raises previous exception on second invokation + Pull Request #271 by thorsteneckel +* Fix an incorrectly resolved arg pattern + Pull Request #327 by mjbellantoni + +=== 13.0.0 + +==== Enhancements + +* Follows recent changes on keyword arguments in ruby 2.7. + Pull Request #326 by nobu +* Make `PackageTask` be able to omit parent directory while packing files + Pull Request #310 by tonytonyjan +* Add order only dependency + Pull Request #269 by take-cheeze + +==== Compatibility changes + +* Drop old ruby versions(< 2.2) + +=== 12.3.3 + +==== Bug fixes + +* Use the application's name in error message if a task is not found. + Pull Request #303 by tmatilai + +==== Enhancements: + +* Use File.open explicitly. + +=== 12.3.2 + +==== Bug fixes + +* Fixed test fails caused by 2.6 warnings. + Pull Request #297 by hsbt + +==== Enhancements: + +* Rdoc improvements. + Pull Request #293 by colby-swandale +* Improve multitask performance. + Pull Request #273 by jsm +* Add alias `prereqs`. + Pull Request #268 by take-cheeze + +=== 12.3.1 + +==== Bug fixes + +* Support did_you_mean >= v1.2.0 which has a breaking change on formatters. + Pull request #262 by FUJI Goro. + +==== Enhancements: + +* Don't run task if it depends on already invoked but failed task. + Pull request #252 by Gonzalo Rodriguez. +* Make space trimming consistent for all task arguments. + Pull request #259 by Gonzalo Rodriguez. +* Removes duplicated inclusion of Rake::DSL in tests. + Pull request #254 by Gonzalo Rodriguez. +* Re-raise a LoadError that didn't come from require in the test loader. + Pull request #250 by Dylan Thacker-Smith. + +=== 12.3.0 + +==== Compatibility Changes + +* Bump `required_ruby_version` to Ruby 2.0.0. Rake has already + removed support for Ruby 1.9.x. + +==== Enhancements: + +* Support `test-bundled-gems` task on ruby core. + +=== 12.2.1 + +==== Bug fixes + +* Fixed to break Capistrano::Application on capistrano3. + +=== 12.2.0 + +==== Enhancements: + +* Make rake easier to use as a library + Pull request #211 by @drbrain +* Fix quadratic performance in FileTask#out_of_date? + Pull request #224 by @doudou +* Clarify output when printing nested exception traces + Pull request #232 by @urbanautomaton + +==== Bug fixes + +* Account for a file that match 2 or more patterns. + Pull request #231 by @styd + +=== 12.1.0 + +==== Enhancements: + +* Added did_you_mean feature for invalid rake task. + Pull request #221 by @xtina-starr +* Enabled to dependency chained by extensions. Pull request #39 by Petr Skocik. +* Make all of string literals to frozen objects on Ruby 2.4 or later. + +==== Bug fixes + +* Typo fixes in rakefile.rdoc. Pull request #180 by Yuta Kurotaki. +* Fix unexpected behavior of file task with dryrun option. + Pull request #183 by @aycabta. +* Make LoadError from running tests more obvious. Pull request #195 + by Eric Hodel. +* Fix unexpected TypeError with hash style option. Pull request #202 + by Kuniaki IGARASHI. + +=== 12.0.0 + +==== Compatibility Changes + +* Removed arguments on clear #157 by Jesse Bowes +* Removed `rake/contrib` packages. These are extracted to `rake-contrib` gem. +* Removed deprecated method named `last\_comment`. + +==== Enhancements: + +* Re-use trace option on `cleanup` task. #164 by Brian Henderson +* Actions adore keyword arguments #174 by Josh Cheek +* Rake::TaskArguments#key? alias of #has_key? #175 by Paul Annesley + +=== 11.3.0 / 2016-09-20 + +==== Enhancements: + +* Remove to reference `Fixnum` constant. Pull request #160 by nobu + +=== 11.2.2 / 2016-06-12 + +==== Bug fixes + +* Fix unexpected behavior with multiple dependencies on Rake::TestTask + +=== 11.2.1 / 2016-06-12 + +==== Bug fixes + +* Fix regression of dependencies handling on Rake::TestTask. Report #139 + +=== 11.2.0 / 2016-06-11 + +==== Bug fixes + +* Fix unexpected cut-out behavior on task description using triple dots + and exclamation. Report #106 from Stephan Kämper and Pull request #134 by Lee +* Fix empty argument assignment with `with_defaults` option. Pull request #135 + by bakunyo +* Ignore to use `hwprefs` on Darwin platform. Use sysctl now. Report #128 + +==== Enhancements + +* Spawn options for sh Pull equest #138 by Eric Hodel. +* Allow to specify dependencies(prerequisites) for Rake::TestTask + Pull request #117 by Tim Maslyuchenko +* Use Bundler task instead of hoe for gem release. +* Remove explicitly load to rubygems for Ruby 1.8. +* Unify to declare `Rake::VERSION`. +* Support xz format for PackageTask. + +=== 11.1.2 / 2016-03-28 + +==== Bug fixes + +* Remove `-W` option when Rake::TestTask#verbose enabled. It's misunderstanding + specification change with Rake 11. Partly revert #67 + +=== 11.1.1 / 2016-03-14 + +==== Bug fixes + +* Use `-W` instead of `--verbose` when Rake::TestTask#verbose enabled. + JRuby doesn't have `--verbose` option. + +=== 11.1.0 / 2016-03-11 + +==== Compatibility Changes + +* Revert to remove `last\_comment`. It will remove Rake 12. + +=== 11.0.1 / 2016-03-09 + +==== Bug fixes + +* Fixed packaging manifest. + +=== 11.0.0 / 2016-03-09 + +==== Bug fixes + +* Correctly handle bad encoding in exception messages. Pull request #113 + by Tomer Brisker +* Fix verbose option at TestTask. Pull request #67 by Mike Blumtritt + +==== Enhancements + +* Make FileList#exclude more analogous to FileList#include. +* Use IO.open instead of Open3.popen3 for CPU counter. +* Make Rake::Task#already_invoked publicly accessible. + Pull request #93 by Joe Rafaniello +* Lookup prerequisites with same name outside of scope instead of + matching self. Pull request #96 by Sandy Vanderbleek +* Make FileList#pathmap behave like String#pathmap. + Pull request #61 by Daniel Tamai +* Add fetch method to task arguments. + Pull request #12 by Chris Keathley +* Use ruby warnings by default. Pull request #97 by Harold Giménez + +==== Compatibility Changes + +* Removed to support Ruby 1.8.x +* Removed constant named `RAKEVERSION` +* Removed Rake::AltSystem +* Removed Rake::RubyForgePublisher +* Removed Rake::TaskManager#last\_comment. Use last\_description. +* Removed Rake::TaskLib#paste +* Removed Top-level SshDirPublisher, SshFreshDirPublisher, SshFilePublisher + and CompositePublisher from lib/rake/contrib/publisher.rb +* Removed "rake/runtest.rb" + +=== 10.5.0 / 2016-01-13 + +==== Enhancements + +* Removed monkey patching for Ruby 1.8. Pull request #46 by Pablo Herrero. +* Inheritance class of Rake::FileList returns always self class. + Pull request #74 by Thomas Scholz + +=== 10.4.2 / 2014-12-02 + +==== Bug fixes + +* Rake no longer edits ARGV. This allows you to re-exec rake from a rake + task. Pull requset #9 by Matt Palmer. +* Documented how Rake::DSL#desc handles sentences in task descriptions. + Issue #7 by Raza Sayed. +* Fixed test error on 1.9.3 with legacy RubyGems. Issue #8 by Matt Palmer. +* Deleted duplicated History entry. Pull request #10 by Yuji Yamamoto. + +=== 10.4.1 / 2014-12-01 + +==== Bug fixes + +* Reverted fix for #277 as it caused numerous issues for rake users. + rails/spring issue #366 by Gustavo Dutra. + +=== 10.4.0 / 2014-11-22 + +==== Enhancements + +* Upgraded to minitest 5. Pull request #292 by Teo Ljungberg. +* Added support for Pathname in rake tasks. Pull request #271 by Randy + Coulman. +* Rake now ignores falsy dependencies which allows for easier programmatic + creation of tasks. Pull request #273 by Manav. +* Rake no longer edits ARGV. This allows you to re-exec rake from a rake + task. Issue #277 by Matt Palmer. +* Etc.nprocessors is used for counting the number of CPUs. + +==== Bug fixes + +* Updated rake manpage. Issue #283 by Nathan Long, pull request #291 by + skittleys. +* Add Rake::LATE to allow rebuilding of files that depend on deleted files. + Bug #286, pull request #287 by David Grayson. +* Fix relinking of files when repackaging. Bug #276 by Muenze. +* Fixed some typos. Pull request #280 by Jed Northridge. +* Try counting CPUs via cpuinfo if host_os was not matched. Pull request + #282 by Edouard B. + +=== 10.3.2 / 2014-05-15 + +==== Bug fixes + +* Rake no longer infinitely loops when showing exception causes that refer to + each other. Bug #272 by Chris Bandy. +* Fixed documentation typos. Bug #275 by Jake Worth. + +=== 10.3.1 / 2014-04-17 + +==== Bug fixes + +* Really stop reporting an error when cleaning already-deleted files. Pull + request #269 by Randy Coulman +* Fixed infinite loop when cleaning already-deleted files on windows. + +=== 10.3 / 2014-04-15 + +==== Enhancements + +* Added --build-all option to rake which treats all file prerequisites as + out-of-date. Pull request #254 by Andrew Gilbert. +* Added Rake::NameSpace#scope. Issue #263 by Jon San Miguel. + +==== Bug fixes + +* Suppress org.jruby package files in rake error messages for JRuby users. + Issue #213 by Charles Nutter. +* Fixed typo, removed extra "h". Pull request #267 by Hsing-Hui Hsu. +* Rake no longer reports an error when cleaning already-deleted files. Pull + request #266 by Randy Coulman. +* Consume stderr while determining CPU count to avoid hang. Issue #268 by + Albert Sun. + +=== 10.2.2 / 2014-03-27 + +==== Bug fixes + +* Restored Ruby 1.8.7 compatibility + +=== 10.2.1 / 2014-03-25 + +==== Bug fixes + +* File tasks including a ':' are now top-level tasks again. Issue #262 by + Josh Holtrop. +* Use sysctl for CPU count for all BSDs. Pull request #261 by Joshua Stein. +* Fixed CPU detection for unknown platforms. + +=== 10.2.0 / 2014-03-24 + +==== Enhancements + +* Rake now requires Ruby 1.9 or newer. For me, this is a breaking change, but + it seems that Jim planned to release it with Rake 10.2. See also pull + request #247 by Philip Arndt. +* Rake now allows you to declare tasks under a namespace like: + + task 'a:b' do ... end + + Pull request #232 by Judson Lester. +* Task#source defaults to the first prerequisite in non-rule tasks. Pull + request #215 by Avdi Grimm. +* Rake now automatically rebuilds and reloads imported files. Pull request + #209 by Randy Coulman. +* The rake task arguments can contain escaped commas. Pull request #214 by + Filip Hrbek. +* Rake now prints the exception class on errors. Patch #251 by David Cornu. + +==== Bug fixes + +* Fixed typos. Pull request #256 by Valera Rozuvan, #250 via Jake Worth, #260 + by Zachary Scott. +* Fixed documentation for calling tasks with arguments. Pull request #235 by + John Varghese. +* Clarified `rake -f` usage message. Pull request #252 by Marco Pfatschbacher. +* Fixed a test failure on windows. Pull request #231 by Hiroshi Shirosaki. +* Fixed corrupted rake.1.gz. Pull request #225 by Michel Boaventura. +* Fixed bug in can\_detect\_signals? in test. Patch from #243 by Alexey + Borzenkov. + +=== 10.1.1 + +* Use http://github.com/jimweirich/rake instead of http://rake.rubyforge.org for + canonical project url. + +=== 10.1.0 + +==== Changes + +===== New Features + +* Add support for variable length task argument lists. If more actual + arguments are supplied than named arguments, then the extra + arguments values will be in args.extras. + +* Application name is not displayed in the help banner. (Previously + "rake" was hardcoded, now rake-based applications can display their + own names). + +===== Bug Fixes + +Bug fixes include: + +* Fix backtrace suppression issues. + +* Rules now explicit get task arguments passed to them. + +* Rename FileList#exclude? to FileList#exclude\_from\_list? to avoid + conflict with new Rails method. + +* Clean / Clobber tasks now report failure to remove files. + +* Plus heaps of internal code cleanup. + +==== Thanks + +As usual, it was input from users that drove a lot of these changes. +The following people contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Michael Nikitochkin (general code cleanup) +* Vipul A M (general code cleanup) +* Dennis Bell (variable length task argument lists) +* Jacob Swanner (rules arguments) +* Rafael Rosa Fu (documentation typo) +* Stuart Nelson (install.rb fixes) +* Lee Hambley (application name in help banner) + +-- Jim Weirich + +=== 10.0.3 + + "Jim, when will Rake reach version 1.0?" + +Over the past several years I've been asked that question at +conferences, panels and over twitter. Due to historical reasons (or +maybe just plain laziness) Rake has (incorrectly) been treating the +second digit of the version as the major release number. So in my head +Rake was already at version 9. + +Well, it's time to fix things. This next version of Rake drops old, +crufty, backwards compatibility hacks such as top level constants, DSL +methods defined in Object and numerous other features that are just no +longer desired. It's also time to drop the leading zero from the +version number as well and call this new version of rake what it +really is: Version 10. + +So, welcome to Rake 10.0! + +Rake 10 is actually feature identical to the latest version of Rake 9 +(that would be the version spelled 0.9.3), *except* that Rake 10 drops +all the sundry deprecated features that have accumulated over the years. + +If your Rakefile is up to date and current with all the new features +of Rake 10, you are ready to go. If your Rakefile still uses a few +deprecated feeatures, feel free to use Rake 9 (0.9.3) with the same +feature set. Just be aware that future features will be in Rake 10 +family line. + +==== Changes + +As mentioned above, there are no new features in Rake 10. However, +there are a number of features missing: + +* Classic namespaces are now gone. Rake is no longer able to reflect + the options settings in the global variables ($rakefile, $show\_tasks, + $show\_prereqs, $trace, $dryrun and $silent). The + --classic-namespace option is no longer supported. + +* Global constants are no longer supported. This includes + Task, FileTask, FileCreationTask and + RakeApp). The constant missing hook to warn about using + global rake constants has been removed. + +* The Rake DSL methods (task, file, directory, etc) are in their own + module (Rake::DSL). The stub versions of these methods (that printed + warnings) in Object have been removed. However, the DSL methods are + added to the top-level main object. Since main is + not in the inheritance tree, the presence of the DSL methods in main + should be low impact on other libraries. + + If you want to use the Rake DSL commands from your own code, just + include Rake::DSL into your own classes and modules. + +* The deprecated syntax for task arguments (the one using + :needs) has been removed. + +* The --reduce-compat flag has been removed (it's not needed + anymore). + +* The deprecated rake/sys.rb library has been removed. + +* The deprecated rake/rdoctask.rb library has been removed. + RDoc supplies its own rake task now. + +* The deprecated rake/gempackagetask.rb library has been + removed. Gem supplies its own package task now. + +There is one small behavioral change: + +* Non-file tasks now always report the current time as their time + stamp. This is different from the previous behavior where non-file + tasks reported current time only if there were no prerequisites, and + the max prerequisite timestamp otherwise. This lead to inconsistent + and surprising behavior when adding prerequisites to tasks that in + turn were prequisites to file tasks. The new behavior is more + consistent and predictable. + +==== Changes (from 0.9.3, 0.9.4, 0.9.5) + +Since Rake 10 includes the changes from the last version of Rake 9, +we'll repeat the changes for versions 0.9.3 through 0.9.5 here. + +===== New Features (in 0.9.3) + +* Multitask tasks now use a thread pool. Use -j to limit the number of + available threads. + +* Use -m to turn regular tasks into multitasks (use at your own risk). + +* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to + programatically add rake task libraries. + +* You can specific backtrace suppression patterns (see + --suppress-backtrace) + +* Directory tasks can now take prerequisites and actions + +* Use --backtrace to request a full backtrace without the task trace. + +* You can say "--backtrace=stdout" and "--trace=stdout" to route trace + output to standard output rather than standard error. + +* Optional 'phony' target (enable with 'require 'rake/phony'") for + special purpose builds. + +* Task#clear now clears task comments as well as actions and + prerequisites. Task#clear_comment will specifically target comments. + +* The --all option will force -T and -D to consider all the tasks, + with and without descriptions. + +===== Bug Fixes (in 0.9.3) + +* Semi-colons in windows rakefile paths now work. + +* Improved Control-C support when invoking multiple test suites. + +* egrep method now reads files in text mode (better support for + Windows) + +* Better deprecation line number reporting. + +* The -W option now works with all tasks, whether they have a + description or not. + +* File globs in rake should not be sorted alphabetically, independent + of file system and platform. + +* Numerous internal improvements. + +* Documentation typos and fixes. + +===== Bug Fixes (in 0.9.4) + +* Exit status with failing tests is not correctly set to non-zero. + +* Simplified syntax for phony task (for older versions of RDoc). + +* Stand alone FileList usage gets glob function (without loading in + extra dependencies) + +===== Bug Fixes (in 0.9.5) + +* --trace and --backtrace no longer swallow following task names. + +==== Thanks + +As usual, it was input from users that drove a lot of these changes. The +following people contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich + +=== 10.0.2 + +==== Changes + +===== Bug Fixes + +* --trace and --backtrace no longer swallow following task names. + +==== Thanks + +As usual, it was input from users that drove a lot of these changes. The +following people contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich + +=== 10.0.1 + +==== Changes + +===== Bug Fixes + +* Exit status with failing tests is not correctly set to non-zero. + +* Simplified syntax for phony task (for older versions of RDoc). + +* Stand alone FileList usage gets glob function (without loading in + extra dependencies) + +==== Thanks + +As usual, it was input from users that drove a lot of these changes. The +following people contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich + +=== 10.0.0 + + "Jim, when will Rake reach version 1.0?" + +Over the past several years I've been asked that question at +conferences, panels and over twitter. Due to historical reasons (or +maybe just plain laziness) Rake has (incorrectly) been treating the +second digit of the version as the major release number. So in my head +Rake was already at version 9. + +Well, it's time to fix things. This next version of Rake drops old, +crufty, backwards compatibility hacks such as top level constants, DSL +methods defined in Object and numerous other features that are just no +longer desired. It's also time to drop the leading zero from the +version number as well and call this new version of rake what it +really is: Version 10. + +So, welcome to Rake 10.0! + +Rake 10 is actually feature identical to the latest version of Rake 9 +(that would be the version spelled 0.9.3), *except* that Rake 10 drops +all the sundry deprecated features that have accumulated over the years. + +If your Rakefile is up to date and current with all the new features +of Rake 10, you are ready to go. If your Rakefile still uses a few +deprecated feeatures, feel free to use Rake 9 (0.9.3) with the same +feature set. Just be aware that future features will be in Rake 10 +family line. + +==== Changes in 10.0 + +As mentioned above, there are no new features in Rake 10. However, +there are a number of features missing: + +* Classic namespaces are now gone. Rake is no longer able to reflect + the options settings in the global variables ($rakefile, $show\_tasks, + $show\_prereqs, $trace, $dryrun and $silent). The + --classic-namespace option is no longer supported. + +* Global constants are no longer supported. This includes + Task, FileTask, FileCreationTask and + RakeApp). The constant missing hook to warn about using + global rake constants has been removed. + +* The Rake DSL methods (task, file, directory, etc) are in their own + module (Rake::DSL). The stub versions of these methods (that printed + warnings) in Object have been removed. However, the DSL methods are + added to the top-level main object. Since main is + not in the inheritance tree, the presence of the DSL methods in main + should be low impact on other libraries. + + If you want to use the Rake DSL commands from your own code, just + include Rake::DSL into your own classes and modules. + +* The deprecated syntax for task arguments (the one using + :needs) has been removed. + +* The --reduce-compat flag has been removed (it's not needed + anymore). + +* The deprecated rake/sys.rb library has been removed. + +* The deprecated rake/rdoctask.rb library has been removed. + RDoc supplies its own rake task now. + +* The deprecated rake/gempackagetask.rb library has been + removed. Gem supplies its own package task now. + +There is one small behavioral change: + +* Non-file tasks now always report the current time as their time + stamp. This is different from the previous behavior where non-file + tasks reported current time only if there were no prerequisites, and + the max prerequisite timestamp otherwise. This lead to inconsistent + and surprising behavior when adding prerequisites to tasks that in + turn were prequisites to file tasks. The new behavior is more + consistent and predictable. + +==== Changes (from 0.9.3) + +Since Rake 10 includes the changes from the last version of Rake 9, +we'll repeat the changes for version 0.9.3 here. + +===== New Features + +* Multitask tasks now use a thread pool. Use -j to limit the number of + available threads. + +* Use -m to turn regular tasks into multitasks (use at your own risk). + +* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to + programatically add rake task libraries. + +* You can specific backtrace suppression patterns (see + --suppress-backtrace) + +* Directory tasks can now take prerequisites and actions + +* Use --backtrace to request a full backtrace without the task trace. + +* You can say "--backtrace=stdout" and "--trace=stdout" to route trace + output to standard output rather than standard error. + +* Optional 'phony' target (enable with 'require 'rake/phony'") for + special purpose builds. + +* Task#clear now clears task comments as well as actions and + prerequisites. Task#clear_comment will specifically target comments. + +* The --all option will force -T and -D to consider all the tasks, + with and without descriptions. + +===== Bug Fixes + +* Semi-colons in windows rakefile paths now work. + +* Improved Control-C support when invoking multiple test suites. + +* egrep method now reads files in text mode (better support for + Windows) + +* Better deprecation line number reporting. + +* The -W option now works with all tasks, whether they have a + description or not. + +* File globs in rake should not be sorted alphabetically, independent + of file system and platform. + +* Numerous internal improvements. + +* Documentation typos and fixes. + + +==== Thanks + +As usual, it was input from users that drove a lot of these changes. The +following people contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich + +=== 0.9.6 + +Rake version 0.9.6 contains a number of fixes mainly for merging +Rake into the Ruby source tree and fixing tests. + +==== Changes + +===== Bug Fixes (0.9.6) + +* Better trace output when using a multi-threaded Rakefile. +* Arg parsing is now consistent for tasks and multitasks. +* Skip exit code test in versions of Ruby that don't support it well. + +Changes for better integration with the Ruby source tree: + +* Fix version literal for Ruby source tree build. +* Better loading of libraries for testing in Ruby build. +* Use the ruby version provided by Ruby's tests. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich + +=== 0.9.5 + +Rake version 0.9.5 contains a number of bug fixes. + +==== Changes + +===== Bug Fixes (0.9.5) + +* --trace and --backtrace no longer swallow following task names. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich + +=== 0.9.4 + +Rake version 0.9.4 contains a number of bug fixes. + +==== Changes + +===== Bug Fixes (0.9.4) + +* Exit status with failing tests is not correctly set to non-zero. + +* Simplified syntax for phony task (for older versions of RDoc). + +* Stand alone FileList usage gets glob function (without loading in + extra dependencies) + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich + +=== 0.9.3 + +Rake version 0.9.3 contains some new, backwards compatible features and +a number of bug fixes. + +==== Changes + +===== New Features + +* Multitask tasks now use a thread pool. Use -j to limit the number of + available threads. + +* Use -m to turn regular tasks into multitasks (use at your own risk). + +* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to + programatically add rake task libraries. + +* You can specific backtrace suppression patterns (see + --suppress-backtrace) + +* Directory tasks can now take prerequisites and actions + +* Use --backtrace to request a full backtrace without the task trace. + +* You can say "--backtrace=stdout" and "--trace=stdout" to route trace + output to standard output rather than standard error. + +* Optional 'phony' target (enable with 'require 'rake/phony'") for + special purpose builds. + +* Task#clear now clears task comments as well as actions and + prerequisites. Task#clear_comment will specifically target comments. + +* The --all option will force -T and -D to consider all the tasks, + with and without descriptions. + +===== Bug Fixes + +* Semi-colons in windows rakefile paths now work. + +* Improved Control-C support when invoking multiple test suites. + +* egrep method now reads files in text mode (better support for + Windows) + +* Better deprecation line number reporting. + +* The -W option now works with all tasks, whether they have a + description or not. + +* File globs in rake should not be sorted alphabetically, independent + of file system and platform. + +* Numerous internal improvements. + +* Documentation typos and fixes. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Aaron Patterson +* Dylan Smith +* Jo Liss +* Jonas Pfenniger +* Kazuki Tsujimoto +* Michael Bishop +* Michael Elufimov +* NAKAMURA Usaku +* Ryan Davis +* Sam Grönblom +* Sam Phippen +* Sergio Wong +* Tay Ray Chuan +* grosser +* quix + +Also, many thanks to Eric Hodel for assisting with getting this release +out the door. + +-- Jim Weirich + +=== Rake 0.9.2.2 + +Rake version 0.9.2.2 is mainly bug fixes. + +==== Changes + +* The rake test loader now removes arguments it has processed. Issue #51 +* Rake::TaskArguments now responds to #values\_at +* RakeFileUtils.verbose_flag = nil silences output the same as 0.8.7 +* Rake tests are now directory-independent +* Rake tests are no longer require flexmock +* Commands constant is no longer polluting top level namespace. +* Show only the interesting portion of the backtrace by default (James M. Lawrence). +* Added --reduce-compat option to remove backward compatible DSL hacks (James M. Lawrence). + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence (quix) +* Roger Pack +* Cezary Baginski +* Sean Scot August Moon +* R.T. Lechow +* Alex Chaffee +* James Tucker +* Matthias Lüdtke +* Santiago Pastorino + +Also, bit thanks to Eric Hodel for assisting with getting this release +out the door (where "assisting" includes, but is not by any means +limited to, "pushing" me to get it done). + +-- Jim Weirich + +=== 0.9.2 + +Rake version 0.9.2 has a few small fixes. See below for details. + +==== Changes + +* Support for Ruby 1.8.6 was fixed. +* Global DSL warnings now honor --no-deprecate + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence (quix) +* Roger Pack +* Cezary Baginski +* Sean Scot August Moon +* R.T. Lechow +* Alex Chaffee +* James Tucker +* Matthias Lüdtke +* Santiago Pastorino + +Also, bit thanks to Eric Hodel for assisting with getting this release +out the door (where "assisting" includes, but is not by any means +limited to, "pushing" me to get it done). + +-- Jim Weirich + +=== 0.9.1 + +Rake version 0.9.1 has a number of bug fixes and enhancments (see +below for more details). Additionally, the internals have be slightly +restructured and improved. + +==== Changes + +Rake 0.9.1 adds back the global DSL methods, but with deprecation +messages. This allows Rake 0.9.1 to be used with older rakefiles with +warning messages. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence (quix) +* Roger Pack +* Cezary Baginski +* Sean Scot August Moon +* R.T. Lechow +* Alex Chaffee +* James Tucker +* Matthias Lüdtke +* Santiago Pastorino + +Also, bit thanks to Eric Hodel for assisting with getting this release +out the door (where "assisting" includes, but is not by any means +limited to, "pushing" me to get it done). + +-- Jim Weirich + +=== 0.9.0 + +Rake version 0.9.0 has a number of bug fixes and enhancments (see +below for more details). Additionally, the internals have be slightly +restructured and improved. + +==== Changes + +===== New Features / Enhancements / Bug Fixes in Version 0.9.0 + +* Rake now warns when the deprecated :needs syntax used (and suggests + the proper syntax in the warning). + +* Moved Rake DSL commands to top level ruby object 'main'. Rake DSL + commands are no longer private methods in Object. (Suggested by + James M. Lawrence/quix) + +* Rake now uses case-insensitive comparisons to find the Rakefile on Windows. + Based on patch by Roger Pack. + +* Rake now requires (instead of loads) files in the test task. Patch by Cezary + Baginski. + +* Fixed typos. Patches by Sean Scot August Moon and R.T. Lechow. + +* Rake now prints the Rakefile directory only when it's different from the + current directory. Patch by Alex Chaffee. + +* Improved rakefile_location discovery on Windows. Patch by James Tucker. + +* Rake now recognizes "Windows Server" as a windows system. Patch by Matthias + Lüdtke + +* Rake::RDocTask is deprecated. Use RDoc::Task from RDoc 2.4.2+ (require + 'rdoc/task') + +* Rake::GemPackageTask is deprecated. Use Gem::PackageTask (require + 'rubygems/package\_task') + +* Rake now outputs various messages to $stderr instead of $stdout. + +* Rake no longer emits warnings for Config. Patch by Santiago Pastorino. + +* Removed Rake's DSL methods from the top level scope. If you need to + call 'task :xzy' in your code, include Rake::DSL into your class, or + put the code in a Rake::DSL.environment do ... end block. + +* Split rake.rb into individual files. + +* Support for the --where (-W) flag for showing where a task is defined. + +* Fixed quoting in test task. + (http://onestepback.org/redmine/issues/show/44, + http://www.pivotaltracker.com/story/show/1223138) + +* Fixed the silent option parsing problem. + (http://onestepback.org/redmine/issues/show/47) + +* Fixed :verbose=>false flag on sh and ruby commands. + +* Rake command line options may be given by default in a RAKEOPT + environment variable. + +* Errors in Rake will now display the task invocation chain in effect + at the time of the error. + +* Accepted change by warnickr to not expand test patterns in shell + (allowing more files in the test suite). + +* Fixed that file tasks did not perform prereq lookups in scope + (Redmine #57). + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence (quix) +* Roger Pack +* Cezary Baginski +* Sean Scot August Moon +* R.T. Lechow +* Alex Chaffee +* James Tucker +* Matthias Lüdtke +* Santiago Pastorino + +Also, bit thanks to Eric Hodel for assisting with getting this release +out the door (where "assisting" includes, but is not by any means +limited to, "pushing" me to get it done). + +-- Jim Weirich + + +=== 0.8.7 + +Rake version 0.8.5 introduced greatly improved support for executing +commands on Windows. The "sh" command now has the same semantics on +Windows that it has on Unix based platforms. + +Rake version 0.8.6 includes minor fixes the the RDoc generation. +Rake version 0.8.7 includes a minor fix for JRuby running on windows. + +==== Changes + +===== New Features / Enhancements in Version 0.8.5 + +* Improved implementation of the Rake system command for Windows. + (patch from James M. Lawrence/quix) + +* Support for Ruby 1.9's improved system command. (patch from James + M. Lawrence/quix) + +* Rake now includes the configured extension when invoking an + executable (Config::CONFIG['EXEEXT]) + +===== Bug Fixes in Version 0.8.5 + +* Environment variable keys are now correctly cased (it matters in + some implementations). + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Charles Nutter + +-- Jim Weirich + +=== 0.8.6 + +Rake version 0.8.5 introduced greatly improved support for executing +commands on Windows. The "sh" command now has the same semantics on +Windows that it has on Unix based platforms. + +Rake version 0.8.5 includes minor fixes the the RDoc generation. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence/quix +* Luis Lavena + +-- Jim Weirich + +=== 0.8.5 + +Rake version 0.8.5 is a new release of Rake with greatly improved +support for executing commands on Windows. The "sh" command now has +the same semantics on Windows that it has on Unix based platforms. + +==== Changes + +===== New Features / Enhancements in Version 0.8.5 + +* Improved implementation of the Rake system command for Windows. + (patch from James M. Lawrence/quix) + +* Support for Ruby 1.9's improved system command. (patch from James + M. Lawrence/quix) + +* Rake now includes the configured extension when invoking an + executable (Config::CONFIG['EXEEXT]) + +===== Bug Fixes in Version 0.8.5 + +* Environment variable keys are now correctly cased (it matters in + some implementations). + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence/quix +* Luis Lavena + +-- Jim Weirich + +=== 0.8.4 + +Rake version 0.8.4 is a bug-fix release of rake. + +NOTE: The version of Rake that comes with Ruby 1.9 has diverged + slightly from the core Rake code base. Rake 0.8.4 will work + with Ruby 1.9, but is not a strict upgrade for the Rake that + comes with Ruby 1.9. A (near) future release of Rake will unify + those two codebases. + +==== Letter Writing Campaign + +Thanks to Aaron Patterson (@tenderlove) and Eric Hodel (@drbrain) for +their encouraging support in organizing a letter writing campaign to +lobby for the "Warning Free" release of rake 0.8.4. A special callout +goes to Jonathan D. Lord, Sr (Dr. Wingnut) whose postcard was the +first to actually reach me. (see +http://tenderlovemaking.com/2009/02/26/we-need-a-new-version-of-rake/ +for details) + +==== Changes + +===== New Features / Enhancements in Version 0.8.4 + +* Case is preserved on rakefile names. (patch from James + M. Lawrence/quix) + +* Improved Rakefile case insensitivity testing (patch from Luis + Lavena). + +* Windows system dir search order is now: HOME, HOMEDRIVE + HOMEPATH, + APPDATA, USERPROFILE (patch from Luis Lavena) + +* MingGW is now recognized as a windows platform. (patch from Luis + Lavena) + +===== Bug Fixes in Version 0.8.4 + +* Removed reference to manage_gem to fix the warning produced by the + gem package task. + +* Fixed stray ARGV option problem that was interfering with + Test::Unit::Runner. (patch from Pivotal Labs) + +===== Infrastructure Improvements in Version 0.8.4 + +* Numerous fixes to the windows test suite (patch from Luis Lavena). + +* Improved Rakefile case insensitivity testing (patch from Luis + Lavena). + +* Better support for windows paths in the test task (patch from Simon + Chiang/bahuvrihi) + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence/quix +* Luis Lavena +* Pivotal Labs +* Simon Chiang/bahuvrihi + +-- Jim Weirich + +=== 0.8.3 + +Rake version 0.8.3 is a bug-fix release of rake. + +==== Changes + +===== Bug Fixes in Version 0.8.3 + +* Enhanced the system directory detection in windows. We now check + HOMEDRIVE/HOMEPATH and USERPROFILE if APPDATA isn't found. (Patch + supplied by James Tucker). Rake no long aborts if it can't find the + directory. + +* Added fix to handle ruby installations in directories with spaces in + their name. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Edwin Pratomo +* Gavin Stark +* Adam Q. Salter +* Adam Majer +* Emanuel Indermühle +* Ittay Dror +* Bheeshmar Redheendran (for spending an afternoon with me debugging + windows issues) + +-- Jim Weirich + + +=== 0.8.2 + +Rake version 0.8.2 is a new release of rake that includes a number of +new features and numerous bug fixes. + +==== Changes + +===== New Features in Version 0.8.2 + +* Switched from getoptlong to optparse (patches supplied by Edwin + Pratomo). + +* The -T option will now attempt to dynamically sense the size of the + terminal. The -T output will only self-truncate if the output is a + tty. However, if RAKE_COLUMNS is explicitly set, it will be honored + in any case. (Patch provided by Gavin Stark). + +* The following public methods have been added to rake task objects: + + * task.clear -- Clear both the prerequisites and actions of the + target rake task. + * task.clear_prerequisites -- Clear all the existing prerequisites + from the target rake task. + * task.clear_actions -- Clear all the existing actions from the + target rake task. + * task.reenable -- Re-enable a task, allowing its actions to be + executed again if the task is invoked. + +* Changed RDoc test task to have no default template. This makes it + easier for the tempate to pick up the template from the environment. + +* Default values for task arguments can easily be specified with the + :with_defaults method. (Idea for default argument merging supplied + by (Adam Q. Salter) + +===== Bug Fixes in Version 0.8.2 + +* Fixed bug in package task so that it will include the subdir + directory in the package for testing. (Bug found by Adam Majer) + +* Fixed filename dependency order bug in test\_inspect\_pending and + test\_to\_s\_pending. (Bug found by Adam Majer) + +* Fixed check for file utils options to make them immune to the + symbol/string differences. (Patch supplied by Edwin Pratomo) + +* Fixed bug with rules involving multiple source, where only the first + dependency of a rule has any effect (Patch supplied by Emanuel + Indermühle) + +* FileList#clone and FileList#dup have better sematics w.r.t. taint + and freeze. + +* Changed from using Mutex to Monitor. Evidently Mutex causes thread + join errors when Ruby is compiled with -disable-pthreads. (Patch + supplied by Ittay Dror) + +* Fixed bug in makefile parser that had problems with extra spaces in + file task names. (Patch supplied by Ittay Dror) + +==== Other changes in Version 0.8.2 + +* Added ENV var to rake's own Rakefile to prevent OS X from including + extended attribute junk in the rake package tar file. (Bug found by + Adam Majer) + +* Added a performance patch for reading large makefile dependency + files. (Patch supplied by Ittay Dror) + +==== Task Argument Examples + +Prior to version 0.8.0, rake was only able to handle command line +arguments of the form NAME=VALUE that were passed into Rake via the +ENV hash. Many folks had asked for some kind of simple command line +arguments, perhaps using "--" to separate regular task names from +argument values on the command line. The problem is that there was no +easy way to associate positional arguments on the command line with +different tasks. Suppose both tasks :a and :b expect a command line +argument: does the first value go with :a? What if :b is run first? +Should it then get the first command line argument. + +Rake 0.8.0 solves this problem by explicitly passing values directly +to the tasks that need them. For example, if I had a release task +that required a version number, I could say: + + rake release[0.8.2] + +And the string "0.8.2" will be passed to the :release task. Multiple +arguments can be passed by separating them with a comma, for example: + + rake name[john,doe] + +Just a few words of caution. The rake task name and its arguments +need to be a single command line argument to rake. This generally +means no spaces. If spaces are needed, then the entire rake + +argument string should be quoted. Something like this: + + rake "name[billy bob, smith]" + +(Quoting rules vary between operating systems and shells, so make sure +you consult the proper docs for your OS/shell). + +===== Tasks that Expect Parameters + +Parameters are only given to tasks that are setup to expect them. In +order to handle named parameters, the task declaration syntax for +tasks has been extended slightly. + +For example, a task that needs a first name and last name might be +declared as: + + task :name, :first_name, :last_name + +The first argument is still the name of the task (:name in this case). +The next to argumements are the names of the parameters expected by +:name (:first_name and :last_name in the example). + +To access the values of the parameters, the block defining the task +behaviour can now accept a second parameter: + + task :name, :first_name, :last_name do |t, args| + puts "First name is #{args.first_name}" + puts "Last name is #{args.last_name}" + end + +The first argument of the block "t" is always bound to the current +task object. The second argument "args" is an open-struct like object +that allows access to the task arguments. Extra command line +arguments to a task are ignored. Missing command line arguments are +given the nil value. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Edwin Pratomo +* Gavin Stark +* Adam Q. Salter +* Adam Majer +* Emanuel Indermühle +* Ittay Dror +* Bheeshmar Redheendran (for spending an afternoon with me debugging + windows issues) + +-- Jim Weirich + +=== 0.8.0/0.8.1 + +Rake version 0.8.0 is a new release of rake that includes serveral new +features. + +==== Changes + +===== New Features in Version 0.8.0 + +* Tasks can now receive command line parameters. See the examples + below for more details. + +* Comments are limited to 80 columns on output, but full comments can + be seen by using the -D parameter. (feature suggested by Jamis + Buck). + +* Explicit exit(n) calls will now set the exit status to n. (patch + provided by Stephen Touset). + +* Rake is now compatible with Ruby 1.9. + +Version 0.8.1 is a minor update that includes additional Ruby 1.9 +compatibility fixes. + +==== Task Argument Examples + +Prior to version 0.8.0, rake was only able to handle command line +arguments of the form NAME=VALUE that were passed into Rake via the +ENV hash. Many folks had asked for some kind of simple command line +arguments, perhaps using "--" to separate regular task names from +argument values on the command line. The problem is that there was no +easy way to associate positional arguments on the command line with +different tasks. Suppose both tasks :a and :b expect a command line +argument: does the first value go with :a? What if :b is run first? +Should it then get the first command line argument. + +Rake 0.8.0 solves this problem by explicitly passing values directly +to the tasks that need them. For example, if I had a release task +that required a version number, I could say: + + rake release[0.8.0] + +And the string "0.8.0" will be passed to the :release task. Multiple +arguments can be passed by separating them with a comma, for example: + + rake name[john,doe] + +Just a few words of caution. The rake task name and its arguments +need to be a single command line argument to rake. This generally +means no spaces. If spaces are needed, then the entire rake + +argument string should be quoted. Something like this: + + rake "name[billy bob, smith]" + +(Quoting rules vary between operating systems and shells, so make sure +you consult the proper docs for your OS/shell). + +===== Tasks that Expect Parameters + +Parameters are only given to tasks that are setup to expect them. In +order to handle named parameters, the task declaration syntax for +tasks has been extended slightly. + +For example, a task that needs a first name and last name might be +declared as: + + task :name, :first_name, :last_name + +The first argument is still the name of the task (:name in this case). +The next to argumements are the names of the parameters expected by +:name (:first_name and :last_name in the example). + +To access the values of the parameters, the block defining the task +behaviour can now accept a second parameter: + + task :name, :first_name, :last_name do |t, args| + puts "First name is #{args.first_name}" + puts "Last name is #{args.last_name}" + end + +The first argument of the block "t" is always bound to the current +task object. The second argument "args" is an open-struct like object +that allows access to the task arguments. Extra command line +arguments to a task are ignored. Missing command line arguments are +given the nil value. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* Jamis Buck (for comment formatting suggestions) +* Stephen Touset (for exit status patch). + +-- Jim Weirich + + +=== 0.7.3 + +Rake version 0.7.3 is a minor release that includes some refactoring to better +support custom Rake applications. + +==== Changes + +===== New Features in Version 0.7.3 + +* Added the +init+ and +top_level+ methods to make the creation of custom Rake applications a bit easier. E.g. + + gem 'rake', ">= 0.7.3" + require 'rake' + + Rake.application.init('myrake') + + task :default do + something_interesting + end + + Rake.application.top_level + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +-- Jim Weirich + + +=== 0.7.2 + + +Version 0.7.2 supplies a bug fix and a few minor enhancements. In +particular, the new version fixes an incompatibility with the soon to +be released Ruby 1.8.6. We strongly recommend upgrading to Rake 0.7.2 +in order to be compatible with the new version of Ruby. + +==== Changes + +===== Bug Fixes in 0.7.2 + +There are quite a number of bug fixes in the new 0.7.2 version of +Rake: + +* Removed dependency on internal fu_xxx functions from FileUtils. + +* Error messages are now send to stderr rather than stdout (from + Payton Quackenbush). + +* Better error handling on invalid command line arguments (from Payton + Quackenbush). + +* Fixed some bugs where the application object was going to the global + appliation instead of using its own data. + +* Fixed the method name leak from FileUtils (bug found by Glenn + Vanderburg). + +* Added test for noop, bad_option and verbose flags to sh command. + +* Added a description to the gem task in GemPackageTask. + +* Fixed a bug when rules have multiple prerequisites (patch by Joel + VanderWerf) + +* Added the handful of RakeFileUtils to the private method as well. + +===== New Features in 0.7.2 + +The following new features are available in Rake version 0.7.2: + +* Added square and curly bracket patterns to FileList#include (Tilman + Sauerbeck). + +* FileLists can now pass a block to FileList#exclude to exclude files + based on calculated values. + +* Added plain filename support to rule dependents (suggested by Nobu + Nakada). + +* Added pathmap support to rule dependents. In other words, if a + pathmap format (beginning with a '%') is given as a Rake rule + dependent, then the name of the depend will be the name of the + target with the pathmap format applied. + +* Added a 'tasks' method to a namespace to get a list of tasks + associated with the namespace. + +* Added tar_command and zip_command options to the Package task. + +* The clean task will no longer delete 'core' if it is a directory. + +===== Internal Rake Improvements + +The following changes will are mainly internal improvements and +refactorings and have little effect on the end user. But they may be +of interest to the general public. + +* Added rcov task and updated unit testing for better code coverage. + +* Added a 'shame' task to the Rakefile. + +* Added rake_extension to handle detection of extension collisions. + +* Added a protected 'require "rubygems"' to test/test_application to + unbreak cruisecontrol.rb. + +* Removed rake\_dup. Now we just simply rescue a bad dup. + +* Refactored the FileList reject logic to remove duplication. + +* Removed if \_\_FILE\_\_ at the end of the rake.rb file. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. +The following people either contributed patches, made suggestions or +made otherwise helpful comments. Thanks to ... + +* Payton Quackenbush -- For several error handling improvements. + +* Glenn Vanderburg -- For finding and fixing the method name leak from + FileUtils. + +* Joel VanderWerf -- for finding and fixing a bug in the handling of + multiple prerequisites. + +* Tilman Sauerbeck -- For some enhancing FileList to support more + advanced file globbing. + +* Nobu Nakada -- For suggesting plain file name support to rule dependents. + +-- Jim Weirich + +=== 0.7.1 + +Version 0.7.1 supplies a bug fix and a few minor enhancements. + +==== Changes + +===== Bug Fixes in 0.7.1 + +* Changes in the exception reported for the FileUtils.ln caused + safe_ln to fail with a NotImplementedError. Rake 0.7.1 will now + catch that error or any StandardError and properly fall back to + using +cp+. + +===== New Features in 0.7.1 + +* You can filter the results of the --task option by supplying an + optional regular expression. This allows the user to easily find a + particular task name in a long list of possible names. + +* Transforming procs in a rule may now return a list of prerequisites. + This allows more flexible rule formation. + +* FileList and String now support a +pathmap+ melthod that makes the + transforming paths a bit easier. See the API docs for +pathmap+ for + details. + +* The -f option without a value will disable the search for a + Rakefile. This allows the Rakefile to be defined entirely in a + library (and loaded with the -r option). The current working + directory is not changed when this is done. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. +The following people either contributed patches, made suggestions or +made otherwise helpful comments. Thanks to ... + +* James Britt and Assaph Mehr for reporting and helping to debug the + safe_ln issue. + +-- Jim Weirich + + +=== 0.7.0 + +These changes for Rake have been brewing for a long time. Here they +are, I hope you enjoy them. + +==== Changes + +===== New Features + +* Name space support for task names (see below). +* Prerequisites can be executed in parallel (see below). +* Added safe_ln support for openAFS (via Ludvig Omholt). +* RDoc defaults to internal (in-process) invocation. The old behavior + is still available by setting the +external+ flag to true. +* Rakefiles are now loaded with the expanded path to prevent + accidental pollution from the Ruby load path. +* Task objects my now be used in prerequisite lists directly. +* Task objects (in addition to task names) may now be included in the + prerequisite list of a task. +* Internals cleanup and refactoring. + +===== Bug Fixes + +* Compatibility fixes for Ruby 1.8.4 FileUtils changes. + +===== Namespaces + +Tasks can now be nested inside their own namespaces. Tasks within one +namespace will not accidentally interfer with tasks named in a different +namespace. + +For example: + + namespace "main" do + task :build do + # Build the main program + end + end + + namespace "samples" do + task :build do + # Build the sample programs + end + end + + task :build_all => ["main:build", "samples:build"] + +Even though both tasks are named :build, they are separate tasks in +their own namespaces. The :build_all task (defined in the toplevel +namespace) references both build tasks in its prerequisites. + +You may invoke each of the individual build tasks with the following +commands: + + rake main:build + rake samples:build + +Or invoke both via the :build_all command: + + rake build_all + +Namespaces may be nested arbitrarily. Since the name of file tasks +correspond to the name of a file in the external file system, +FileTasks are not affected by the namespaces. + +See the Rakefile format documentation (in the Rake API documents) for +more information. + +===== Parallel Tasks + +Sometimes you have several tasks that can be executed in parallel. By +specifying these tasks as prerequisites to a +multitask+ task. + +In the following example the tasks copy\_src, copy\_doc and copy\_bin +will all execute in parallel in their own thread. + + multitask :copy_files => [:copy_src, :copy_doc, :copy_bin] do + puts "All Copies Complete" + end + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. +The following people either contributed patches, made suggestions or +made otherwise helpful comments. Thanks to ... + +* Doug Young (inspiration for the parallel task) +* David Heinemeier Hansson (for --trace message enhancement and for + pushing for namespace support). +* Ludvig Omholt (for the openAFS fix) + +-- Jim Weirich + +=== 0.6.1 + +* Rebuilt 0.6.0 gem without signing. + +=== 0.6.0 + +Its time for some long requested enhancements and lots of bug fixes +... And a whole new web page. + +==== New Web Page + +The primary documentation for rake has moved from the RubyForge based +wiki to its own Hieraki based web site. Constant spam on the wiki +made it a difficult to keep clean. The new site will be easier to +update and organize. + +Check out the new documentation at: http://docs.rubyrake.org + +We will be adding new documentation to the site as time goes on. + +In addition to the new docs page, make sure you check out Martin +Fowlers article on rake at http://martinfowler.com/articles/rake.html + +==== Changes + +===== New Features + +* Multiple prerequisites on Rake rules now allowed. However, keep the + following in mind: + + 1. All the prerequisites of a rule must be available before a rule + is triggered, where "enabled" means (a) an existing file, (b) a + defined rule, or (c) another rule which also must be + trigger-able. + 2. Rules are checked in order of definition, so it is important to + order your rules properly. If a file can be created by two + different rules, put the more specific rule first (otherwise the + more general rule will trigger first and the specific one will + never be triggered). + 3. The source method now returns the name of the first + prerequisite listed in the rule. sources returns the + names of all the rule prerequisites, ordered as they are defined + in the rule. If the task has other prerequisites not defined in + the rule (but defined in an explicit task definition), then they + will _not_ be included in the sources list. + +* FileLists may now use the egrep command. This popular enhancement + is now a core part of the FileList object. If you want to get a + list of all your to-dos, fixmes and TBD comments, add the following + to your Rakefile. + + desc "Look for TODO and FIXME tags in the code" + task :todo do + FileList['**/*.rb'].egrep /#.*(FIXME|TODO|TBD)/ + end + +* The investigation method was added to task object to dump + out some important values. This makes it a bit easier to debug Rake + tasks. + + For example, if you are having problems with a particular task, just + print it out: + + task :huh do + puts Rake::Task['huh'].investigation + end + +* The Rake::TestTask class now supports a "ruby\_opts" option to pass + arbitrary ruby options to a test subprocess. + +===== Some Incompatibilities + +* When using the ruby command to start a Ruby subprocess, the + Ruby interpreter that is currently running rake is used by default. + This makes it easier to use rake in an environment with multiple + ruby installation. (Previously, the first ruby command found in the + PATH was used). + + If you wish to chose a different Ruby interpreter, you can + explicitly choose the interpreter via the sh command. + +* The major rake classes (Task, FileTask, FileCreationTask, RakeApp) + have been moved out of the toplevel scope and are now accessible as + Rake::Task, Rake::FileTask, Rake::FileCreationTask and + Rake::Application. If your Rakefile + directly references any one of these tasks, you may: + + 1. Update your Rakefile to use the new classnames + 2. Use the --classic-namespace option on the rake command to get the + old behavior, + 3. Add require 'rake/classic_namespace' to the + Rakefile to get the old behavior. + + rake will print a rather annoying warning whenever a + deprecated class name is referenced without enabling classic + namespace. + +===== Bug Fixes + +* Several unit tests and functional tests were fixed to run better + under windows. + +* Directory tasks are now a specialized version of a File task. A + directory task will only be triggered if it doesn't exist. It will + not be triggered if it is out of date w.r.t. any of its + prerequisites. + +* Fixed a bug in the Rake::GemPackageTask class so that the gem now + properly contains the platform name. + +* Fixed a bug where a prerequisite on a file task would cause + an exception if the prerequisite did not exist. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. +The following people either contributed patches, made suggestions or +made otherwise helpful comments. Thanks to ... + +* Greg Fast (better ruby_opt test options) +* Kelly Felkins (requested by better namespace support) +* Martin Fowler (suggested Task.investigation) +* Stuart Jansen (send initial patch for multiple prerequisites). +* Masao Mutch (better support for non-ruby Gem platforms) +* Philipp Neubeck (patch for file task exception fix) + +-- Jim Weirich + +=== 0.5.4 + +Time for some minor bug fixes and small enhancements + +==== Changes + +Here are the changes for version 0.5.4 ... + +* Added double quotes to the test runner. This allows the location of + the tests (and runner) to be in a directory path that contains + spaces (e.g. "C:/Program Files/ruby/bin"). +* Added .svn to default ignore list. Now subversion project metadata + is automatically ignored by Rake's FileList. +* Updated FileList#include to support nested arrays and filelists. + FileLists are flat lists of file names. Using a FileList in an + include will flatten out the nested file names. + +== Thanks + +As usual, it was input from users that drove a alot of these changes. +Thanks to ... + +* Tilman Sauerbeck for the nested FileList suggestion. +* Josh Knowles for pointing out the spaces in directory name problem. + +-- Jim Weirich + +=== 0.5.3 + +Although it has only been two weeks since the last release, we have +enough updates to the Rake program to make it time for another +release. + +==== Changes + +Here are the changes for version 0.5.3 ... + +* FileLists have been extensively changed so that they mimic the + behavior of real arrays even more closely. In particular, + operations on FileLists that return a new collection (e.g. collect, + reject) will now return a FileList rather than an array. In + addition, several places where FileLists were not properly expanded + before use have been fixed. +* A method (+ext+) to simplify the handling of file extensions was + added to String and to Array. +* The 'testrb' script in test/unit tends to silently swallow syntax + errors in test suites. Because of that, the default test loader is + now a rake-provided script. You can still use 'testrb' by setting + the loader flag in the test task to :testrb. (See the API documents + for TestTask for all the loader flag values). +* FileUtil methods (e.g. cp, mv, install) are now declared to be + private. This will cut down on the interference with user defined + methods of the same name. +* Fixed the verbose flag in the TestTask so that the test code is + controlled by the flag. Also shortened up some failure messages. + (Thanks to Tobias Luetke for the suggestion). +* Rules will now properly detect a task that can generate a source + file. Previously rules would only consider source files that were + already present. +* Added an +import+ command that allows Rake to dynamically import + dependendencies into a running Rake session. The +import+ command + can run tasks to update the dependency file before loading them. + Dependency files can be in rake or make format, allowing rake to + work with tools designed to generate dependencies for make. + +==== Thanks + +As usual, it was input from users that drove a alot of these changes. +Thanks to ... + +* Brian Gernhardt for the rules fix (especially for the patience to + explain the problem to me until I got what he was talking about). +* Stefan Lang for pointing out problems in the dark corners of the + FileList implementation. +* Alexey Verkhovsky pointing out the silently swallows syntax errors + in tests. +* Tobias Luetke for beautifying the test task output. +* Sam Roberts for some of the ideas behind dependency loading. + +-- Jim Weirich + + +=== 0.5.0 + +It has been a long time in coming, but we finally have a new version +of Rake available. + +==== Changes + +* Fixed documentation that was lacking the Rake module name (Tilman + Sauerbeck). +* Added tar.gz and tar.bz2 support to package task (Tilman Sauerbeck). +* Recursive rules are now supported (Tilman Sauerbeck). +* Added warning option for the Test Task (requested by Eric Hodel). +* The jamis rdoc template is only used if it exists. +* Added fix for Ruby 1.8.2 test/unit and rails problem. +* Added contributed rake man file (Jani Monoses). +* Added Brian Candler's fix for problems in --trace and --dry-run + mode. + +==== Thanks + +Lots of people provided input to this release. Thanks to Tilman +Sauerbeck for numerous patches, documentation fixes and suggestions. +And for also pushing me to get this release out. Also, thanks to +Brian Candler for the finding and fixing --trace/dry-run fix. That +was an obscure bug. Also to Eric Hodel for some good suggestions. + +-- Jim Weirich + +=== 0.4.15 + +==== Changes + +Version 0.4.15 is a bug fix update for the Ruby 1.8.2 compatibility +changes. This release includes: + +* Fixed a bug that prevented the TESTOPTS flag from working with the + revised for 1.8.2 test task. +* Updated the docs on --trace to indicate that it also enables a full + backtrace on errors. +* Several fixes for new warnings generated. + +==== Mini-Roadmap + +I will continue to issue Rake updates in the 0.4.xx series as new +Ruby-1.8.2 issues become manifest. Once the codebase stabilizes, I +will release a 0.5.0 version incorporating all the changes. If you +are not using Ruby-1.8.2 and wish to avoid version churn, I recommend +staying with a release prior to Rake-0.4.14. + +=== 0.4.14 + +Version 0.4.14 is a compatibility fix to allow Rake's test task to +work under Ruby 1.8.2. A change in the Test::Unit autorun feature +prevented Rake from running any tests. This release fixes the +problem. + +Rake 0.4.14 is the recommended release for anyone using Ruby 1.8.2. + +=== 0.4.13 + +* Fixed the dry-run flag so it is operating again. +* Multiple arguments to sh and ruby commands will not be interpreted + by the shell (patch provided by Jonathan Paisley). + +=== 0.4.12 + +* Added --silent (-s) to suppress the (in directory) rake message. + +=== 0.4.11 + +* Changed the "don't know how to rake" message (finally) +* Changes references to a literal "Rakefile" to reference the global + variable $rakefile (which contains the actual name of the rakefile). + +=== 0.4.10 + +* Added block support to the "sh" command, allowing users to take + special actions on the result of the system call. E.g. + + sh "shell_command" do |ok, res| + puts "Program returned #{res.exitstatus}" if ! ok + end + +=== 0.4.9 + +* Switched to Jamis Buck's RDoc template. +* Removed autorequire from Rake's gem spec. This prevents the Rake + libraries from loading while using rails. + +=== 0.4.8 + +* Added support for .rb versions of Rakefile. +* Removed \\\n's from test task. +* Fixed Ruby 1.9 compatibility issue with FileList. + +=== 0.4.7 + +* Fixed problem in FileList that caused Ruby 1.9 to go into infinite + recursion. Since to_a was removed from Object, it does not need to + added back into the list of methods to rewrite in FileList. (Thanks + to Kent Sibilev for pointing this out). + +=== 0.4.6 +* Removed test version of ln in FileUtils that prevented safe_ln from + using ln. + +=== 0.4.5 +* Upgraded comments in TestTask. +* FileList to_s and inspect now automatically resolve pending changes. +* FileList#exclude properly returns the FileList. + +=== 0.4.4 +* Fixed initialization problem with @comment. +* Now using multi -r technique in TestTask. Switch Rakefile back to + using the built-in test task macros because the rake runtime is no + longer needed. +* Added 'TEST=filename' and 'TESTOPTS=options' to the Test Task + macros. +* Allow a +test_files+ attribute in test tasks. This allows more + flexibility in specifying test files. + +=== 0.4.3 +* Fixed Comment leakage. + +=== 0.4.2 +* Added safe_ln that falls back to a copy if a file link is not supported. +* Package builder now uses safe\_ln. + +=== 0.4.1 +* Task comments are now additive, combined with "/". +* Works with (soon to be released) rubygems 0.6.2 (or 0.7.0) + +=== 0.4.0 +* FileList now uses deferred loading. The file system is not searched + until the first call that needs the file names. +* VAR=VALUE options are now accepted on the command line and are + treated like environment variables. The values may be tested in a + Rakefile by referencing ENV['VAR']. +* File.mtime is now used (instead of File.new().mtime). + +=== 0.3.2.x + +* Removed some hidden dependencies on rubygems. Tests now will test + gems only if they are installed. +* Removed Sys from some example files. I believe that is that last + reference to Sys outside of the contrib area. +* Updated all copyright notices to include 2004. + +=== 0.3.2 + +* GEM Installation now works with the application stub. + +=== 0.3.1 + +* FileLists now automatically ignore CVS, .bak, ! +* GEM Installation now works. + +=== 0.3.0 + +Promoted 0.2.10. + +=== 0.2.10 +General + +* Added title to Rake's rdocs +* Contrib packages are no longer included in the documentation. + +RDoc Issues + +* Removed default for the '--main' option +* Fixed rendering of the rdoc options +* Fixed clean/clobber confusion with rerdoc +* 'title' attribute added + +Package Task Library Issues + +* Version (or explicit :noversion) is required. +* +package_file+ attribute is now writable + +FileList Issues + +* Dropped bang version of exclude. Now using ant-like include/exclude semantics. +* Enabled the "yield self" idiom in FileList#initialize. + +=== 0.2.9 + +This version contains numerous changes as the RubyConf.new(2003) +presentation was being prepared. The changes include: + +* The monolithic rubyapp task library is in the process of being + dropped in favor of lighter weight task libraries. + +=== 0.2.7 + +* Added "desc" for task descriptions. +* -T will now display tasks with descriptions. +* -P will display tasks and prerequisites. +* Dropped the Sys module in favor of the 1.8.x FileUtils module. Sys + is still supported in the contrib area. + +=== 0.2.6 + +* Moved to RubyForge + +=== 0.2.5 + +* Switched to standard ruby app builder. +* Added no_match option to file matcher. + +=== 0.2.4 + +* Fixed indir, which neglected to actually change directories. + +=== 0.2.3 + +* Added rake module for a help target +* Added 'for\_files' to Sys +* Added a $rakefile constant +* Added test for selecting proper rule with multiple targets. diff --git a/MIT-LICENSE b/MIT-LICENSE index 727347539..4292f3b3c 100644 --- a/MIT-LICENSE +++ b/MIT-LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2003, 2004 Jim Weirich +Copyright (c) Jim Weirich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.rdoc b/README.rdoc index 3941f7950..5f0278d8e 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,7 +1,13 @@ = RAKE -- Ruby Make -This package contains Rake, a simple ruby build program with capabilities -similar to make. +home :: https://github.com/ruby/rake +bugs :: https://github.com/ruby/rake/issues +docs :: https://ruby.github.io/rake + +== Description + +Rake is a Make-like program implemented in Ruby. Tasks and dependencies are +specified in standard Ruby syntax. Rake has the following features: @@ -17,9 +23,9 @@ Rake has the following features: file names and paths. * A library of prepackaged tasks to make building rakefiles easier. For example, - tasks for building tarballs and publishing to FTP or SSH sites. (Formerly - tasks for building RDoc and Gems were included in rake but they're now - available in RDoc and RubyGems respectively.) + tasks for building tarballs. (Formerly + tasks for building RDoc, Gems, and publishing to FTP were included in rake but they're now + available in RDoc, RubyGems, and rake-contrib respectively.) * Supports parallel execution of tasks. @@ -29,7 +35,7 @@ Rake has the following features: Download and install rake with the following. - gem install rake + gem install rake == Usage @@ -38,7 +44,7 @@ Download and install rake with the following. First, you must write a "Rakefile" file which contains the build rules. Here's a simple example: - task :default => [:test] + task default: %w[test] task :test do ruby "test/unittest.rb" @@ -46,8 +52,8 @@ a simple example: This Rakefile has two tasks: -* A task named "test", which - upon invocation - will run a unit test file in - Ruby. +* A task named "test", which -- upon invocation -- will run a unit test file + in Ruby. * A task named "default". This task does nothing by itself, but it has exactly one dependency, namely the "test" task. Invoking the "default" task will cause Rake to invoke the "test" task as well. @@ -64,124 +70,86 @@ Running the "rake" command without any options will cause it to run the Type "rake --help" for all available options. +== Resources -=== More Information - -* For details on Rake's command-line invocation, read - doc/command_line_usage.rdoc[https://github.com/jimweirich/rake/blob/master/doc/command_line_usage.rdoc] -* For details on writing Rakefiles, see - doc/rakefile.rdoc[https://github.com/jimweirich/rake/blob/master/doc/rakefile.rdoc]. -* For the original announcement of Rake, see - doc/rational.rdoc[https://github.com/jimweirich/rake/blob/master/doc/rational.rdoc]. -* For a glossary of terms, see - doc/glossary.rdoc[https://github.com/jimweirich/rake/blob/master/doc/glossary.rdoc]. - -== Development - -=== Source Repository - -Rake is currently hosted at github. The github web page is -http://github.com/jimweirich/rake. The public git clone URL is - -* git://github.com/jimweirich/rake.git - -=== Running the Rake Test Suite - -If you wish to run the unit and functional tests that come with Rake: - -* Install the 'flexmock' gem -* Install the 'session' gem in order to run the functional tests. -* CD into the top project directory of rake. -* Type one of the following: - - rake # If you have a version of rake installed - ruby -Ilib bin/rake # If you do not have a version of rake installed. - -=== Issues and Bug Reports - -Feature requests and bug reports can be made here - -* https://github.com/jimweirich/rake/issues - -Issues and bug reports can also be tracked here: +=== Rake Information -* http://www.pivotaltracker.com/projects/28469 - -== Online Resources - -=== Rake References - -* Rake Documentation Home: http://docs.rubyrake.org -* Rake Project Page: http://github.com/jimweirich/rake -* Rake API Documents: http://onestepback.org/software/rake/ -* Rake Source Code Repo: http://github.com/jimweirich/rake -* Rake Git Repo Clone URL: git://github.com/jimweirich/rake.git -* Rake Bug Reports: https://github.com/jimweirich/rake/issues -* Rake Continuous Build Server: https://travis-ci.org/#!/jimweirich/rake +* {Rake command-line}[link:doc/command_line_usage.rdoc] +* {Writing Rakefiles}[link:doc/rakefile.rdoc] +* The original {Rake announcement}[link:doc/rational.rdoc] +* Rake {glossary}[link:doc/glossary.rdoc] === Presentations and Articles about Rake -* Jim Weirich's 2003 RubyConf presentation: - http://onestepback.org/articles/buildingwithrake/ +* Avdi Grimm's rake series: + 1. {Rake Basics}[http://devblog.avdi.org/2014/04/21/rake-part-1-basics/] + 2. {Rake File Lists}[http://devblog.avdi.org/2014/04/22/rake-part-2-file-lists/] + 3. {Rake Rules}[http://devblog.avdi.org/2014/04/23/rake-part-3-rules/] + 4. {Rake Pathmap}[http://devblog.avdi.org/2014/04/24/rake-part-4-pathmap/] + 5. {File Operations}[http://devblog.avdi.org/2014/04/25/rake-part-5-file-operations/] + 6. {Clean and Clobber}[http://devblog.avdi.org/2014/04/28/rake-part-6-clean-and-clobber/] + 7. {MultiTask}[http://devblog.avdi.org/2014/04/29/rake-part-7-multitask/] +* {Jim Weirich's 2003 RubyConf presentation}[http://web.archive.org/web/20140221123354/http://onestepback.org/articles/buildingwithrake/] * Martin Fowler's article on Rake: http://martinfowler.com/articles/rake.html -== Other Make Reinvisionings ... +== Other Make Re-envisionings ... Rake is a late entry in the make replacement field. Here are links to other projects with similar (and not so similar) goals. -* http://directory.fsf.org/bras.html -- Bras, one of earliest +* http://directory.fsf.org/wiki/Bras -- Bras, one of earliest implementations of "make in a scripting language". * http://www.a-a-p.org -- Make in Python -* http://www.aromatic.com/tools/jam.txt -- JAM, Java Automated Make * http://ant.apache.org -- The Ant project -* http://ppt.perl.org/commands/make/index.html -- Make from the Perl - Power Tools implementation. * http://search.cpan.org/search?query=PerlBuildSystem -- The Perl Build System -* http://rubydoc.info/gems/rant/0.5.7/frames -- Rant, another Ruby make tool. +* http://www.rubydoc.info/gems/rant/0.5.7/frames -- Rant, another Ruby make tool. == Credits +[Jim Weirich] Who originally created Rake. + [Ryan Dlugosz] For the initial conversation that sparked Rake. -[nobu.nokada@softhome.net] For the initial patch for rule support. +[Nobuyoshi Nakada ] For the initial patch for rule support. [Tilman Sauerbeck ] For the recursive rule patch. [Eric Hodel] For aid in maintaining rake. +[Hiroshi SHIBATA] Maintainer of Rake 10.X and Rake 11.X + == License Rake is available under an MIT-style license. :include: MIT-LICENSE -== Support - -The Rake homepage is http://onestepback.org/software/rake/. You can find the Rake -GitHub page at http://github.com/jimweirich/rake. - -Feel free to submit commits or feature requests. If you send a patch, -remember to update the corresponding unit tests. In fact, I prefer -new feature to be submitted in the form of new unit tests. - -For other information, feel free to ask on the ruby-talk mailing list -(which is mirrored to comp.lang.ruby) or contact -jim dot weirich at gmail.com. - --- = Other stuff Author:: Jim Weirich -Requires:: Ruby 1.8.7 or later -License:: Copyright 2003-2013 by Jim Weirich. +Requires:: Ruby 2.0.0 or later +License:: Copyright Jim Weirich. Released under an MIT-style license. See the MIT-LICENSE file included in the distribution. == Warranty -This software is provided "as is" and without any express or -implied warranties, including, without limitation, the implied -warranties of merchantibility and fitness for a particular -purpose. +This software is provided "as is" and without any express or implied +warranties, including, without limitation, the implied warranties of +merchantability and fitness for a particular purpose. + +== Historical + +Rake was originally created by Jim Weirich, who unfortunately passed away in +February 2014. This repository was originally hosted at +{github.com/jimweirich/rake}[https://github.com/jimweirich/rake/], however +with his passing, has been moved to {ruby/rake}[https://github.com/ruby/rake]. + +You can view Jim's last commit here: +https://github.com/jimweirich/rake/tree/336559f28f55bce418e2ebcc0a57548dcbac4025 + +You can {read more about Jim}[https://en.wikipedia.org/wiki/Jim_Weirich] at Wikipedia. + +Thank you for this great tool, Jim. We'll remember you. diff --git a/Rakefile b/Rakefile index 608c62446..e03dc6feb 100644 --- a/Rakefile +++ b/Rakefile @@ -6,369 +6,36 @@ # This file may be distributed under an MIT style license. See # MIT-LICENSE for details. -require 'rbconfig' -require 'rubygems' - -system_rake = File.join RbConfig::CONFIG['rubylibdir'], 'rake.rb' - -# Use our rake, not the installed rake from system -if $".include? system_rake or $".grep(/rake\/name_space\.rb$/).empty? then - exec Gem.ruby, '-Ilib', 'bin/rake', *ARGV -end - -require 'rubygems/package_task' - -require 'rake/clean' -require 'rake/testtask' - -begin - gem 'rdoc' - require 'rdoc/task' -rescue Gem::LoadError -end - -CLEAN.include('**/*.o', '*.dot', '**/*.rbc') -CLOBBER.include('doc/example/main') -CLOBBER.include('TAGS') -CLOBBER.include('coverage', 'rcov_aggregate') - -# Prevent OS X from including extended attribute junk in the tar output -ENV['COPY_EXTENDED_ATTRIBUTES_DISABLE'] = 'true' - -def announce(msg='') - STDERR.puts msg -end - -# Determine the current version of the software - -if `ruby -Ilib ./bin/rake --version` =~ /rake, version ([0-9a-z.]+)$/ - CURRENT_VERSION = $1 -else - CURRENT_VERSION = "0.0.0" -end - -$package_version = CURRENT_VERSION - -SRC_RB = FileList['lib/**/*.rb'] - -# The default task is run if rake is given no explicit arguments. - -desc "Default Task" -task :default => :test - -# Test Tasks --------------------------------------------------------- - -Rake::TestTask.new do |t| - files = FileList['test/helper.rb', 'test/test_*.rb'] - t.loader = :rake - t.test_files = files - t.libs << "." - t.warning = true -end +lib = File.expand_path("../lib", __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) begin - require 'rcov/rcovtask' - IGNORE_COVERAGE_IN = FileList[ - 'lib/rake/rdoctask.rb', - 'lib/rake/testtask.rb', - 'lib/rake/packagetask.rb', - 'lib/rake/clean.rb', - ] - - unless File::ALT_SEPARATOR - IGNORE_COVERAGE_IN.include( - 'lib/rake/alt_system.rb', - 'lib/rake/win32.rb') - end - - Rcov::RcovTask.new do |t| - t.libs << "test" - t.rcov_opts = [ - '-xRakefile', '-xrakefile', '-xpublish.rf', - '-xlib/rake/contrib', '-x/Library', '-x.rvm', - '--text-report', - '--sort coverage' - ] + FileList['rakelib/*.rake'].pathmap("-x%p") + - IGNORE_COVERAGE_IN.map { |fn| "-x#{fn}" } - t.test_files = FileList[ - 'test/lib/*_test.rb', - 'test/contrib/*_test.rb', - 'test/functional/*_test.rb' - ] - t.output_dir = 'coverage' - t.verbose = true - end + require "bundler/gem_tasks" rescue LoadError - task :rcov do - puts "RCov is not available" - end end -# CVS Tasks ---------------------------------------------------------- - -# Install rake using the standard install.rb script. - -desc "Install the application" -task :install do - ruby "install.rb" +require "rake/testtask" +Rake::TestTask.new(:test) do |t| + t.libs << "test" + t.verbose = true + t.test_files = FileList["test/**/test_*.rb"] end -# Create a task to build the RDOC documentation tree. - -BASE_RDOC_OPTIONS = [ - '--line-numbers', '--show-hash', - '--main', 'README.rdoc', - '--title', 'Rake -- Ruby Make' -] - -if defined?(RDoc::Task) then - RDoc::Task.new do |rdoc| - rdoc.rdoc_dir = 'html' - rdoc.title = "Rake -- Ruby Make" - rdoc.options = BASE_RDOC_OPTIONS.dup - - rdoc.rdoc_files.include('README.rdoc', 'MIT-LICENSE', 'TODO', 'CHANGES') - rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc') - rdoc.rdoc_files.exclude(/\bcontrib\b/) - end -else - warn "RDoc 2.4.2+ is required to build documentation" +require "rdoc/task" +RDoc::Task.new do |doc| + doc.main = "README.rdoc" + doc.title = "Rake -- Ruby Make" + doc.rdoc_files = FileList.new %w[lib MIT-LICENSE doc/**/*.rdoc *.rdoc] + doc.rdoc_dir = "html" end -# ==================================================================== -# Create a task that will package the Rake software into distributable -# tar, zip and gem files. - -PKG_FILES = FileList[ - '.gemtest', - 'install.rb', - 'CHANGES', - 'MIT-LICENSE', - 'README.rdoc', - 'Rakefile', - 'TODO', - 'bin/rake', - 'lib/**/*.rb', - 'test/**/*.rb', - 'doc/**/*' -] -PKG_FILES.exclude('doc/example/*.o') -PKG_FILES.exclude('TAGS') -PKG_FILES.exclude(%r{doc/example/main$}) - -if ! defined?(Gem) - puts "Package Target requires RubyGems" -else - SPEC = Gem::Specification.new do |s| - s.name = 'rake' - s.version = $package_version - s.summary = "Ruby based make-like utility." - s.license = "MIT" - s.description = <<-EOF.delete "\n" -Rake is a Make-like program implemented in Ruby. Tasks and dependencies are -specified in standard Ruby syntax. - EOF - - s.required_ruby_version = '>= 1.8.6' - s.required_rubygems_version = '>= 1.3.2' - s.add_development_dependency 'minitest', '~> 2.1' - - s.files = PKG_FILES.to_a - - s.executables = ["rake"] - - s.extra_rdoc_files = FileList[ - 'README.rdoc', - 'MIT-LICENSE', - 'TODO', - 'CHANGES', - 'doc/**/*.rdoc' - ] - - s.rdoc_options = BASE_RDOC_OPTIONS - - s.author = "Jim Weirich" - s.email = "jim.weirich@gmail.com" - s.homepage = "http://github.com/jimweirich/rake" - end - - Gem::PackageTask.new(SPEC) do |pkg| - pkg.need_zip = true - pkg.need_tar = true - end - - file "rake.gemspec" => ["Rakefile", "lib/rake.rb"] do |t| - require 'yaml' - open(t.name, "w") { |f| f.puts SPEC.to_yaml } - end - - desc "Create a stand-alone gemspec" - task :gemspec => "rake.gemspec" -end - -# Misc tasks ========================================================= - -def count_lines(filename) - lines = 0 - codelines = 0 - open(filename) { |f| - f.each do |line| - lines += 1 - next if line =~ /^\s*$/ - next if line =~ /^\s*#/ - codelines += 1 - end - } - [lines, codelines] +task ghpages: :rdoc do + %x[git checkout gh-pages] + require "fileutils" + FileUtils.rm_rf "/tmp/html" + FileUtils.mv "html", "/tmp" + FileUtils.rm_rf "*" + FileUtils.cp_r Dir.glob("/tmp/html/*"), "." end -def show_line(msg, lines, loc) - printf "%6s %6s %s\n", lines.to_s, loc.to_s, msg -end - -desc "Count lines in the main rake file" -task :lines do - total_lines = 0 - total_code = 0 - show_line("File Name", "LINES", "LOC") - SRC_RB.each do |fn| - lines, codelines = count_lines(fn) - show_line(fn, lines, codelines) - total_lines += lines - total_code += codelines - end - show_line("TOTAL", total_lines, total_code) -end - -# Define an optional publish target in an external file. If the -# publish.rf file is not found, the publish targets won't be defined. - -load "publish.rf" if File.exist? "publish.rf" - -# Support Tasks ------------------------------------------------------ - -RUBY_FILES = FileList['**/*.rb'].exclude('pkg') - -desc "Look for TODO and FIXME tags in the code" -task :todo do - RUBY_FILES.egrep(/#.*(FIXME|TODO|TBD)/) -end - -desc "List all ruby files" -task :rubyfiles do - puts RUBY_FILES - puts FileList['bin/*'].exclude('bin/*.rb') -end -task :rf => :rubyfiles - -# -------------------------------------------------------------------- -# Creating a release - -def plugin(plugin_name) - require "rake/plugins/#{plugin_name}" -end - -task :noop -#plugin "release_manager" - -desc "Make a new release" -task :release, [:rel, :reuse, :reltest] => [ - :prerelease, - :clobber, - :test, - :update_version, - :package, - :tag - ] do - announce - announce "**************************************************************" - announce "* Release #{$package_version} Complete." - announce "* Packages ready to upload." - announce "**************************************************************" - announce -end - -# Validate that everything is ready to go for a release. -task :prerelease, :rel, :reuse, :reltest do |t, args| - $package_version = args.rel - announce - announce "**************************************************************" - announce "* Making RubyGem Release #{$package_version}" - announce "* (current version #{CURRENT_VERSION})" - announce "**************************************************************" - announce - - # Is a release number supplied? - unless args.rel - fail "Usage: rake release[X.Y.Z] [REUSE=tag_suffix]" - end - - # Is the release different than the current release. - # (or is REUSE set?) - if $package_version == CURRENT_VERSION && ! args.reuse - fail "Current version is #{$package_version}, must specify REUSE=tag_suffix to reuse version" - end - - # Are all source files checked in? - if args.reltest - announce "Release Task Testing, skipping checked-in file test" - else - announce "Checking for unchecked-in files..." - data = `svn st` - unless data =~ /^$/ - abort "svn status is not clean ... do you have unchecked-in files?" - end - announce "No outstanding checkins found ... OK" - end -end - -task :update_version, [:rel, :reuse, :reltest] => [:prerelease] do |t, args| - if args.rel == CURRENT_VERSION - announce "No version change ... skipping version update" - else - announce "Updating Rake version to #{args.rel}" - open("lib/rake.rb") do |rakein| - open("lib/rake.rb.new", "w") do |rakeout| - rakein.each do |line| - if line =~ /^RAKEVERSION\s*=\s*/ - rakeout.puts "RAKEVERSION = '#{args.rel}'" - else - rakeout.puts line - end - end - end - end - mv "lib/rake.rb.new", "lib/rake.rb" - if args.reltest - announce "Release Task Testing, skipping commiting of new version" - else - sh %{svn commit -m "Updated to version #{args.rel}" lib/rake.rb} # " - end - end -end - -desc "Tag all the CVS files with the latest release number (REL=x.y.z)" -task :tag, [:rel, :reuse, :reltest] => [:prerelease] do |t, args| - reltag = "REL_#{args.rel.gsub(/\./, '_')}" - reltag << args.reuse.gsub(/\./, '_') if args.reuse - announce "Tagging Repository with [#{reltag}]" - if args.reltest - announce "Release Task Testing, skipping CVS tagging" - else - sh %{svn copy svn+ssh://rubyforge.org/var/svn/rake/trunk svn+ssh://rubyforge.org/var/svn/rake/tags/#{reltag} -m 'Commiting release #{reltag}'} ###' - end -end - -# Require experimental XForge/Metaproject support. - -load 'xforge.rf' if File.exist?('xforge.rf') - -desc "Where is the current directory. This task displays the current rake directory" -task :where_am_i do - puts Rake.original_dir -end - -task :failure => :really_fail -task :really_fail do - fail "oops" -end +task default: :test diff --git a/TODO b/TODO deleted file mode 100644 index 6893b9fe2..000000000 --- a/TODO +++ /dev/null @@ -1,21 +0,0 @@ -= Rake Project -- To Do List - -Send suggestions for this list to mailto:jim@weirichhouse.org or on -the rake-devel@rubyforge.org mailing list. - -=== To Do -* Need a nice API for accessing tasks in namespaces, namespaces in an app, etc. -* Provide a way to disable -w warning mode. -* Define a set of default rules that work in the absence of any Rakefile -* What about cyclic dependencies? -* Java support utilities -* Installation support utilities - * Check out installpkg.rb -* Autogenerate Dependencies -* Rules should apply to existing tasks if no actions are defined. -* How to create multiple package tasks without task name collision? -* Trap "ln -s" commands that fail and use "cp" instead (SMB mounted - drives have problems with "ln -s". - - -(moved DONE list to CHANGES file) diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 000000000..524dfd3f2 --- /dev/null +++ b/bin/bundle @@ -0,0 +1,105 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'bundle' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "rubygems" + +m = Module.new do + module_function + + def invoked_as_script? + File.expand_path($0) == File.expand_path(__FILE__) + end + + def env_var_version + ENV["BUNDLER_VERSION"] + end + + def cli_arg_version + return unless invoked_as_script? # don't want to hijack other binstubs + return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` + bundler_version = nil + update_index = nil + ARGV.each_with_index do |a, i| + if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN + bundler_version = a + end + next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ + bundler_version = $1 || ">= 0.a" + update_index = i + end + bundler_version + end + + def gemfile + gemfile = ENV["BUNDLE_GEMFILE"] + return gemfile if gemfile && !gemfile.empty? + + File.expand_path("../../Gemfile", __FILE__) + end + + def lockfile + lockfile = + case File.basename(gemfile) + when "gems.rb" then gemfile.sub(/\.rb$/, gemfile) + else "#{gemfile}.lock" + end + File.expand_path(lockfile) + end + + def lockfile_version + return unless File.file?(lockfile) + lockfile_contents = File.read(lockfile) + return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ + Regexp.last_match(1) + end + + def bundler_version + @bundler_version ||= begin + env_var_version || cli_arg_version || + lockfile_version || "#{Gem::Requirement.default}.a" + end + end + + def load_bundler! + ENV["BUNDLE_GEMFILE"] ||= gemfile + + # must dup string for RG < 1.8 compatibility + activate_bundler(bundler_version.dup) + end + + def activate_bundler(bundler_version) + if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0") + bundler_version = "< 2" + end + gem_error = activation_error_handling do + gem "bundler", bundler_version + end + return if gem_error.nil? + require_error = activation_error_handling do + require "bundler/version" + end + return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`" + exit 42 + end + + def activation_error_handling + yield + nil + rescue StandardError, LoadError => e + e + end +end + +m.load_bundler! + +if m.invoked_as_script? + load Gem.bin_path("bundler", "bundle") +end diff --git a/bin/console b/bin/console new file mode 100755 index 000000000..b8342352c --- /dev/null +++ b/bin/console @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby + +require "bundler/setup" +require "rake" + +require "irb" +IRB.start diff --git a/bin/rake b/bin/rake index 4e0bbb7b7..9275675e8 100755 --- a/bin/rake +++ b/bin/rake @@ -1,33 +1,29 @@ #!/usr/bin/env ruby +# frozen_string_literal: true -#-- -# Copyright (c) 2003, 2004, 2005, 2006, 2007 Jim Weirich # -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: +# This file was generated by Bundler. # -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. +# The application 'rake' is installed as part of a gem, and +# this file is here to facilitate running it. # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -#++ -begin - require 'rubygems' - gem 'rake' -rescue LoadError +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end end -require 'rake' +require "rubygems" +require "bundler/setup" -Rake.application.run +load Gem.bin_path("rake", "rake") diff --git a/bin/rdoc b/bin/rdoc new file mode 100755 index 000000000..a952e7988 --- /dev/null +++ b/bin/rdoc @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rdoc' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rdoc", "rdoc") diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 000000000..d0c488293 --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rubocop' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rubocop", "rubocop") diff --git a/bin/setup b/bin/setup new file mode 100755 index 000000000..cf4ad25e1 --- /dev/null +++ b/bin/setup @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' +set -vx + +bundle install diff --git a/doc/command_line_usage.rdoc b/doc/command_line_usage.rdoc index 57d51e8d0..105d6c8e9 100644 --- a/doc/command_line_usage.rdoc +++ b/doc/command_line_usage.rdoc @@ -20,7 +20,7 @@ Options are: tracing details). The _output_ parameter is optional, but if specified it controls where the backtrace output is sent. If _output_ is stdout, then backtrace output is directed to - stardard output. If _output_ is stderr, or if it is + standard output. If _output_ is stderr, or if it is missing, then the backtrace output is sent to standard error. [--comments] @@ -48,22 +48,28 @@ Options are: Display some help text and exit. [--jobs _number_ (-j)] - Specifies the number of active concurrent tasks used. The - suggested value is equal to the number of CPUs. The concurrent - tasks are used to execute the multitask prerequisites. - Also see the -m option which turns all tasks into - multitasks. + + Specifies the maximum number of concurrent threads allowed. Rake + will allocate threads as needed up to this maximum number. + + If omitted, Rake will attempt to estimate the number of CPUs on + the system and add 4 to that number. + + The concurrent threads are used to execute the multitask + prerequisites. Also see the -m option which turns all + tasks into multitasks. Sample values: - (no -j) : unlimited concurrent tasks (standard rake behavior) - -j : 2 concurrent tasks (exact number may change) - -j 16 : 16 concurrent tasks + (no -j) : Allow up to (# of CPUs + 4) number of threads + --jobs : Allow unlimited number of threads + --jobs=1 : Allow only one thread (the main thread) + --jobs=16 : Allow up to 16 concurrent threads [--job-stats _level_] Display job statistics at the completion of the run. By default, - this will display the requested number of active tasks (from the - -j options) and the maximum number of tasks in play at any given + this will display the requested number of active threads (from the + -j options) and the maximum number of threads in play at any given time. If the optional _level_ is history, then a complete trace @@ -129,7 +135,7 @@ Options are: Turn on invoke/execute tracing. Also enable full backtrace on errors. The _output_ parameter is optional, but if specified it controls where the trace output is sent. If _output_ is - stdout, then trace output is directed to stardard output. + stdout, then trace output is directed to standard output. If _output_ is stderr, or if it is missing, then trace output is sent to standard error. diff --git a/doc/example/.cvsignore b/doc/example/.cvsignore deleted file mode 100644 index f0c9b8122..000000000 --- a/doc/example/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -*.o -main diff --git a/doc/glossary.rdoc b/doc/glossary.rdoc index a81176409..9d592b02c 100644 --- a/doc/glossary.rdoc +++ b/doc/glossary.rdoc @@ -1,51 +1,42 @@ = Glossary -[action] - Code to be executed in order to perform a task. Actions in a - rakefile are specified in a code block (usually delimited by - +do+/+end+ pairs. - -[execute] - When a task is executed, all of its actions are performed, in - the order they were defined. Note that unlike - invoke, execute always executes the actions - (without invoking or executing the prerequisites). - -[file task (FileTask)] - A file task is a task whose purpose is to create a file - (which has the same name as the task). When invoked, a file - task will only execute if one or more of the following - conditions are true. - - 1. The associated file does not exist. - 2. A prerequisite has a later time stamp than the existing file. - - Because normal Tasks always have the current time as - timestamp, a FileTask that has a normal Task prerequisite - will always execute. - -[invoke] - When a task is invoked, first we check to see if it has been - invoked before. if it has been, then nothing else is done. - If this is the first time its been invoked, then we invoke - each of its prerequisites. Finally, we check to see if we - need to execute the actions of this task by calling - needed?. Finally, if the task is needed, we execute - its actions. - - NOTE: Currently prerequisites are invoked even if the task is - not needed. This may change in the future. - -[prerequisites] - Every task has a set (possibly empty) of prerequisites. A - prerequisite P to Task T is itself a task that must be invoked - before Task T. - -[rule] - A rule is a recipe for synthesizing a task when no task is - explicitly defined. Rules generally synthesize file tasks. - -[task (Task)] - Basic unit of work in a rakefile. A task has a name, a set of - prerequisites and a list of actions to be performed. - +action :: + Code to be executed in order to perform a task. Actions in a Rakefile are + specified in a code block. (Usually delimited by +do+/+end+ pairs.) + +execute :: + When a task is executed, all of its actions are performed in the order they + were defined. Note that, unlike invoke, execute always + executes the actions (without invoking or executing the prerequisites). + +file task (Rake::FileTask) :: + A file task is a task whose purpose is to create a file (which has the same + name as the task). When invoked, a file task will only execute if one or + more of the following conditions are true. + + 1. The associated file does not exist. + 2. A prerequisite has a later time stamp than the existing file. + + Because normal Tasks always have the current time as timestamp, a FileTask + that has a normal Task prerequisite will always execute. + +invoke :: + When a task is invoked, first we check to see if it has been invoked before. + If it has been, then nothing else is done. If this is the first time it has + been invoked, then we invoke each of its prerequisites. Finally, we check + to see if we need to execute the actions of this task by calling + Rake::Task#needed?. If the task is needed, we execute its actions. + + NOTE: Prerequisites are still invoked even if the task is not needed. + +prerequisites :: + Every task has a (possibly empty) set of prerequisites. A prerequisite P to + Task T is itself a task that must be invoked before Task T. + +rule :: + A rule is a recipe for synthesizing a task when no task is explicitly + defined. Rules generally synthesize file tasks. + +task (Rake::Task) :: + The basic unit of work in a Rakefile. A task has a name, a set of + prerequisites, and a list of actions to be performed. diff --git a/doc/jamis.rb b/doc/jamis.rb index c7bc84ac5..531aa7573 100644 --- a/doc/jamis.rb +++ b/doc/jamis.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module RDoc module Page diff --git a/doc/rake.1 b/doc/rake.1 new file mode 100644 index 000000000..c6bfa25c0 --- /dev/null +++ b/doc/rake.1 @@ -0,0 +1,156 @@ +.Dd June 12, 2016 +.Dt RAKE 1 +.Os rake 11.2.2 +.Sh NAME +.Nm rake +.Nd make-like build utility for Ruby +.Sh SYNOPSIS +.Nm +.Op Fl f Ar rakefile +.Op Ar options +.Ar targets ... +.Sh DESCRIPTION +.Nm +is a +.Xr make 1 Ns -like +build utility for Ruby. +Tasks and dependencies are specified in standard Ruby syntax. +.Sh OPTIONS +.Bl -tag -width Ds +.It Fl m , Fl -multitask +Treat all tasks as multitasks. +.It Fl B , Fl -build-all +Build all prerequisites, including those which are up\-to\-date. +.It Fl j , Fl -jobs Ar num_jobs +Specifies the maximum number of tasks to execute in parallel (default is number of CPU cores + 4). +.El +.Ss Modules +.Bl -tag -width Ds +.It Fl I , Fl -libdir Ar libdir +Include +.Ar libdir +in the search path for required modules. +.It Fl r , Fl -require Ar module +Require +.Ar module +before executing +.Pa rakefile . +.El +.Ss Rakefile location +.Bl -tag -width Ds +.It Fl f , Fl -rakefile Ar filename +Use +.Ar filename +as the rakefile to search for. +.It Fl N , Fl -no-search , Fl -nosearch +Do not search parent directories for the Rakefile. +.It Fl G , Fl -no-system , Fl -nosystem +Use standard project Rakefile search paths, ignore system wide rakefiles. +.It Fl R , Fl -rakelib Ar rakelibdir , Fl -rakelibdir Ar rakelibdir +Auto-import any .rake files in +.Ar rakelibdir +(default is +.Sq rakelib ) +.It Fl g , Fl -system +Use system-wide (global) rakefiles (usually +.Pa ~/.rake/*.rake ) . +.El +.Ss Debugging +.Bl -tag -width Ds +.It Fl -backtrace Ns = Ns Ar out +Enable full backtrace. +.Ar out +can be +.Dv stderr +(default) or +.Dv stdout . +.It Fl t , Fl -trace Ns = Ns Ar out +Turn on invoke/execute tracing, enable full backtrace. +.Ar out +can be +.Dv stderr +(default) or +.Dv stdout . +.It Fl -suppress-backtrace Ar pattern +Suppress backtrace lines matching regexp +.Ar pattern . +Ignored if +.Fl -trace +is on. +.It Fl -rules +Trace the rules resolution. +.It Fl n , Fl -dry-run +Do a dry run without executing actions. +.It Fl T , Fl -tasks Op Ar pattern +Display the tasks (matching optional +.Ar pattern ) +with descriptions, then exit. +.It Fl D , Fl -describe Op Ar pattern +Describe the tasks (matching optional +.Ar pattern ) , +then exit. +.It Fl W , Fl -where Op Ar pattern +Describe the tasks (matching optional +.Ar pattern ) , +then exit. +.It Fl P , Fl -prereqs +Display the tasks and dependencies, then exit. +.It Fl e , Fl -execute Ar code +Execute some Ruby code and exit. +.It Fl p , Fl -execute-print Ar code +Execute some Ruby code, print the result, then exit. +.It Fl E , Fl -execute-continue Ar code +Execute some Ruby code, then continue with normal task processing. +.El +.Ss Information +.Bl -tag -width Ds +.It Fl v , Fl -verbose +Log message to standard output. +.It Fl q , Fl -quiet +Do not log messages to standard output. +.It Fl s , Fl -silent +Like +.Fl -quiet , +but also suppresses the +.Sq in directory +announcement. +.It Fl X , Fl -no-deprecation-warnings +Disable the deprecation warnings. +.It Fl -comments +Show commented tasks only +.It Fl A , Fl -all +Show all tasks, even uncommented ones (in combination with +.Fl T +or +.Fl D ) +.It Fl -job-stats Op Ar level +Display job statistics. +If +.Ar level +is +.Sq history , +displays a complete job list. +.It Fl V , Fl -version +Display the program version. +.It Fl h , Fl H , Fl -help +Display a help message. +.El +.Sh SEE ALSO +The complete documentation for +.Nm rake +has been installed at +.Pa /usr/share/doc/rake-doc/html/index.html . +It is also available online at +.Lk https://ruby.github.io/rake . +.Sh AUTHORS +.An -nosplit +.Nm +was written by +.An Jim Weirich Aq Mt jim@weirichhouse.org . +.Pp +This manual was created by +.An Caitlin Matos Aq Mt caitlin.matos@zoho.com +for the Debian project (but may be used by others). +It was inspired by the manual by +.An Jani Monoses Aq Mt jani@iv.ro +for the Ubuntu project. diff --git a/doc/rake.1.gz b/doc/rake.1.gz deleted file mode 100644 index 8cf443b34..000000000 Binary files a/doc/rake.1.gz and /dev/null differ diff --git a/doc/rakefile.rdoc b/doc/rakefile.rdoc index 688535b6e..4014306a1 100644 --- a/doc/rakefile.rdoc +++ b/doc/rakefile.rdoc @@ -1,4 +1,4 @@ -= Rakefile Format (as of version 0.8.7) += Rakefile Format First of all, there is no special format for a Rakefile. A Rakefile contains executable Ruby code. Anything legal in a ruby script is @@ -30,9 +30,9 @@ parameter that is the name of the task. Any prerequisites are given as a list (enclosed in square brackets) following the name and an arrow (=>). - task :name => [:prereq1, :prereq2] + task name: [:prereq1, :prereq2] -NOTE: Although this syntax looks a little funky, it is legal +*NOTE:* Although this syntax looks a little funky, it is legal Ruby. We are constructing a hash where the key is :name and the value for that key is the list of prerequisites. It is equivalent to the following ... @@ -41,13 +41,27 @@ following ... hash[:name] = [:prereq1, :prereq2] task(hash) +You can also use strings for task names and prerequisites, rake doesn't care. +This is the same task definition: + + task 'name' => %w[prereq1 prereq2] + +As is this: + + task name: %w[prereq1 prereq2] + +We'll prefer this style for regular tasks with prerequisites throughout the +rest of the document. Using an array of strings for the prerequisites means +you will need to make fewer changes if you need to move tasks into namespaces +or perform other refactorings. + === Tasks with Actions Actions are defined by passing a block to the +task+ method. Any Ruby code can be placed in the block. The block may reference the task object via the block parameter. - task :name => [:prereq1, :prereq2] do |t| + task name: [:prereq1, :prereq2] do |t| # actions (may reference t) end @@ -62,8 +76,8 @@ For example, the following is equivalent to the single task specification given above. task :name - task :name => [:prereq1] - task :name => [:prereq2] + task name: :prereq1 + task name: %w[prereq2] task :name do |t| # actions end @@ -79,8 +93,8 @@ method). In addition, file tasks are usually named with a string rather than a symbol. The following file task creates a executable program (named +prog+) -given two object files named a.o and b.o. The tasks -for creating a.o and b.o are not shown. +given two object files named +a.o+ and +b.o+. The tasks +for creating +a.o+ and +b.o+ are not shown. file "prog" => ["a.o", "b.o"] do |t| sh "cc -o #{t.name} #{t.prerequisites.join(' ')}" @@ -97,9 +111,9 @@ that creates the directory. For example, the following declaration is equivalent to ... - file "testdata" do |t| mkdir t.name end - file "testdata/examples" do |t| mkdir t.name end - file "testdata/examples/doc" do |t| mkdir t.name end + file "testdata" do |t| mkdir t.name end + file "testdata/examples" => ["testdata"] do |t| mkdir t.name end + file "testdata/examples/doc" => ["testdata/examples"] do |t| mkdir t.name end The +directory+ method does not accept prerequisites or actions, but both prerequisites and actions can be added later. For example ... @@ -114,7 +128,7 @@ both prerequisites and actions can be added later. For example ... Rake allows parallel execution of prerequisites using the following syntax: - multitask :copy_files => [:copy_src, :copy_doc, :copy_bin] do + multitask copy_files: %w[copy_src copy_doc copy_bin] do puts "All Copies Complete" end @@ -133,9 +147,9 @@ until the common prerequisites have been run. For example, if the copy_xxx tasks have the following prerequisites: - task :copy_src => [:prep_for_copy] - task :copy_bin => [:prep_for_copy] - task :copy_doc => [:prep_for_copy] + task copy_src: :prep_for_copy + task copy_bin: :prep_for_copy + task copy_doc: :prep_for_copy Then the +prep_for_copy+ task is run before starting all the copies in parallel. Once +prep_for_copy+ is complete, +copy_src+, +copy_bin+, @@ -175,7 +189,7 @@ arguments can be passed by separating them with a comma, for example: Just a few words of caution. The rake task name and its arguments need to be a single command line argument to rake. This generally -means no spaces. If spaces are needed, then the entire rake + +means no spaces. If spaces are needed, then the entire name + argument string should be quoted. Something like this: rake "name[billy bob, smith]" @@ -183,35 +197,6 @@ argument string should be quoted. Something like this: (Quoting rules vary between operating systems and shells, so make sure you consult the proper docs for your OS/shell). -=== Tasks Arguments and the Environment - -Task argument values can also be picked up from the environment. For -example, if the "release" task expected a parameter named -"release_version", then either - - rake release[0.8.2] - -or - - RELEASE_VERSION=0.8.2 rake release - -or, alternatively - - rake release RELEASE_VERSION=0.8.2 - -will work. Environment variable names must either match the task -parameter exactly, or match an all-uppercase version of the task -parameter. - -NOTE: A variable declared within a rake command will -not persist in the environment: - - $ export VALUE=old - $ rake print_value VALUE=new - new - $ rake print_value - old - === Tasks that Expect Parameters Parameters are only given to tasks that are setup to expect them. In @@ -238,9 +223,7 @@ behaviour can now accept a second parameter: The first argument of the block "t" is always bound to the current task object. The second argument "args" is an open-struct like object that allows access to the task arguments. Extra command line -arguments to a task are ignored. Missing command line arguments are -picked up from matching environment variables. If there are no -matching environment variables, they are given the nil value. +arguments to a task are ignored. If you wish to specify default values for the arguments, you can use the with_defaults method in the task body. Here is the above example @@ -275,7 +258,7 @@ parameters as well: mail = Mail.new(args.message) recipients = args.extras recipients.each do |target| - mail.send_to(recipents) + mail.send_to(target) end end @@ -294,8 +277,7 @@ versions of rake. == Accessing Task Programmatically Sometimes it is useful to manipulate tasks programmatically in a -Rakefile. To find a task object, use the :[] operator on the -Rake::Task. +Rakefile. To find a task object use Rake::Task.[]. === Programmatic Task Example @@ -364,7 +346,7 @@ The following rule is equivalent to the example above. sh "cc #{t.source} -c -o #{t.name}" end -NOTE: Because of a _quirk_ in Ruby syntax, parenthesis are +*NOTE:* Because of a _quirk_ in Ruby syntax, parenthesis are required on *rule* when the first argument is a regular expression. The following rule might be used for Java files ... @@ -375,7 +357,7 @@ The following rule might be used for Java files ... java_compile(t.source, t.name) end -NOTE: +java_compile+ is a hypothetical method that invokes the +*NOTE:* +java_compile+ is a hypothetical method that invokes the java compiler. == Importing Dependencies @@ -397,7 +379,7 @@ explicit task, that task is invoked before loading the file. This allows dependency files to be generated and used in a single rake command invocation. -=== Example: +Example: require 'rake/loaders/makefile' @@ -418,17 +400,17 @@ legal in Ruby source code, including comments for tasks and rules. However, if you wish a task to be described using the "-T" switch, then you need to use the +desc+ command to describe the task. -=== Example: +Example: desc "Create a distribution package" - task :package => [ ... ] do ... end + task package: %w[ ... ] do ... end The "-T" switch (or "--tasks" if you like to spell things out) will display a list of tasks that have a description. If you use +desc+ to describe your major tasks, you have a semi-automatic way of generating a summary of your Rake file. - traken$ rake -T + $ rake -T (in /home/.../rake) rake clean # Remove any temporary products. rake clobber # Remove any generated file. @@ -453,8 +435,7 @@ common for task names to begin to clash. For example, if you might have a main program and a set of sample programs built by a single Rakefile. By placing the tasks related to the main program in one namespace, and the tasks for building the sample programs in a -different namespace, the task names will not will not interfere with -each other. +different namespace, the task names will not interfere with each other. For example: @@ -470,12 +451,12 @@ For example: end end - task :build => ["main:build", "samples:build"] + task build: %w[main:build samples:build] Referencing a task in a separate namespace can be achieved by prefixing the task name with the namespace and a colon (e.g. "main:build" refers to the :build task in the +main+ namespace). -Nested namespaces are supported, so +Nested namespaces are supported. Note that the name given in the +task+ command is always the unadorned task name without any namespace prefixes. The +task+ command always @@ -579,11 +560,11 @@ This is the proper way to specify the task ... == Rakefile Path -When issuing the rake command in a terminal, Rake will look +When issuing the +rake+ command in a terminal, Rake will look for a Rakefile in the current directory. If a Rakefile is not found, it will search parent directories until one is found. -For example, if a Rakefile resides in the project/ directory, +For example, if a Rakefile resides in the +project/+ directory, moving deeper into the project's directory tree will not have an adverse effect on rake tasks: @@ -603,12 +584,36 @@ which the Rakefile resides. === Multiple Rake Files Not all tasks need to be included in a single Rakefile. Additional -rake files (with the file extension ".rake") may be placed in -rakelib directory located at the top level of a project (i.e. -the same directory that contains the main Rakefile). +rake files (with the file extension "+.rake+") may be placed in ++rakelib+ directory located at the top level of a project (i.e. +the same directory that contains the main +Rakefile+). Also, rails projects may include additional rake files in the -lib/tasks directory. ++lib/tasks+ directory. + +=== Clean and Clobber Tasks + +Through require 'rake/clean' Rake provides +clean+ and +clobber+ +tasks: + ++clean+ :: + Clean up the project by deleting scratch files and backup files. Add files + to the +CLEAN+ FileList to have the +clean+ target handle them. + ++clobber+ :: + Clobber all generated and non-source files in a project. The task depends + on +clean+, so all the +CLEAN+ files will be deleted as well as files in the + +CLOBBER+ FileList. The intent of this task is to return a project to its + pristine, just unpacked state. + +You can add file names or glob patterns to both the +CLEAN+ and +CLOBBER+ +lists. + +=== Phony Task + +The phony task can be used as a dependency to allow file-based tasks to use +non-file-based-tasks as prerequisites without forcing them to rebuild. You +can require 'rake/phony' to add the +phony+ task. ---- diff --git a/doc/release_notes/rake-0.4.14.rdoc b/doc/release_notes/rake-0.4.14.rdoc deleted file mode 100644 index b2f1f84f3..000000000 --- a/doc/release_notes/rake-0.4.14.rdoc +++ /dev/null @@ -1,23 +0,0 @@ -= Rake 0.4.14 Released - -== Changes - -Version 0.4.14 is a compatibility fix to allow Rake's test task to -work under Ruby 1.8.2. A change in the Test::Unit autorun feature -prevented Rake from running any tests. This release fixes the -problem. - -Rake 0.4.14 is the recommended release for anyone using Ruby 1.8.2. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 - diff --git a/doc/release_notes/rake-0.4.15.rdoc b/doc/release_notes/rake-0.4.15.rdoc deleted file mode 100644 index 975708863..000000000 --- a/doc/release_notes/rake-0.4.15.rdoc +++ /dev/null @@ -1,35 +0,0 @@ -= Rake 0.4.15 Released - -== Changes - -Version 0.4.15 is a bug fix update for the Ruby 1.8.2 compatibility -changes. This release includes: - -* Fixed a bug that prevented the TESTOPTS flag from working with the - revised for 1.8.2 test task. - -* Updated the docs on --trace to indicate that it also enables a full - backtrace on errors. - -* Several fixes for new warnings generated. - -== Mini-Roadmap - -I will continue to issue Rake updates in the 0.4.xx series as new -Ruby-1.8.2 issues become manifest. Once the codebase stabilizes, I -will release a 0.5.0 version incorporating all the changes. If you -are not using Ruby-1.8.2 and wish to avoid version churn, I recommend -staying with a release prior to Rake-0.4.14. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 - diff --git a/doc/release_notes/rake-0.5.0.rdoc b/doc/release_notes/rake-0.5.0.rdoc deleted file mode 100644 index f5cb9f307..000000000 --- a/doc/release_notes/rake-0.5.0.rdoc +++ /dev/null @@ -1,53 +0,0 @@ -= Rake 0.5.0 Released - -It has been a long time in coming, but we finally have a new version -of Rake available. - -== Changes - -* Fixed bug where missing intermediate file dependencies could cause - an abort with --trace or --dry-run. (Brian Candler) - -* Recursive rules are now supported (Tilman Sauerbeck). - -* Added tar.gz and tar.bz2 support to package task (Tilman Sauerbeck). - -* Added warning option for the Test Task (requested by Eric Hodel). - -* The jamis rdoc template is only used if it exists. - -* Added fix for Ruby 1.8.2 test/unit and rails problem. - -* Added contributed rake man file. (Jani Monoses) - -* Fixed documentation that was lacking the Rake module name (Tilman - Sauerbeck). - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 - -== Thanks - -Lots of people provided input to this release. Thanks to Tilman -Sauerbeck for numerous patches, documentation fixes and suggestions. -And for also pushing me to get this release out. Also, thanks to -Brian Candler for the finding and fixing --trace/dry-run fix. That -was an obscure bug. Also to Eric Hodel for some good suggestions. - --- Jim Weirich - diff --git a/doc/release_notes/rake-0.5.3.rdoc b/doc/release_notes/rake-0.5.3.rdoc deleted file mode 100644 index be2919f54..000000000 --- a/doc/release_notes/rake-0.5.3.rdoc +++ /dev/null @@ -1,78 +0,0 @@ -= Rake 0.5.0 Released - -Although it has only been two weeks since the last release, we have -enough updates to the Rake program to make it time for another -release. - -== Changes - -Here are the changes for version 0.5.3 ... - -* FileLists have been extensively changed so that they mimic the - behavior of real arrays even more closely. In particular, - operations on FileLists that return a new collection (e.g. collect, - reject) will now return a FileList rather than an array. In - addition, several places where FileLists were not properly expanded - before use have been fixed. - -* A method (+ext+) to simplify the handling of file extensions was - added to String and to Array. - -* The 'testrb' script in test/unit tends to silently swallow syntax - errors in test suites. Because of that, the default test loader is - now a rake-provided script. You can still use 'testrb' by setting - the loader flag in the test task to :testrb. (See the API documents - for TestTask for all the loader flag values). - -* FileUtil methods (e.g. cp, mv, install) are now declared to be - private. This will cut down on the interference with user defined - methods of the same name. - -* Fixed the verbose flag in the TestTask so that the test code is - controlled by the flag. Also shortened up some failure messages. - (Thanks to Tobias Luetke for the suggestion). - -* Rules will now properly detect a task that can generate a source - file. Previously rules would only consider source files that were - already present. - -* Added an +import+ command that allows Rake to dynamically import - dependendencies into a running Rake session. The +import+ command - can run tasks to update the dependency file before loading them. - Dependency files can be in rake or make format, allowing rake to - work with tools designed to generate dependencies for make. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 - -== Thanks - -As usual, it was input from users that drove a alot of these changes. -Thanks to ... - -* Brian Gernhardt for the rules fix (especially for the patience to - explain the problem to me until I got what he was talking about). -* Stefan Lang for pointing out problems in the dark corners of the - FileList implementation. -* Alexey Verkhovsky pointing out the silently swallows syntax errors - in tests. -* Tobias Luetke for beautifying the test task output. -* Sam Roberts for some of the ideas behind dependency loading. - --- Jim Weirich - diff --git a/doc/release_notes/rake-0.5.4.rdoc b/doc/release_notes/rake-0.5.4.rdoc deleted file mode 100644 index 38dfbdda3..000000000 --- a/doc/release_notes/rake-0.5.4.rdoc +++ /dev/null @@ -1,46 +0,0 @@ -= Rake 0.5.4 Released - -Time for some minor bug fixes and small enhancements - -== Changes - -Here are the changes for version 0.5.3 ... - -* Added double quotes to the test runner. This allows the location of - the tests (and runner) to be in a directory path that contains - spaces (e.g. "C:/Program Files/ruby/bin"). - -* Added .svn to default ignore list. Now subversion project metadata - is automatically ignored by Rake's FileList. - -* Updated FileList#include to support nested arrays and filelists. - FileLists are flat lists of file names. Using a FileList in an - include will flatten out the nested file names. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 - -== Thanks - -As usual, it was input from users that drove a alot of these changes. -Thanks to ... - -* Tilman Sauerbeck for the nested FileList suggestion. -* Josh Knowles for pointing out the spaces in directory name problem. - --- Jim Weirich diff --git a/doc/release_notes/rake-0.6.0.rdoc b/doc/release_notes/rake-0.6.0.rdoc deleted file mode 100644 index 340c07bf7..000000000 --- a/doc/release_notes/rake-0.6.0.rdoc +++ /dev/null @@ -1,141 +0,0 @@ -= Rake 0.6.0 Released - -Its time for some long requested enhancements and lots of bug fixes -... And a whole new web page. - -== New Web Page - -The primary documentation for rake has moved from the RubyForge based -wiki to its own Hieraki based web site. Constant spam on the wiki -made it a difficult to keep clean. The new site will be easier to -update and organize. - -Check out the new documentation at: http://docs.rubyrake.org - -We will be adding new documentation to the site as time goes on. - -In addition to the new docs page, make sure you check out Martin -Fowlers article on rake at http://martinfowler.com/articles/rake.html - -== Changes - -=== New Features - -* Multiple prerequisites on Rake rules now allowed. However, keep the - following in mind: - - 1. All the prerequisites of a rule must be available before a rule - is triggered, where "enabled" means (a) an existing file, (b) a - defined rule, or (c) another rule which also must be - trigger-able. - 2. Rules are checked in order of definition, so it is important to - order your rules properly. If a file can be created by two - different rules, put the more specific rule first (otherwise the - more general rule will trigger first and the specific one will - never be triggered). - 3. The source method now returns the name of the first - prerequisite listed in the rule. sources returns the - names of all the rule prerequisites, ordered as they are defined - in the rule. If the task has other prerequisites not defined in - the rule (but defined in an explicit task definition), then they - will _not_ be included in the sources list. - -* FileLists may now use the egrep command. This popular enhancement - is now a core part of the FileList object. If you want to get a - list of all your to-dos, fixmes and TBD comments, add the following - to your Rakefile. - - desc "Look for TODO and FIXME tags in the code" - task :todo do - FileList['**/*.rb'].egrep /#.*(FIXME|TODO|TBD)/ - end - -* The investigation method was added to task object to dump - out some important values. This makes it a bit easier to debug Rake - tasks. - - For example, if you are having problems with a particular task, just - print it out: - - task :huh do - puts Rake::Task['huh'].investigation - end - -* The Rake::TestTask class now supports a "ruby_opts" option to pass - arbitrary ruby options to a test subprocess. - -=== Some Incompatibilities - -* When using the ruby command to start a Ruby subprocess, the - Ruby interpreter that is currently running rake is used by default. - This makes it easier to use rake in an environment with multiple - ruby installation. (Previously, the first ruby command found in the - PATH was used). - - If you wish to chose a different Ruby interpreter, you can - explicitly choose the interpreter via the sh command. - -* The major rake classes (Task, FileTask, FileCreationTask, RakeApp) - have been moved out of the toplevel scope and are now accessible as - Rake::Task, Rake::FileTask, Rake::FileCreationTask and - Rake::Application. If your Rakefile - directly references any one of these tasks, you may: - - 1. Update your Rakefile to use the new classnames - 2. Use the --classic-namespace option on the rake command to get the - old behavior, - 3. Add require 'rake/classic_namespace' to the - Rakefile to get the old behavior. - - rake will print a rather annoying warning whenever a - deprecated class name is referenced without enabling classic - namespace. - -=== Bug Fixes - -* Several unit tests and functional tests were fixed to run better - under windows. - -* Directory tasks are now a specialized version of a File task. A - directory task will only be triggered if it doesn't exist. It will - not be triggered if it is out of date w.r.t. any of its - prerequisites. - -* Fixed a bug in the Rake::GemPackageTask class so that the gem now - properly contains the platform name. - -* Fixed a bug where a prerequisite on a file task would cause - an exception if the prerequisite did not exist. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 - -== Thanks - -As usual, it was input from users that drove a alot of these changes. -The following people either contributed patches, made suggestions or -made otherwise helpful comments. Thanks to ... - -* Greg Fast (better ruby_opt test options) -* Kelly Felkins (requested by better namespace support) -* Martin Fowler (suggested Task.investigation) -* Stuart Jansen (send initial patch for multiple prerequisites). -* Masao Mutch (better support for non-ruby Gem platforms) -* Philipp Neubeck (patch for file task exception fix) - --- Jim Weirich diff --git a/doc/release_notes/rake-0.7.0.rdoc b/doc/release_notes/rake-0.7.0.rdoc deleted file mode 100644 index b8bf56ebb..000000000 --- a/doc/release_notes/rake-0.7.0.rdoc +++ /dev/null @@ -1,119 +0,0 @@ -= Rake 0.7.0 Released - -These changes for Rake have been brewing for a long time. Here they -are, I hope you enjoy them. - -== Changes - -=== New Features - -* Name space support for task names (see below). - -* Prerequisites can be executed in parallel (see below). - -* Added safe_ln support for openAFS (via Ludvig Omholt). - -* RDoc defaults to internal (in-process) invocation. The old behavior - is still available by setting the +external+ flag to true. - -* Rakefiles are now loaded with the expanded path to prevent - accidental polution from the Ruby load path. - -* Task objects my now be used in prerequisite lists directly. - -* Task objects (in addition to task names) may now be included in the - prerequisite list of a task. - -* Internals cleanup and refactoring. - -=== Bug Fixes - -* Compatibility fixes for Ruby 1.8.4 FileUtils changes. - -=== Namespaces - -Tasks can now be nested inside their own namespaces. Tasks within one -namespace will not accidently interfer with tasks named in a different -namespace. - -For example: - - namespace "main" do - task :build do - # Build the main program - end - end - - namespace "samples" do - task :build do - # Build the sample programs - end - end - - task :build_all => ["main:build", "samples:build"] - -Even though both tasks are named :build, they are separate tasks in -their own namespaces. The :build_all task (defined in the toplevel -namespace) references both build tasks in its prerequisites. - -You may invoke each of the individual build tasks with the following -commands: - - rake main:build - rake samples:build - -Or invoke both via the :build_all command: - - rake build_all - -Namespaces may be nested arbitrarily. Since the name of file tasks -correspond to the name of a file in the external file system, -FileTasks are not affected by the namespaces. - -See the Rakefile format documentation (in the Rake API documents) for -more information. - -=== Parallel Tasks - -Sometimes you have several tasks that can be executed in parallel. By -specifying these tasks as prerequisites to a +multitask+ task. - -In the following example the tasks copy_src, copy_doc and copy_bin -will all execute in parallel in their own thread. - - multitask :copy_files => [:copy_src, :copy_doc, :copy_bin] do - puts "All Copies Complete" - end - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 - -== Thanks - -As usual, it was input from users that drove a alot of these changes. -The following people either contributed patches, made suggestions or -made otherwise helpful comments. Thanks to ... - -* Doug Young (inspriation for the parallel task) - -* David Heinemeier Hansson (for --trace message enhancement and for - pushing for namespace support). - -* Ludvig Omholt (for the openAFS fix) - --- Jim Weirich diff --git a/doc/release_notes/rake-0.7.1.rdoc b/doc/release_notes/rake-0.7.1.rdoc deleted file mode 100644 index c17088ee9..000000000 --- a/doc/release_notes/rake-0.7.1.rdoc +++ /dev/null @@ -1,59 +0,0 @@ -= Rake 0.7.1 Released - -Version 0.7.1 supplies a bug fix and a few minor enhancements. - -== Changes - -=== Bug Fixes in 0.7.1 - -* Changes in the exception reported for the FileUtils.ln caused - safe_ln to fail with a NotImplementedError. Rake 0.7.1 will now - catch that error or any StandardError and properly fall back to - using +cp+. - -=== New Features in 0.7.1 - -* You can filter the results of the --task option by supplying an - optional regular expression. This allows the user to easily find a - particular task name in a long list of possible names. - -* Transforming procs in a rule may now return a list of prerequisites. - This allows more flexible rule formation. - -* FileList and String now support a +pathmap+ melthod that makes the - transforming paths a bit easier. See the API docs for +pathmap+ for - details. - -* The -f option without a value will disable the search for a - Rakefile. This allows the Rakefile to be defined entirely in a - library (and loaded with the -r option). The current working - directory is not changed when this is done. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 - -== Thanks - -As usual, it was input from users that drove a alot of these changes. -The following people either contributed patches, made suggestions or -made otherwise helpful comments. Thanks to ... - -* James Britt and Assaph Mehr for reporting and helping to debug the - safe_ln issue. - --- Jim Weirich diff --git a/doc/release_notes/rake-0.7.2.rdoc b/doc/release_notes/rake-0.7.2.rdoc deleted file mode 100644 index ec99ee0c0..000000000 --- a/doc/release_notes/rake-0.7.2.rdoc +++ /dev/null @@ -1,121 +0,0 @@ -= Rake 0.7.2 Released - -Version 0.7.2 supplies a bug fix and a few minor enhancements. In -particular, the new version fixes an incompatibility with the soon to -be released Ruby 1.8.6. We strongly recommend upgrading to Rake 0.7.2 -in order to be compatible with the new version of Ruby. - -== Changes - -=== Bug Fixes in 0.7.2 - -There are quite a number of bug fixes in the new 0.7.2 version of -Rake: - -* Removed dependency on internal fu_xxx functions from FileUtils. - -* Error messages are now send to stderr rather than stdout (from - Payton Quackenbush). - -* Better error handling on invalid command line arguments (from Payton - Quackenbush). - -* Fixed some bugs where the application object was going to the global - appliation instead of using its own data. - -* Fixed the method name leak from FileUtils (bug found by Glenn - Vanderburg). - -* Added test for noop, bad_option and verbose flags to sh command. - -* Added a description to the gem task in GemPackageTask. - -* Fixed a bug when rules have multiple prerequisites (patch by Joel - VanderWerf) - -* Added the handful of RakeFileUtils to the private method as well. - -=== New Features in 0.7.2 - -The following new features are available in Rake version 0.7.2: - -* Added square and curly bracket patterns to FileList#include (Tilman - Sauerbeck). - -* FileLists can now pass a block to FileList#exclude to exclude files - based on calculated values. - -* Added plain filename support to rule dependents (suggested by Nobu - Nakada). - -* Added pathmap support to rule dependents. In other words, if a - pathmap format (beginning with a '%') is given as a Rake rule - dependent, then the name of the depend will be the name of the - target with the pathmap format applied. - -* Added a 'tasks' method to a namespace to get a list of tasks - associated with the namespace. - -* Added tar_command and zip_command options to the Package task. - -* The clean task will no longer delete 'core' if it is a directory. - -=== Internal Rake Improvements - -The following changes will are mainly internal improvements and -refactorings and have little effect on the end user. But they may be -of interest to the general public. - -* Added rcov task and updated unit testing for better code coverage. - -* Added a 'shame' task to the Rakefile. - -* Added rake_extension to handle detection of extension collisions. - -* Added a protected 'require "rubygems"' to test/test_application to - unbreak cruisecontrol.rb. - -* Removed rake_dup. Now we just simply rescue a bad dup. - -* Refactored the FileList reject logic to remove duplication. - -* Removed if __FILE__ at the end of the rake.rb file. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 - -== Thanks - -As usual, it was input from users that drove a alot of these changes. -The following people either contributed patches, made suggestions or -made otherwise helpful comments. Thanks to ... - -* Payton Quackenbush -- For several error handling improvements. - -* Glenn Vanderburg -- For finding and fixing the method name leak from - FileUtils. - -* Joel VanderWerf -- for finding and fixing a bug in the handling of - multiple prerequisites. - -* Tilman Sauerbeck -- For some enhancing FileList to support more - advanced file globbing. - -* Nobu Nakada -- For suggesting plain file name support to rule dependents. - --- Jim Weirich diff --git a/doc/release_notes/rake-0.7.3.rdoc b/doc/release_notes/rake-0.7.3.rdoc deleted file mode 100755 index 7e9f92198..000000000 --- a/doc/release_notes/rake-0.7.3.rdoc +++ /dev/null @@ -1,47 +0,0 @@ -= Rake 0.7.3 Released - -Rake version 0.7.3 is a minor release that includes some refactoring to better -support custom Rake applications. - -== Changes - -=== New Features in Version 0.7.3 - -* Added the +init+ and +top_level+ methods to make the creation of custom Rake applications a bit easier. E.g. - - gem 'rake', ">= 0.7.3" - require 'rake' - - Rake.application.init('myrake') - - task :default do - something_interesting - end - - Rake.application.top_level - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But instead of -cryptic make recipes, Rake uses standard Ruby code to declare tasks and -dependencies. You have the full power of a modern scripting language built -right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 - -== Thanks - -As usual, it was input from users that drove a alot of these changes. The -following people either contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - --- Jim Weirich diff --git a/doc/release_notes/rake-0.8.0.rdoc b/doc/release_notes/rake-0.8.0.rdoc deleted file mode 100644 index 4fc7fdd7b..000000000 --- a/doc/release_notes/rake-0.8.0.rdoc +++ /dev/null @@ -1,114 +0,0 @@ -= Rake 0.8.0/0.8.1 Released - -Rake version 0.8.0 is a new release of rake that includes serveral new -features. - -== Changes - -=== New Features in Version 0.8.0 - -* Tasks can now receive command line parameters. See the examples - below for more details. - -* Comments are limited to 80 columns on output, but full comments can - be seen by using the -D parameter. (feature suggested by Jamis - Buck). - -* Explicit exit(n) calls will now set the exit status to n. (patch - provided by Stephen Touset). - -* Rake is now compatible with Ruby 1.9. - -Version 0.8.1 is a minor update that includes additional Ruby 1.9 -compatibility fixes. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 - -== Task Argument Examples - -Prior to version 0.8.0, rake was only able to handle command line -arguments of the form NAME=VALUE that were passed into Rake via the -ENV hash. Many folks had asked for some kind of simple command line -arguments, perhaps using "--" to separate regular task names from -argument values on the command line. The problem is that there was no -easy way to associate positional arguments on the command line with -different tasks. Suppose both tasks :a and :b expect a command line -argument: does the first value go with :a? What if :b is run first? -Should it then get the first command line argument. - -Rake 0.8.0 solves this problem by explicitly passing values directly -to the tasks that need them. For example, if I had a release task -that required a version number, I could say: - - rake release[0.8.0] - -And the string "0.8.0" will be passed to the :release task. Multiple -arguments can be passed by separating them with a comma, for example: - - rake name[john,doe] - -Just a few words of caution. The rake task name and its arguments -need to be a single command line argument to rake. This generally -means no spaces. If spaces are needed, then the entire rake + -argument string should be quoted. Something like this: - - rake "name[billy bob, smith]" - -(Quoting rules vary between operating systems and shells, so make sure -you consult the proper docs for your OS/shell). - -=== Tasks that Expect Parameters - -Parameters are only given to tasks that are setup to expect them. In -order to handle named parameters, the task declaration syntax for -tasks has been extended slightly. - -For example, a task that needs a first name and last name might be -declared as: - - task :name, :first_name, :last_name - -The first argument is still the name of the task (:name in this case). -The next to argumements are the names of the parameters expected by -:name (:first_name and :last_name in the example). - -To access the values of the paramters, the block defining the task -behaviour can now accept a second parameter: - - task :name, :first_name, :last_name do |t, args| - puts "First name is #{args.first_name}" - puts "Last name is #{args.last_name}" - end - -The first argument of the block "t" is always bound to the current -task object. The second argument "args" is an open-struct like object -that allows access to the task arguments. Extra command line -arguments to a task are ignored. Missing command line arguments are -given the nil value. - -== Thanks - -As usual, it was input from users that drove a alot of these changes. The -following people either contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* Jamis Buck (for comment formatting suggestions) -* Stephen Touset (for exit status patch). - --- Jim Weirich diff --git a/doc/release_notes/rake-0.8.2.rdoc b/doc/release_notes/rake-0.8.2.rdoc deleted file mode 100644 index a822a9497..000000000 --- a/doc/release_notes/rake-0.8.2.rdoc +++ /dev/null @@ -1,165 +0,0 @@ -= Rake 0.8.2 Released - -Rake version 0.8.2 is a new release of rake that includes a number of -new features and numerous bug fixes. - -== Changes - -=== New Features in Version 0.8.2 - -* Switched from getoptlong to optparse (patches supplied by Edwin - Pratomo). - -* The -T option will now attempt to dynamically sense the size of the - terminal. The -T output will only self-truncate if the output is a - tty. However, if RAKE_COLUMNS is explicitly set, it will be honored - in any case. (Patch provided by Gavin Stark). - -* The following public methods have been added to rake task objects: - - * task.clear -- Clear both the prerequisites and actions of the - target rake task. - * task.clear_prerequisites -- Clear all the existing prerequisites - from the target rake task. - * task.clear_actions -- Clear all the existing actions from the - target rake task. - * task.reenable -- Re-enable a task, allowing its actions to be - executed again if the task is invoked. - -* Changed RDoc test task to have no default template. This makes it - easier for the tempate to pick up the template from the environment. - -* Default values for task arguments can easily be specified with the - :with_defaults method. (Idea for default argument merging supplied - by (Adam Q. Salter) - -=== Bug Fixes in Version 0.8.2 - -* Fixed bug in package task so that it will include the subdir - directory in the package for testing. (Bug found by Adam Majer) - -* Fixed filename dependency order bug in test_inspect_pending and - test_to_s_pending. (Bug found by Adam Majer) - -* Fixed check for file utils options to make them immune to the - symbol/string differences. (Patch supplied by Edwin Pratomo) - -* Fixed bug with rules involving multiple source, where only the first - dependency of a rule has any effect (Patch supplied by Emanuel - Indermühle) - -* FileList#clone and FileList#dup have better sematics w.r.t. taint - and freeze. - -* Changed from using Mutex to Monitor. Evidently Mutex causes thread - join errors when Ruby is compiled with -disable-pthreads. (Patch - supplied by Ittay Dror) - -* Fixed bug in makefile parser that had problems with extra spaces in - file task names. (Patch supplied by Ittay Dror) - -== Other changes in Version 0.8.2 - -* Added ENV var to rake's own Rakefile to prevent OS X from including - extended attribute junk in the rake package tar file. (Bug found by - Adam Majer) - -* Added a performance patch for reading large makefile dependency - files. (Patch supplied by Ittay Dror) - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 - -== Task Argument Examples - -Prior to version 0.8.0, rake was only able to handle command line -arguments of the form NAME=VALUE that were passed into Rake via the -ENV hash. Many folks had asked for some kind of simple command line -arguments, perhaps using "--" to separate regular task names from -argument values on the command line. The problem is that there was no -easy way to associate positional arguments on the command line with -different tasks. Suppose both tasks :a and :b expect a command line -argument: does the first value go with :a? What if :b is run first? -Should it then get the first command line argument. - -Rake 0.8.0 solves this problem by explicitly passing values directly -to the tasks that need them. For example, if I had a release task -that required a version number, I could say: - - rake release[0.8.2] - -And the string "0.8.2" will be passed to the :release task. Multiple -arguments can be passed by separating them with a comma, for example: - - rake name[john,doe] - -Just a few words of caution. The rake task name and its arguments -need to be a single command line argument to rake. This generally -means no spaces. If spaces are needed, then the entire rake + -argument string should be quoted. Something like this: - - rake "name[billy bob, smith]" - -(Quoting rules vary between operating systems and shells, so make sure -you consult the proper docs for your OS/shell). - -=== Tasks that Expect Parameters - -Parameters are only given to tasks that are setup to expect them. In -order to handle named parameters, the task declaration syntax for -tasks has been extended slightly. - -For example, a task that needs a first name and last name might be -declared as: - - task :name, :first_name, :last_name - -The first argument is still the name of the task (:name in this case). -The next to argumements are the names of the parameters expected by -:name (:first_name and :last_name in the example). - -To access the values of the paramters, the block defining the task -behaviour can now accept a second parameter: - - task :name, :first_name, :last_name do |t, args| - puts "First name is #{args.first_name}" - puts "Last name is #{args.last_name}" - end - -The first argument of the block "t" is always bound to the current -task object. The second argument "args" is an open-struct like object -that allows access to the task arguments. Extra command line -arguments to a task are ignored. Missing command line arguments are -given the nil value. - -== Thanks - -As usual, it was input from users that drove a alot of these changes. The -following people either contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* Edwin Pratomo -* Gavin Stark -* Adam Q. Salter -* Adam Majer -* Emanuel Indermühle -* Ittay Dror -* Bheeshmar Redheendran (for spending an afternoon with me debugging - windows issues) - --- Jim Weirich diff --git a/doc/release_notes/rake-0.8.3.rdoc b/doc/release_notes/rake-0.8.3.rdoc deleted file mode 100644 index 97184c390..000000000 --- a/doc/release_notes/rake-0.8.3.rdoc +++ /dev/null @@ -1,112 +0,0 @@ -= Rake 0.8.3 Released - -Rake version 0.8.3 is a bug-fix release of rake. - -== Changes - -=== Bug Fixes in Version 0.8.3 - -* Enhanced the system directory detection in windows. We now check - HOMEDRIVE/HOMEPATH and USERPROFILE if APPDATA isn't found. (Patch - supplied by James Tucker). Rake no long aborts if it can't find the - directory. - -* Added fix to handle ruby installations in directories with spaces in - their name. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 - -== Task Argument Examples - -Prior to version 0.8.0, rake was only able to handle command line -arguments of the form NAME=VALUE that were passed into Rake via the -ENV hash. Many folks had asked for some kind of simple command line -arguments, perhaps using "--" to separate regular task names from -argument values on the command line. The problem is that there was no -easy way to associate positional arguments on the command line with -different tasks. Suppose both tasks :a and :b expect a command line -argument: does the first value go with :a? What if :b is run first? -Should it then get the first command line argument. - -Rake 0.8.0 solves this problem by explicitly passing values directly -to the tasks that need them. For example, if I had a release task -that required a version number, I could say: - - rake release[0.8.3] - -And the string "0.8.3" will be passed to the :release task. Multiple -arguments can be passed by separating them with a comma, for example: - - rake name[john,doe] - -Just a few words of caution. The rake task name and its arguments -need to be a single command line argument to rake. This generally -means no spaces. If spaces are needed, then the entire rake + -argument string should be quoted. Something like this: - - rake "name[billy bob, smith]" - -(Quoting rules vary between operating systems and shells, so make sure -you consult the proper docs for your OS/shell). - -=== Tasks that Expect Parameters - -Parameters are only given to tasks that are setup to expect them. In -order to handle named parameters, the task declaration syntax for -tasks has been extended slightly. - -For example, a task that needs a first name and last name might be -declared as: - - task :name, :first_name, :last_name - -The first argument is still the name of the task (:name in this case). -The next to argumements are the names of the parameters expected by -:name (:first_name and :last_name in the example). - -To access the values of the paramters, the block defining the task -behaviour can now accept a second parameter: - - task :name, :first_name, :last_name do |t, args| - puts "First name is #{args.first_name}" - puts "Last name is #{args.last_name}" - end - -The first argument of the block "t" is always bound to the current -task object. The second argument "args" is an open-struct like object -that allows access to the task arguments. Extra command line -arguments to a task are ignored. Missing command line arguments are -given the nil value. - -== Thanks - -As usual, it was input from users that drove a alot of these changes. The -following people either contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* Edwin Pratomo -* Gavin Stark -* Adam Q. Salter -* Adam Majer -* Emanuel Indermühle -* Ittay Dror -* Bheeshmar Redheendran (for spending an afternoon with me debugging - windows issues) - --- Jim Weirich diff --git a/doc/release_notes/rake-0.8.4.rdoc b/doc/release_notes/rake-0.8.4.rdoc deleted file mode 100644 index d27de8b27..000000000 --- a/doc/release_notes/rake-0.8.4.rdoc +++ /dev/null @@ -1,147 +0,0 @@ -= Rake 0.8.4 Released - -Rake version 0.8.4 is a bug-fix release of rake. - -NOTE: The version of Rake that comes with Ruby 1.9 has diverged - slightly from the core Rake code base. Rake 0.8.4 will work - with Ruby 1.9, but is not a strict upgrade for the Rake that - comes with Ruby 1.9. A (near) future release of Rake will unify - those two codebases. - -== Letter Writing Campaign - -Thanks to Aaron Patterson (@tenderlove) and Eric Hodel (@drbrain) for -their encouraging support in organizing a letter writing campaign to -lobby for the "Warning Free" release of rake 0.8.4. A special callout -goes to Jonathan D. Lord, Sr (Dr. Wingnut) whose postcard was the -first to actually reach me. (see -http://tenderlovemaking.com/2009/02/26/we-need-a-new-version-of-rake/ -for details) - -== Changes - -=== New Features / Enhancements in Version 0.8.4 - -* Case is preserved on rakefile names. (patch from James - M. Lawrence/quix) - -* Improved Rakefile case insensitivity testing (patch from Luis - Lavena). - -* Windows system dir search order is now: HOME, HOMEDRIVE + HOMEPATH, - APPDATA, USERPROFILE (patch from Luis Lavena) - -* MingGW is now recognized as a windows platform. (patch from Luis - Lavena) - -=== Bug Fixes in Version 0.8.4 - -* Removed reference to manage_gem to fix the warning produced by the - gem package task. - -* Fixed stray ARGV option problem that was interfering with - Test::Unit::Runner. (patch from Pivotal Labs) - -=== Infrastructure Improvements in Version 0.8.4 - -* Numerous fixes to the windows test suite (patch from Luis Lavena). - -* Improved Rakefile case insensitivity testing (patch from Luis - Lavena). - -* Better support for windows paths in the test task (patch from Simon - Chiang/bahuvrihi) - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git - -== Task Argument Examples - -Prior to version 0.8.0, rake was only able to handle command line -arguments of the form NAME=VALUE that were passed into Rake via the -ENV hash. Many folks had asked for some kind of simple command line -arguments, perhaps using "--" to separate regular task names from -argument values on the command line. The problem is that there was no -easy way to associate positional arguments on the command line with -different tasks. Suppose both tasks :a and :b expect a command line -argument: does the first value go with :a? What if :b is run first? -Should it then get the first command line argument. - -Rake 0.8.0 solves this problem by explicitly passing values directly -to the tasks that need them. For example, if I had a release task -that required a version number, I could say: - - rake release[0.8.4] - -And the string "0.8.4" will be passed to the :release task. Multiple -arguments can be passed by separating them with a comma, for example: - - rake name[john,doe] - -Just a few words of caution. The rake task name and its arguments -need to be a single command line argument to rake. This generally -means no spaces. If spaces are needed, then the entire rake + -argument string should be quoted. Something like this: - - rake "name[billy bob, smith]" - -(Quoting rules vary between operating systems and shells, so make sure -you consult the proper docs for your OS/shell). - -=== Tasks that Expect Parameters - -Parameters are only given to tasks that are setup to expect them. In -order to handle named parameters, the task declaration syntax for -tasks has been extended slightly. - -For example, a task that needs a first name and last name might be -declared as: - - task :name, :first_name, :last_name - -The first argument is still the name of the task (:name in this case). -The next to argumements are the names of the parameters expected by -:name (:first_name and :last_name in the example). - -To access the values of the paramters, the block defining the task -behaviour can now accept a second parameter: - - task :name, :first_name, :last_name do |t, args| - puts "First name is #{args.first_name}" - puts "Last name is #{args.last_name}" - end - -The first argument of the block "t" is always bound to the current -task object. The second argument "args" is an open-struct like object -that allows access to the task arguments. Extra command line -arguments to a task are ignored. Missing command line arguments are -given the nil value. - -== Thanks - -As usual, it was input from users that drove a alot of these changes. The -following people either contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* James M. Lawrence/quix -* Luis Lavena -* Pivotal Labs -* Simon Chiang/bahuvrihi - --- Jim Weirich diff --git a/doc/release_notes/rake-0.8.5.rdoc b/doc/release_notes/rake-0.8.5.rdoc deleted file mode 100644 index 0ee2583dd..000000000 --- a/doc/release_notes/rake-0.8.5.rdoc +++ /dev/null @@ -1,53 +0,0 @@ -= Rake 0.8.5 Released - -Rake version 0.8.5 is a new release of Rake with greatly improved -support for executing commands on Windows. The "sh" command now has -the same semantics on Windows that it has on Unix based platforms. - -== Changes - -=== New Features / Enhancements in Version 0.8.5 - -* Improved implementation of the Rake system command for Windows. - (patch from James M. Lawrence/quix) - -* Support for Ruby 1.9's improved system command. (patch from James - M. Lawrence/quix) - -* Rake now includes the configured extension when invoking an - executable (Config::CONFIG['EXEEXT]) - -=== Bug Fixes in Version 0.8.5 - -* Environment variable keys are now correctly cased (it matters in - some implementations). - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git - -== Thanks - -As usual, it was input from users that drove a alot of these changes. The -following people either contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* James M. Lawrence/quix -* Luis Lavena - --- Jim Weirich diff --git a/doc/release_notes/rake-0.8.6.rdoc b/doc/release_notes/rake-0.8.6.rdoc deleted file mode 100644 index 476446077..000000000 --- a/doc/release_notes/rake-0.8.6.rdoc +++ /dev/null @@ -1,55 +0,0 @@ -= Rake 0.8.6 Released - -Rake version 0.8.5 introduced greatly improved support for executing -commands on Windows. The "sh" command now has the same semantics on -Windows that it has on Unix based platforms. - -Rake version 0.8.6 includes minor fixes the the RDoc generation. - -== Changes - -=== New Features / Enhancements in Version 0.8.5 - -* Improved implementation of the Rake system command for Windows. - (patch from James M. Lawrence/quix) - -* Support for Ruby 1.9's improved system command. (patch from James - M. Lawrence/quix) - -* Rake now includes the configured extension when invoking an - executable (Config::CONFIG['EXEEXT]) - -=== Bug Fixes in Version 0.8.5 - -* Environment variable keys are now correctly cased (it matters in - some implementations). - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git - -== Thanks - -As usual, it was input from users that drove a alot of these changes. The -following people either contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* James M. Lawrence/quix -* Luis Lavena - --- Jim Weirich diff --git a/doc/release_notes/rake-0.8.7.rdoc b/doc/release_notes/rake-0.8.7.rdoc deleted file mode 100644 index 884f4c659..000000000 --- a/doc/release_notes/rake-0.8.7.rdoc +++ /dev/null @@ -1,55 +0,0 @@ -= Rake 0.8.7 Released - -Rake version 0.8.5 introduced greatly improved support for executing -commands on Windows. The "sh" command now has the same semantics on -Windows that it has on Unix based platforms. - -Rake version 0.8.6 includes minor fixes the the RDoc generation. -Rake version 0.8.7 includes a minor fix for JRuby running on windows. - -== Changes - -=== New Features / Enhancements in Version 0.8.5 - -* Improved implementation of the Rake system command for Windows. - (patch from James M. Lawrence/quix) - -* Support for Ruby 1.9's improved system command. (patch from James - M. Lawrence/quix) - -* Rake now includes the configured extension when invoking an - executable (Config::CONFIG['EXEEXT]) - -=== Bug Fixes in Version 0.8.5 - -* Environment variable keys are now correctly cased (it matters in - some implementations). - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git - -== Thanks - -As usual, it was input from users that drove a alot of these changes. The -following people either contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* Charles Nutter - --- Jim Weirich diff --git a/doc/release_notes/rake-0.9.0.rdoc b/doc/release_notes/rake-0.9.0.rdoc deleted file mode 100644 index 823483cc2..000000000 --- a/doc/release_notes/rake-0.9.0.rdoc +++ /dev/null @@ -1,112 +0,0 @@ -= Rake 0.9.0 Released - -Rake version 0.9.0 has a number of bug fixes and enhancments (see -below for more details). Additionally, the internals have be slightly -restructured and improved. - -== Changes - -=== New Features / Enhancements / Bug Fixes in Version 0.9.0 - -* Rake now warns when the deprecated :needs syntax used (and suggests - the proper syntax in the warning). - -* Moved Rake DSL commands to top level ruby object 'main'. Rake DSL - commands are no longer private methods in Object. (Suggested by - James M. Lawrence/quix) - -* Rake now uses case-insensitive comparisons to find the Rakefile on Windows. - Based on patch by Roger Pack. - -* Rake now requires (instead of loads) files in the test task. Patch by Cezary - Baginski. - -* Fixed typos. Patches by Sean Scot August Moon and R.T. Lechow. - -* Rake now prints the Rakefile directory only when it's different from the - current directory. Patch by Alex Chaffee. - -* Improved rakefile_location discovery on Windows. Patch by James Tucker. - -* Rake now recognizes "Windows Server" as a windows system. Patch by Matthias - Lüdtke - -* Rake::RDocTask is deprecated. Use RDoc::Task from RDoc 2.4.2+ (require - 'rdoc/task') - -* Rake::GemPackageTask is deprecated. Use Gem::PackageTask (require - 'rubygems/package_task') - -* Rake now outputs various messages to $stderr instead of $stdout. - -* Rake no longer emits warnings for Config. Patch by Santiago Pastorino. - -* Removed Rake's DSL methods from the top level scope. If you need to - call 'task :xzy' in your code, include Rake::DSL into your class, or - put the code in a Rake::DSL.environment do ... end block. - -* Split rake.rb into individual files. - -* Support for the --where (-W) flag for showing where a task is defined. - -* Fixed quoting in test task. - (http://onestepback.org/redmine/issues/show/44, - http://www.pivotaltracker.com/story/show/1223138) - -* Fixed the silent option parsing problem. - (http://onestepback.org/redmine/issues/show/47) - -* Fixed :verbose=>false flag on sh and ruby commands. - -* Rake command line options may be given by default in a RAKEOPT - environment variable. - -* Errors in Rake will now display the task invocation chain in effect - at the time of the error. - -* Accepted change by warnickr to not expand test patterns in shell - (allowing more files in the test suite). - -* Fixed that file tasks did not perform prereq lookups in scope - (Redmine #57). - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git - -== Thanks - -As usual, it was input from users that drove a alot of these changes. The -following people either contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* James M. Lawrence (quix) -* Roger Pack -* Cezary Baginski -* Sean Scot August Moon -* R.T. Lechow -* Alex Chaffee -* James Tucker -* Matthias Lüdtke -* Santiago Pastorino - -Also, bit thanks to Eric Hodel for assisting with getting this release -out the door (where "assisting" includes, but is not by any means -limited to, "pushing" me to get it done). - --- Jim Weirich diff --git a/doc/release_notes/rake-0.9.1.rdoc b/doc/release_notes/rake-0.9.1.rdoc deleted file mode 100644 index 70be8b568..000000000 --- a/doc/release_notes/rake-0.9.1.rdoc +++ /dev/null @@ -1,52 +0,0 @@ -= Rake 0.9.1 Released - -Rake version 0.9.1 has a number of bug fixes and enhancments (see -below for more details). Additionally, the internals have be slightly -restructured and improved. - -== Changes - -Rake 0.9.1 adds back the global DSL methods, but with deprecation -messages. This allows Rake 0.9.1 to be used with older rakefiles with -warning messages. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git - -== Thanks - -As usual, it was input from users that drove a alot of these changes. The -following people either contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* James M. Lawrence (quix) -* Roger Pack -* Cezary Baginski -* Sean Scot August Moon -* R.T. Lechow -* Alex Chaffee -* James Tucker -* Matthias Lüdtke -* Santiago Pastorino - -Also, bit thanks to Eric Hodel for assisting with getting this release -out the door (where "assisting" includes, but is not by any means -limited to, "pushing" me to get it done). - --- Jim Weirich diff --git a/doc/release_notes/rake-0.9.2.2.rdoc b/doc/release_notes/rake-0.9.2.2.rdoc deleted file mode 100644 index d804aba81..000000000 --- a/doc/release_notes/rake-0.9.2.2.rdoc +++ /dev/null @@ -1,55 +0,0 @@ -= Rake 0.9.3 Released - -Rake version 0.9.3 is mainly bug fixes. - -== Changes - -* The rake test loader now removes arguments it has processed. Issue #51 -* Rake::TaskArguments now responds to #values_at -* RakeFileUtils.verbose_flag = nil silences output the same as 0.8.7 -* Rake tests are now directory-independent -* Rake tests are no longer require flexmock -* Commands constant is no longer polluting top level namespace. -* Show only the interesting portion of the backtrace by default (James M. Lawrence). -* Added --reduce-compat option to remove backward compatible DSL hacks (James M. Lawrence). - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git - -== Thanks - -As usual, it was input from users that drove a alot of these changes. The -following people either contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* James M. Lawrence (quix) -* Roger Pack -* Cezary Baginski -* Sean Scot August Moon -* R.T. Lechow -* Alex Chaffee -* James Tucker -* Matthias Lüdtke -* Santiago Pastorino - -Also, bit thanks to Eric Hodel for assisting with getting this release -out the door (where "assisting" includes, but is not by any means -limited to, "pushing" me to get it done). - --- Jim Weirich diff --git a/doc/release_notes/rake-0.9.2.rdoc b/doc/release_notes/rake-0.9.2.rdoc deleted file mode 100644 index 2314193f5..000000000 --- a/doc/release_notes/rake-0.9.2.rdoc +++ /dev/null @@ -1,49 +0,0 @@ -= Rake 0.9.2 Released - -Rake version 0.9.2 has a few small fixes. See below for details. - -== Changes - -* Support for Ruby 1.8.6 was fixed. -* Global DSL warnings now honor --no-deprecate - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://rake.rubyforge.org/ -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git - -== Thanks - -As usual, it was input from users that drove a alot of these changes. The -following people either contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* James M. Lawrence (quix) -* Roger Pack -* Cezary Baginski -* Sean Scot August Moon -* R.T. Lechow -* Alex Chaffee -* James Tucker -* Matthias Lüdtke -* Santiago Pastorino - -Also, bit thanks to Eric Hodel for assisting with getting this release -out the door (where "assisting" includes, but is not by any means -limited to, "pushing" me to get it done). - --- Jim Weirich diff --git a/doc/release_notes/rake-0.9.3.rdoc b/doc/release_notes/rake-0.9.3.rdoc deleted file mode 100644 index 4476b4f18..000000000 --- a/doc/release_notes/rake-0.9.3.rdoc +++ /dev/null @@ -1,102 +0,0 @@ -= Rake 0.9.3 Released - -Rake version 0.9.3 contains some new, backwards compatible features and -a number of bug fixes. - -== Changes - -=== New Features - -* Multitask tasks now use a thread pool. Use -j to limit the number of - available threads. - -* Use -m to turn regular tasks into multitasks (use at your own risk). - -* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to - programatically add rake task libraries. - -* You can specific backtrace suppression patterns (see - --supress-backtrace) - -* Directory tasks can now take prerequisites and actions - -* Use --backtrace to request a full backtrace without the task trace. - -* You can say "--backtrace=stdout" and "--trace=stdout" to route trace - output to standard output rather than standard error. - -* Optional 'phony' target (enable with 'require 'rake/phony'") for - special purpose builds. - -* Task#clear now clears task comments as well as actions and - prerequisites. Task#clear_comment will specifically target comments. - -* The --all option will force -T and -D to consider all the tasks, - with and without descriptions. - -=== Bug Fixes - -* Semi-colons in windows rakefile paths now work. - -* Improved Control-C support when invoking multiple test suites. - -* egrep method now reads files in text mode (better support for - Windows) - -* Better deprecation line number reporting. - -* The -W option now works with all tasks, whether they have a - description or not. - -* File globs in rake should not be sorted alphabetically, independent - of file system and platform. - -* Numerous internal improvements. - -* Documentation typos and fixes. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://github.com/jimweirich/rake -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git - -== Thanks - -As usual, it was input from users that drove a alot of these changes. The -following people either contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* Aaron Patterson -* Dylan Smith -* Jo Liss -* Jonas Pfenniger -* Kazuki Tsujimoto -* Michael Bishop -* Michael Elufimov -* NAKAMURA Usaku -* Ryan Davis -* Sam Grönblom -* Sam Phippen -* Sergio Wong -* Tay Ray Chuan -* grosser -* quix - -Also, many thanks to Eric Hodel for assisting with getting this release -out the door. - --- Jim Weirich diff --git a/doc/release_notes/rake-0.9.4.rdoc b/doc/release_notes/rake-0.9.4.rdoc deleted file mode 100644 index e5d45b46a..000000000 --- a/doc/release_notes/rake-0.9.4.rdoc +++ /dev/null @@ -1,110 +0,0 @@ -= Rake 0.9.4 Released - -Rake version 0.9.4 contains a number of bug fixes. - -== Changes - -=== New Features (in 0.9.3) - -* Multitask tasks now use a thread pool. Use -j to limit the number of - available threads. - -* Use -m to turn regular tasks into multitasks (use at your own risk). - -* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to - programatically add rake task libraries. - -* You can specific backtrace suppression patterns (see - --supress-backtrace) - -* Directory tasks can now take prerequisites and actions - -* Use --backtrace to request a full backtrace without the task trace. - -* You can say "--backtrace=stdout" and "--trace=stdout" to route trace - output to standard output rather than standard error. - -* Optional 'phony' target (enable with 'require 'rake/phony'") for - special purpose builds. - -* Task#clear now clears task comments as well as actions and - prerequisites. Task#clear_comment will specifically target comments. - -* The --all option will force -T and -D to consider all the tasks, - with and without descriptions. - -=== Bug Fixes (0.9.3) - -* Semi-colons in windows rakefile paths now work. - -* Improved Control-C support when invoking multiple test suites. - -* egrep method now reads files in text mode (better support for - Windows) - -* Better deprecation line number reporting. - -* The -W option now works with all tasks, whether they have a - description or not. - -* File globs in rake should not be sorted alphabetically, independent - of file system and platform. - -* Numerous internal improvements. - -* Documentation typos and fixes. - -=== Bug Fixes (0.9.4) - -* Exit status with failing tests is not correctly set to non-zero. - -* Simplified syntax for phony task (for older versions of RDoc). - -* Stand alone FileList usage gets glob function (without loading in - extra dependencies) - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://github.com/jimweirich/rake -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git - -== Thanks - -As usual, it was input from users that drove a alot of these changes. The -following people either contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* Aaron Patterson -* Dylan Smith -* Jo Liss -* Jonas Pfenniger -* Kazuki Tsujimoto -* Michael Bishop -* Michael Elufimov -* NAKAMURA Usaku -* Ryan Davis -* Sam Grönblom -* Sam Phippen -* Sergio Wong -* Tay Ray Chuan -* grosser -* quix - -Also, many thanks to Eric Hodel for assisting with getting this release -out the door. - --- Jim Weirich diff --git a/doc/release_notes/rake-0.9.5.rdoc b/doc/release_notes/rake-0.9.5.rdoc deleted file mode 100644 index 88e2d7cf3..000000000 --- a/doc/release_notes/rake-0.9.5.rdoc +++ /dev/null @@ -1,114 +0,0 @@ -= Rake 0.9.5 Released - -Rake version 0.9.5 contains a number of bug fixes. - -== Changes - -=== New Features (in 0.9.3) - -* Multitask tasks now use a thread pool. Use -j to limit the number of - available threads. - -* Use -m to turn regular tasks into multitasks (use at your own risk). - -* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to - programatically add rake task libraries. - -* You can specific backtrace suppression patterns (see - --supress-backtrace) - -* Directory tasks can now take prerequisites and actions - -* Use --backtrace to request a full backtrace without the task trace. - -* You can say "--backtrace=stdout" and "--trace=stdout" to route trace - output to standard output rather than standard error. - -* Optional 'phony' target (enable with 'require 'rake/phony'") for - special purpose builds. - -* Task#clear now clears task comments as well as actions and - prerequisites. Task#clear_comment will specifically target comments. - -* The --all option will force -T and -D to consider all the tasks, - with and without descriptions. - -=== Bug Fixes (0.9.3) - -* Semi-colons in windows rakefile paths now work. - -* Improved Control-C support when invoking multiple test suites. - -* egrep method now reads files in text mode (better support for - Windows) - -* Better deprecation line number reporting. - -* The -W option now works with all tasks, whether they have a - description or not. - -* File globs in rake should not be sorted alphabetically, independent - of file system and platform. - -* Numerous internal improvements. - -* Documentation typos and fixes. - -=== Bug Fixes (0.9.4) - -* Exit status with failing tests is not correctly set to non-zero. - -* Simplified syntax for phony task (for older versions of RDoc). - -* Stand alone FileList usage gets glob function (without loading in - extra dependencies) - -=== Bug Fixes (0.9.5) - -* --trace and --backtrace no longer swallow following task names. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://github.com/jimweirich/rake -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git - -== Thanks - -As usual, it was input from users that drove a alot of these changes. The -following people either contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* Aaron Patterson -* Dylan Smith -* Jo Liss -* Jonas Pfenniger -* Kazuki Tsujimoto -* Michael Bishop -* Michael Elufimov -* NAKAMURA Usaku -* Ryan Davis -* Sam Grönblom -* Sam Phippen -* Sergio Wong -* Tay Ray Chuan -* grosser -* quix - -Also, many thanks to Eric Hodel for assisting with getting this release -out the door. - --- Jim Weirich diff --git a/doc/release_notes/rake-0.9.6.rdoc b/doc/release_notes/rake-0.9.6.rdoc deleted file mode 100644 index e1c5f88ca..000000000 --- a/doc/release_notes/rake-0.9.6.rdoc +++ /dev/null @@ -1,127 +0,0 @@ -= Rake 0.9.6 Released - -Rake version 0.9.6 contains a number of fixes mainly for merging -Rake into the Ruby source tree and fixing tests. - -== Changes - -=== New Features (in 0.9.3) - -* Multitask tasks now use a thread pool. Use -j to limit the number of - available threads. - -* Use -m to turn regular tasks into multitasks (use at your own risk). - -* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to - programatically add rake task libraries. - -* You can specific backtrace suppression patterns (see - --supress-backtrace) - -* Directory tasks can now take prerequisites and actions - -* Use --backtrace to request a full backtrace without the task trace. - -* You can say "--backtrace=stdout" and "--trace=stdout" to route trace - output to standard output rather than standard error. - -* Optional 'phony' target (enable with 'require 'rake/phony'") for - special purpose builds. - -* Task#clear now clears task comments as well as actions and - prerequisites. Task#clear_comment will specifically target comments. - -* The --all option will force -T and -D to consider all the tasks, - with and without descriptions. - -=== Bug Fixes (0.9.3) - -* Semi-colons in windows rakefile paths now work. - -* Improved Control-C support when invoking multiple test suites. - -* egrep method now reads files in text mode (better support for - Windows) - -* Better deprecation line number reporting. - -* The -W option now works with all tasks, whether they have a - description or not. - -* File globs in rake should not be sorted alphabetically, independent - of file system and platform. - -* Numerous internal improvements. - -* Documentation typos and fixes. - -=== Bug Fixes (0.9.4) - -* Exit status with failing tests is not correctly set to non-zero. - -* Simplified syntax for phony task (for older versions of RDoc). - -* Stand alone FileList usage gets glob function (without loading in - extra dependencies) - -=== Bug Fixes (0.9.5) - -* --trace and --backtrace no longer swallow following task names. - -=== Bug Fixes (0.9.6) - -* Better trace output when using a multi-threaded Rakefile. -* Arg parsing is now consistent for tasks and multitasks. -* Skip exit code test in versions of Ruby that don't support it well. - -Changes for better integration with the Ruby source tree: - -* Fix version literal for Ruby source tree build. -* Better loading of libraries for testing in Ruby build. -* Use the ruby version provided by Ruby's tests. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://github.com/jimweirich/rake -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git - -== Thanks - -As usual, it was input from users that drove a alot of these changes. The -following people either contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* Aaron Patterson -* Dylan Smith -* Jo Liss -* Jonas Pfenniger -* Kazuki Tsujimoto -* Michael Bishop -* Michael Elufimov -* NAKAMURA Usaku -* Ryan Davis -* Sam Grönblom -* Sam Phippen -* Sergio Wong -* Tay Ray Chuan -* grosser -* quix - -Also, many thanks to Eric Hodel for assisting with getting this release -out the door. - --- Jim Weirich diff --git a/doc/release_notes/rake-10.0.0.rdoc b/doc/release_notes/rake-10.0.0.rdoc deleted file mode 100644 index 7bf68fb73..000000000 --- a/doc/release_notes/rake-10.0.0.rdoc +++ /dev/null @@ -1,178 +0,0 @@ -= Rake 10.0 Released - - "Jim, when will Rake reach version 1.0?" - -Over the past several years I've been asked that question at -conferences, panels and over twitter. Due to historical reasons (or -maybe just plain laziness) Rake has (incorrectly) been treating the -second digit of the version as the major release number. So in my head -Rake was already at version 9. - -Well, it's time to fix things. This next version of Rake drops old, -crufty, backwards compatibility hacks such as top level constants, DSL -methods defined in Object and numerous other features that are just no -longer desired. It's also time to drop the leading zero from the -version number as well and call this new version of rake what it -really is: Version 10. - -So, welcome to Rake 10.0! - -Rake 10 is actually feature identical to the latest version of Rake 9 -(that would be the version spelled 0.9.3), *except* that Rake 10 drops -all the sundry deprecated features that have accumulated over the years. - -If your Rakefile is up to date and current with all the new features -of Rake 10, you are ready to go. If your Rakefile still uses a few -deprecated feeatures, feel free to use Rake 9 (0.9.3) with the same -feature set. Just be aware that future features will be in Rake 10 -family line. - -== Changes in 10.0 - -As mentioned above, there are no new features in Rake 10. However, -there are a number of features missing: - -* Classic namespaces are now gone. Rake is no longer able to reflect - the options settings in the global variables ($rakefile, $show_tasks, - $show_prereqs, $trace, $dryrun and $silent). The - --classic-namespace option is no longer supported. - -* Global constants are no longer supported. This includes - Task, FileTask, FileCreationTask and - RakeApp). The constant missing hook to warn about using - global rake constants has been removed. - -* The Rake DSL methods (task, file, directory, etc) are in their own - module (Rake::DSL). The stub versions of these methods (that printed - warnings) in Object have been removed. However, the DSL methods are - added to the top-level main object. Since main is - not in the inheritance tree, the presence of the DSL methods in main - should be low impact on other libraries. - - If you want to use the Rake DSL commands from your own code, just - include Rake::DSL into your own classes and modules. - -* The deprecated syntax for task arguments (the one using - :needs) has been removed. - -* The --reduce-compat flag has been removed (it's not needed - anymore). - -* The deprecated rake/sys.rb library has been removed. - -* The deprecated rake/rdoctask.rb library has been removed. - RDoc supplies its own rake task now. - -* The deprecated rake/gempackagetask.rb library has been - removed. Gem supplies its own package task now. - -There is one small behavioral change: - -* Non-file tasks now always report the current time as their time - stamp. This is different from the previous behavior where non-file - tasks reported current time only if there were no prerequisites, and - the max prerequisite timestamp otherwise. This lead to inconsistent - and surprising behavior when adding prerequisites to tasks that in - turn were prequisites to file tasks. The new behavior is more - consistent and predictable. - -== Changes (from 0.9.3) - -Since Rake 10 includes the changes from the last version of Rake 9, -we'll repeat the changes for version 0.9.3 here. - -=== New Features - -* Multitask tasks now use a thread pool. Use -j to limit the number of - available threads. - -* Use -m to turn regular tasks into multitasks (use at your own risk). - -* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to - programatically add rake task libraries. - -* You can specific backtrace suppression patterns (see - --supress-backtrace) - -* Directory tasks can now take prerequisites and actions - -* Use --backtrace to request a full backtrace without the task trace. - -* You can say "--backtrace=stdout" and "--trace=stdout" to route trace - output to standard output rather than standard error. - -* Optional 'phony' target (enable with 'require 'rake/phony'") for - special purpose builds. - -* Task#clear now clears task comments as well as actions and - prerequisites. Task#clear_comment will specifically target comments. - -* The --all option will force -T and -D to consider all the tasks, - with and without descriptions. - -=== Bug Fixes - -* Semi-colons in windows rakefile paths now work. - -* Improved Control-C support when invoking multiple test suites. - -* egrep method now reads files in text mode (better support for - Windows) - -* Better deprecation line number reporting. - -* The -W option now works with all tasks, whether they have a - description or not. - -* File globs in rake should not be sorted alphabetically, independent - of file system and platform. - -* Numerous internal improvements. - -* Documentation typos and fixes. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://github.com/jimweirich/rake -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git - -== Thanks - -As usual, it was input from users that drove a lot of these changes. The -following people contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* Aaron Patterson -* Dylan Smith -* Jo Liss -* Jonas Pfenniger -* Kazuki Tsujimoto -* Michael Bishop -* Michael Elufimov -* NAKAMURA Usaku -* Ryan Davis -* Sam Grönblom -* Sam Phippen -* Sergio Wong -* Tay Ray Chuan -* grosser -* quix - -Also, many thanks to Eric Hodel for assisting with getting this release -out the door. - --- Jim Weirich diff --git a/doc/release_notes/rake-10.0.1.rdoc b/doc/release_notes/rake-10.0.1.rdoc deleted file mode 100644 index 75aa926aa..000000000 --- a/doc/release_notes/rake-10.0.1.rdoc +++ /dev/null @@ -1,187 +0,0 @@ -= Rake 10.0.1 Released - - "Jim, when will Rake reach version 1.0?" - -Over the past several years I've been asked that question at -conferences, panels and over twitter. Due to historical reasons (or -maybe just plain laziness) Rake has (incorrectly) been treating the -second digit of the version as the major release number. So in my head -Rake was already at version 9. - -Well, it's time to fix things. This next version of Rake drops old, -crufty, backwards compatibility hacks such as top level constants, DSL -methods defined in Object and numerous other features that are just no -longer desired. It's also time to drop the leading zero from the -version number as well and call this new version of rake what it -really is: Version 10. - -So, welcome to Rake 10.0! - -Rake 10 is actually feature identical to the latest version of Rake 9 -(that would be the version spelled 0.9.3), *except* that Rake 10 drops -all the sundry deprecated features that have accumulated over the years. - -If your Rakefile is up to date and current with all the new features -of Rake 10, you are ready to go. If your Rakefile still uses a few -deprecated feeatures, feel free to use Rake 9 (0.9.3) with the same -feature set. Just be aware that future features will be in Rake 10 -family line. - -== Changes in 10.0 - -As mentioned above, there are no new features in Rake 10. However, -there are a number of features missing: - -* Classic namespaces are now gone. Rake is no longer able to reflect - the options settings in the global variables ($rakefile, $show_tasks, - $show_prereqs, $trace, $dryrun and $silent). The - --classic-namespace option is no longer supported. - -* Global constants are no longer supported. This includes - Task, FileTask, FileCreationTask and - RakeApp). The constant missing hook to warn about using - global rake constants has been removed. - -* The Rake DSL methods (task, file, directory, etc) are in their own - module (Rake::DSL). The stub versions of these methods (that printed - warnings) in Object have been removed. However, the DSL methods are - added to the top-level main object. Since main is - not in the inheritance tree, the presence of the DSL methods in main - should be low impact on other libraries. - - If you want to use the Rake DSL commands from your own code, just - include Rake::DSL into your own classes and modules. - -* The deprecated syntax for task arguments (the one using - :needs) has been removed. - -* The --reduce-compat flag has been removed (it's not needed - anymore). - -* The deprecated rake/sys.rb library has been removed. - -* The deprecated rake/rdoctask.rb library has been removed. - RDoc supplies its own rake task now. - -* The deprecated rake/gempackagetask.rb library has been - removed. Gem supplies its own package task now. - -There is one small behavioral change: - -* Non-file tasks now always report the current time as their time - stamp. This is different from the previous behavior where non-file - tasks reported current time only if there were no prerequisites, and - the max prerequisite timestamp otherwise. This lead to inconsistent - and surprising behavior when adding prerequisites to tasks that in - turn were prequisites to file tasks. The new behavior is more - consistent and predictable. - -== Changes (from 0.9.3 & 0.9.4) - -Since Rake 10 includes the changes from the last version of Rake 9, -we'll repeat the changes for version 0.9.3 here. - -=== New Features (in 0.9.3) - -* Multitask tasks now use a thread pool. Use -j to limit the number of - available threads. - -* Use -m to turn regular tasks into multitasks (use at your own risk). - -* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to - programatically add rake task libraries. - -* You can specific backtrace suppression patterns (see - --supress-backtrace) - -* Directory tasks can now take prerequisites and actions - -* Use --backtrace to request a full backtrace without the task trace. - -* You can say "--backtrace=stdout" and "--trace=stdout" to route trace - output to standard output rather than standard error. - -* Optional 'phony' target (enable with 'require 'rake/phony'") for - special purpose builds. - -* Task#clear now clears task comments as well as actions and - prerequisites. Task#clear_comment will specifically target comments. - -* The --all option will force -T and -D to consider all the tasks, - with and without descriptions. - -=== Bug Fixes (in 0.9.3) - -* Semi-colons in windows rakefile paths now work. - -* Improved Control-C support when invoking multiple test suites. - -* egrep method now reads files in text mode (better support for - Windows) - -* Better deprecation line number reporting. - -* The -W option now works with all tasks, whether they have a - description or not. - -* File globs in rake should not be sorted alphabetically, independent - of file system and platform. - -* Numerous internal improvements. - -* Documentation typos and fixes. - -=== Bug Fixes (in 0.9.4) - -* Exit status with failing tests is not correctly set to non-zero. - -* Simplified syntax for phony task (for older versions of RDoc). - -* Stand alone FileList usage gets glob function (without loading in - extra dependencies) - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://github.com/jimweirich/rake -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git - -== Thanks - -As usual, it was input from users that drove a lot of these changes. The -following people contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* Aaron Patterson -* Dylan Smith -* Jo Liss -* Jonas Pfenniger -* Kazuki Tsujimoto -* Michael Bishop -* Michael Elufimov -* NAKAMURA Usaku -* Ryan Davis -* Sam Grönblom -* Sam Phippen -* Sergio Wong -* Tay Ray Chuan -* grosser -* quix - -Also, many thanks to Eric Hodel for assisting with getting this release -out the door. - --- Jim Weirich diff --git a/doc/release_notes/rake-10.0.2.rdoc b/doc/release_notes/rake-10.0.2.rdoc deleted file mode 100644 index b9ef26787..000000000 --- a/doc/release_notes/rake-10.0.2.rdoc +++ /dev/null @@ -1,191 +0,0 @@ -= Rake 10.0.2 Released - - "Jim, when will Rake reach version 1.0?" - -Over the past several years I've been asked that question at -conferences, panels and over twitter. Due to historical reasons (or -maybe just plain laziness) Rake has (incorrectly) been treating the -second digit of the version as the major release number. So in my head -Rake was already at version 9. - -Well, it's time to fix things. This next version of Rake drops old, -crufty, backwards compatibility hacks such as top level constants, DSL -methods defined in Object and numerous other features that are just no -longer desired. It's also time to drop the leading zero from the -version number as well and call this new version of rake what it -really is: Version 10. - -So, welcome to Rake 10.0! - -Rake 10 is actually feature identical to the latest version of Rake 9 -(that would be the version spelled 0.9.3), *except* that Rake 10 drops -all the sundry deprecated features that have accumulated over the years. - -If your Rakefile is up to date and current with all the new features -of Rake 10, you are ready to go. If your Rakefile still uses a few -deprecated feeatures, feel free to use Rake 9 (0.9.3) with the same -feature set. Just be aware that future features will be in Rake 10 -family line. - -== Changes in Version 10 - -As mentioned above, there are no new features in Rake 10. However, -there are a number of features missing: - -* Classic namespaces are now gone. Rake is no longer able to reflect - the options settings in the global variables ($rakefile, $show_tasks, - $show_prereqs, $trace, $dryrun and $silent). The - --classic-namespace option is no longer supported. - -* Global constants are no longer supported. This includes - Task, FileTask, FileCreationTask and - RakeApp). The constant missing hook to warn about using - global rake constants has been removed. - -* The Rake DSL methods (task, file, directory, etc) are in their own - module (Rake::DSL). The stub versions of these methods (that printed - warnings) in Object have been removed. However, the DSL methods are - added to the top-level main object. Since main is - not in the inheritance tree, the presence of the DSL methods in main - should be low impact on other libraries. - - If you want to use the Rake DSL commands from your own code, just - include Rake::DSL into your own classes and modules. - -* The deprecated syntax for task arguments (the one using - :needs) has been removed. - -* The --reduce-compat flag has been removed (it's not needed - anymore). - -* The deprecated rake/sys.rb library has been removed. - -* The deprecated rake/rdoctask.rb library has been removed. - RDoc supplies its own rake task now. - -* The deprecated rake/gempackagetask.rb library has been - removed. Gem supplies its own package task now. - -There is one small behavioral change: - -* Non-file tasks now always report the current time as their time - stamp. This is different from the previous behavior where non-file - tasks reported current time only if there were no prerequisites, and - the max prerequisite timestamp otherwise. This lead to inconsistent - and surprising behavior when adding prerequisites to tasks that in - turn were prequisites to file tasks. The new behavior is more - consistent and predictable. - -== Changes (from 0.9.3, 0.9.4, 0.9.5) - -Since Rake 10 includes the changes from the last version of Rake 9, -we'll repeat the changes for versions 0.9.3 through 0.9.5 here. - -=== New Features (in 0.9.3) - -* Multitask tasks now use a thread pool. Use -j to limit the number of - available threads. - -* Use -m to turn regular tasks into multitasks (use at your own risk). - -* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to - programatically add rake task libraries. - -* You can specific backtrace suppression patterns (see - --supress-backtrace) - -* Directory tasks can now take prerequisites and actions - -* Use --backtrace to request a full backtrace without the task trace. - -* You can say "--backtrace=stdout" and "--trace=stdout" to route trace - output to standard output rather than standard error. - -* Optional 'phony' target (enable with 'require 'rake/phony'") for - special purpose builds. - -* Task#clear now clears task comments as well as actions and - prerequisites. Task#clear_comment will specifically target comments. - -* The --all option will force -T and -D to consider all the tasks, - with and without descriptions. - -=== Bug Fixes (in 0.9.3) - -* Semi-colons in windows rakefile paths now work. - -* Improved Control-C support when invoking multiple test suites. - -* egrep method now reads files in text mode (better support for - Windows) - -* Better deprecation line number reporting. - -* The -W option now works with all tasks, whether they have a - description or not. - -* File globs in rake should not be sorted alphabetically, independent - of file system and platform. - -* Numerous internal improvements. - -* Documentation typos and fixes. - -=== Bug Fixes (in 0.9.4) - -* Exit status with failing tests is not correctly set to non-zero. - -* Simplified syntax for phony task (for older versions of RDoc). - -* Stand alone FileList usage gets glob function (without loading in - extra dependencies) - -=== Bug Fixes (in 0.9.5) - -* --trace and --backtrace no longer swallow following task names. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://github.com/jimweirich/rake -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git - -== Thanks - -As usual, it was input from users that drove a lot of these changes. The -following people contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* Aaron Patterson -* Dylan Smith -* Jo Liss -* Jonas Pfenniger -* Kazuki Tsujimoto -* Michael Bishop -* Michael Elufimov -* NAKAMURA Usaku -* Ryan Davis -* Sam Grönblom -* Sam Phippen -* Sergio Wong -* Tay Ray Chuan -* grosser -* quix - -Also, many thanks to Eric Hodel for assisting with getting this release -out the door. - --- Jim Weirich diff --git a/doc/release_notes/rake-10.0.3.rdoc b/doc/release_notes/rake-10.0.3.rdoc deleted file mode 100644 index dbc84c1c1..000000000 --- a/doc/release_notes/rake-10.0.3.rdoc +++ /dev/null @@ -1,191 +0,0 @@ -= Rake 10.0.3 Released - - "Jim, when will Rake reach version 1.0?" - -Over the past several years I've been asked that question at -conferences, panels and over twitter. Due to historical reasons (or -maybe just plain laziness) Rake has (incorrectly) been treating the -second digit of the version as the major release number. So in my head -Rake was already at version 9. - -Well, it's time to fix things. This next version of Rake drops old, -crufty, backwards compatibility hacks such as top level constants, DSL -methods defined in Object and numerous other features that are just no -longer desired. It's also time to drop the leading zero from the -version number as well and call this new version of rake what it -really is: Version 10. - -So, welcome to Rake 10.0! - -Rake 10 is actually feature identical to the latest version of Rake 9 -(that would be the version spelled 0.9.3), *except* that Rake 10 drops -all the sundry deprecated features that have accumulated over the years. - -If your Rakefile is up to date and current with all the new features -of Rake 10, you are ready to go. If your Rakefile still uses a few -deprecated feeatures, feel free to use Rake 9 (0.9.3) with the same -feature set. Just be aware that future features will be in Rake 10 -family line. - -== Changes in Version 10 - -As mentioned above, there are no new features in Rake 10. However, -there are a number of features missing: - -* Classic namespaces are now gone. Rake is no longer able to reflect - the options settings in the global variables ($rakefile, $show_tasks, - $show_prereqs, $trace, $dryrun and $silent). The - --classic-namespace option is no longer supported. - -* Global constants are no longer supported. This includes - Task, FileTask, FileCreationTask and - RakeApp). The constant missing hook to warn about using - global rake constants has been removed. - -* The Rake DSL methods (task, file, directory, etc) are in their own - module (Rake::DSL). The stub versions of these methods (that printed - warnings) in Object have been removed. However, the DSL methods are - added to the top-level main object. Since main is - not in the inheritance tree, the presence of the DSL methods in main - should be low impact on other libraries. - - If you want to use the Rake DSL commands from your own code, just - include Rake::DSL into your own classes and modules. - -* The deprecated syntax for task arguments (the one using - :needs) has been removed. - -* The --reduce-compat flag has been removed (it's not needed - anymore). - -* The deprecated rake/sys.rb library has been removed. - -* The deprecated rake/rdoctask.rb library has been removed. - RDoc supplies its own rake task now. - -* The deprecated rake/gempackagetask.rb library has been - removed. Gem supplies its own package task now. - -There is one small behavioral change: - -* Non-file tasks now always report the current time as their time - stamp. This is different from the previous behavior where non-file - tasks reported current time only if there were no prerequisites, and - the max prerequisite timestamp otherwise. This lead to inconsistent - and surprising behavior when adding prerequisites to tasks that in - turn were prequisites to file tasks. The new behavior is more - consistent and predictable. - -== Changes (from 0.9.3, 0.9.4, 0.9.5) - -Since Rake 10 includes the changes from the last version of Rake 9, -we'll repeat the changes for versions 0.9.3 through 0.9.5 here. - -=== New Features (in 0.9.3) - -* Multitask tasks now use a thread pool. Use -j to limit the number of - available threads. - -* Use -m to turn regular tasks into multitasks (use at your own risk). - -* You can now do "Rake.add_rakelib 'dir'" in your Rakefile to - programatically add rake task libraries. - -* You can specific backtrace suppression patterns (see - --supress-backtrace) - -* Directory tasks can now take prerequisites and actions - -* Use --backtrace to request a full backtrace without the task trace. - -* You can say "--backtrace=stdout" and "--trace=stdout" to route trace - output to standard output rather than standard error. - -* Optional 'phony' target (enable with 'require 'rake/phony'") for - special purpose builds. - -* Task#clear now clears task comments as well as actions and - prerequisites. Task#clear_comment will specifically target comments. - -* The --all option will force -T and -D to consider all the tasks, - with and without descriptions. - -=== Bug Fixes (in 0.9.3) - -* Semi-colons in windows rakefile paths now work. - -* Improved Control-C support when invoking multiple test suites. - -* egrep method now reads files in text mode (better support for - Windows) - -* Better deprecation line number reporting. - -* The -W option now works with all tasks, whether they have a - description or not. - -* File globs in rake should not be sorted alphabetically, independent - of file system and platform. - -* Numerous internal improvements. - -* Documentation typos and fixes. - -=== Bug Fixes (in 0.9.4) - -* Exit status with failing tests is not correctly set to non-zero. - -* Simplified syntax for phony task (for older versions of RDoc). - -* Stand alone FileList usage gets glob function (without loading in - extra dependencies) - -=== Bug Fixes (in 0.9.5) - -* --trace and --backtrace no longer swallow following task names. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more traditional places: - -Home Page:: http://github.com/jimweirich/rake -Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git - -== Thanks - -As usual, it was input from users that drove a lot of these changes. The -following people contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* Aaron Patterson -* Dylan Smith -* Jo Liss -* Jonas Pfenniger -* Kazuki Tsujimoto -* Michael Bishop -* Michael Elufimov -* NAKAMURA Usaku -* Ryan Davis -* Sam Grönblom -* Sam Phippen -* Sergio Wong -* Tay Ray Chuan -* grosser -* quix - -Also, many thanks to Eric Hodel for assisting with getting this release -out the door. - --- Jim Weirich diff --git a/doc/release_notes/rake-10.1.0.rdoc b/doc/release_notes/rake-10.1.0.rdoc deleted file mode 100644 index 3c3d78a4f..000000000 --- a/doc/release_notes/rake-10.1.0.rdoc +++ /dev/null @@ -1,61 +0,0 @@ -= Rake 10.1.0 Released - -== Changes in Version 10.1 - -Here are new features in this version of Rake: - -* Add support for variable length task argument lists. If more actual - arguments are supplied than named arguments, then the extra - arguments values will be in args.extras. - -* Application name is not displayed in the help banner. (Previously - "rake" was hardcoded, now rake-based applications can display their - own names). - -=== Bug Fixes (in 10.1) - -Bug fixes include: - -* Fix backtrace suppression issues. - -* Rules now explicit get task arguments passed to them. - -* Rename FileList#exclude? to FileList#exclude_from_list? to avoid - conflict with new Rails method. - -* Clean / Clobber tasks now report failure to remove files. - -* Plus heaps of internal code cleanup. - -== What is Rake - -Rake is a build tool similar to the make program in many ways. But -instead of cryptic make recipes, Rake uses standard Ruby code to -declare tasks and dependencies. You have the full power of a modern -scripting language built right into your build tool. - -== Availability - -The easiest way to get and install rake is via RubyGems ... - - gem install rake (you may need root/admin privileges) - -Otherwise, you can get it from the more from GitHub: - -GitHub:: git://github.com/jimweirich/rake.git - -== Thanks - -As usual, it was input from users that drove a lot of these changes. -The following people contributed patches, made suggestions or made -otherwise helpful comments. Thanks to ... - -* Michael Nikitochkin (general code cleanup) -* Vipul A M (general code cleanup) -* Dennis Bell (variable length task argument lists) -* Jacob Swanner (rules arguments) -* Rafael Rosa Fu (documentation typo) -* Stuart Nelson (install.rb fixes) -* Lee Hambley (application name in help banner) - --- Jim Weirich diff --git a/exe/rake b/exe/rake new file mode 100755 index 000000000..a00975f30 --- /dev/null +++ b/exe/rake @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby + +#-- +# Copyright (c) 2003, 2004, 2005, 2006, 2007 Jim Weirich +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +#++ + +require "rake" + +Rake.application.run diff --git a/install.rb b/install.rb deleted file mode 100644 index 45946c198..000000000 --- a/install.rb +++ /dev/null @@ -1,80 +0,0 @@ -require 'rbconfig' -require 'find' -require 'fileutils' -require 'tempfile' - -include RbConfig - -$ruby = CONFIG['ruby_install_name'] - -## -# Install a binary file. We patch in on the way through to -# insert a #! line. If this is a Unix install, we name -# the command (for example) 'rake' and let the shebang line -# handle running it. Under windows, we add a '.rb' extension -# and let file associations do their stuff -# - -def installBIN(from, opfile) - - tmp_file = Tempfile.new("_tmp") - - File.open(from) do |ip| - File.open(tmp_file, "w") do |op| - ruby = File.join($realbindir, $ruby) - op.puts "#!#{ruby} -w" - op.write ip.read - end - end - - opfile += ".rb" if CONFIG["target_os"] =~ /mswin/i - FileUtils.install(tmp_file, File.join($bindir, opfile), - {:mode => 0755, :verbose => true}) - tmp_file.unlink -end - -$sitedir = CONFIG["sitelibdir"] -unless $sitedir - version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"] - $libdir = File.join(CONFIG["libdir"], "ruby", version) - $sitedir = $:.find {|x| x =~ /site_ruby/} - if !$sitedir - $sitedir = File.join($libdir, "site_ruby") - elsif $sitedir !~ Regexp.quote(version) - $sitedir = File.join($sitedir, version) - end -end - -$bindir = CONFIG["bindir"] - -$realbindir = $bindir - -if (destdir = ENV['DESTDIR']) - $bindir = destdir + $bindir - $sitedir = destdir + $sitedir - - FileUtils.mkdir_p($bindir) - FileUtils.mkdir_p($sitedir) -end - -rake_dest = File.join($sitedir, "rake") -FileUtils.mkdir_p(rake_dest, {:verbose => true}) -File.chmod(0755, rake_dest) - -# The library files - -files = Dir.chdir('lib') { Dir['**/*.rb'].sort } - -for fn in files - fn_dir = File.dirname(fn) - target_dir = File.join($sitedir, fn_dir) - if ! File.exist?(target_dir) - FileUtils.mkdir_p(target_dir) - end - FileUtils.install(File.join('lib', fn), File.join($sitedir, fn), - {:mode => 0644, :verbose => true}) -end - -# and the executable - -installBIN("bin/rake", "rake") diff --git a/lib/rake.rb b/lib/rake.rb index 531cfc82b..0dfd05315 100644 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -1,5 +1,5 @@ +# frozen_string_literal: true #-- - # Copyright 2003-2010 by Jim Weirich (jim.weirich@gmail.com) # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,47 +21,45 @@ # IN THE SOFTWARE. #++ -require 'rake/version' +module Rake; end -# :stopdoc: -RAKEVERSION = Rake::VERSION -# :startdoc: +require "rake/version" -require 'rbconfig' -require 'fileutils' -require 'singleton' -require 'monitor' -require 'optparse' -require 'ostruct' +require "rbconfig" +require "fileutils" +require "singleton" +require "monitor" +require "optparse" +require "ostruct" -require 'rake/ext/module' -require 'rake/ext/string' -require 'rake/ext/time' +require "rake/ext/string" -require 'rake/win32' +require "rake/win32" -require 'rake/linked_list' -require 'rake/scope' -require 'rake/task_argument_error' -require 'rake/rule_recursion_overflow_error' -require 'rake/rake_module' -require 'rake/trace_output' -require 'rake/pseudo_status' -require 'rake/task_arguments' -require 'rake/invocation_chain' -require 'rake/task' -require 'rake/file_task' -require 'rake/file_creation_task' -require 'rake/multi_task' -require 'rake/dsl_definition' -require 'rake/file_utils_ext' -require 'rake/file_list' -require 'rake/default_loader' -require 'rake/early_time' -require 'rake/name_space' -require 'rake/task_manager' -require 'rake/application' -require 'rake/backtrace' +require "rake/linked_list" +require "rake/cpu_counter" +require "rake/scope" +require "rake/task_argument_error" +require "rake/rule_recursion_overflow_error" +require "rake/rake_module" +require "rake/trace_output" +require "rake/pseudo_status" +require "rake/task_arguments" +require "rake/invocation_chain" +require "rake/task" +require "rake/file_task" +require "rake/file_creation_task" +require "rake/multi_task" +require "rake/dsl_definition" +require "rake/file_utils_ext" +require "rake/file_list" +require "rake/default_loader" +require "rake/early_time" +require "rake/late_time" +require "rake/name_space" +require "rake/task_manager" +require "rake/application" +require "rake/backtrace" $trace = false diff --git a/lib/rake/alt_system.rb b/lib/rake/alt_system.rb deleted file mode 100644 index a42597bf0..000000000 --- a/lib/rake/alt_system.rb +++ /dev/null @@ -1,108 +0,0 @@ -# -# Copyright (c) 2008 James M. Lawrence -# -# Permission is hereby granted, free of charge, to any person -# obtaining a copy of this software and associated documentation files -# (the "Software"), to deal in the Software without restriction, -# including without limitation the rights to use, copy, modify, merge, -# publish, distribute, sublicense, and/or sell copies of the Software, -# and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -require 'rbconfig' - -# -# Alternate implementations of system() and backticks `` on Windows -# for ruby-1.8 and earlier. -# -module Rake::AltSystem - WINDOWS = RbConfig::CONFIG["host_os"] =~ - %r!(msdos|mswin|djgpp|mingw|[Ww]indows)! - - class << self - def define_module_function(name, &block) - define_method(name, &block) - module_function(name) - end - end - - if WINDOWS && RUBY_VERSION < "1.9.0" - RUNNABLE_EXTS = %w[com exe bat cmd] - RUNNABLE_PATTERN = %r!\.(#{RUNNABLE_EXTS.join('|')})\Z!i - - define_module_function :kernel_system, &Kernel.method(:system) - define_module_function :kernel_backticks, &Kernel.method(:'`') - - module_function - - def repair_command(cmd) - "call " + ( - if cmd =~ %r!\A\s*\".*?\"! - # already quoted - cmd - elsif match = cmd.match(%r!\A\s*(\S+)!) - if match[1] =~ %r!/! - # avoid x/y.bat interpretation as x with option /y - %Q!"#{match[1]}"! + match.post_match - else - # a shell command will fail if quoted - cmd - end - else - # empty or whitespace - cmd - end - ) - end - - def find_runnable(file) - if file =~ RUNNABLE_PATTERN - file - else - RUNNABLE_EXTS.each { |ext| - test = "#{file}.#{ext}" - return test if File.exist?(test) - } - nil - end - end - - def system(cmd, *args) - repaired = ( - if args.empty? - [repair_command(cmd)] - elsif runnable = find_runnable(cmd) - [File.expand_path(runnable), *args] - else - # non-existent file - [cmd, *args] - end - ) - kernel_system(*repaired) - end - - def backticks(cmd) - kernel_backticks(repair_command(cmd)) - end - - define_module_function :'`', &method(:backticks) - else - # Non-Windows or ruby-1.9+: same as Kernel versions - define_module_function :system, &Kernel.method(:system) - define_module_function :backticks, &Kernel.method(:'`') - define_module_function :'`', &Kernel.method(:'`') - end -end diff --git a/lib/rake/application.rb b/lib/rake/application.rb index b76244b7a..9ac9b2130 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -1,21 +1,21 @@ -require 'shellwords' -require 'optparse' +# frozen_string_literal: true +require "optparse" -require 'rake/task_manager' -require 'rake/file_list' -require 'rake/thread_pool' -require 'rake/thread_history_display' -require 'rake/trace_output' -require 'rake/win32' +require "rake/task_manager" +require "rake/file_list" +require "rake/thread_pool" +require "rake/thread_history_display" +require "rake/trace_output" +require "rake/win32" module Rake CommandLineOptionError = Class.new(StandardError) - ###################################################################### + ## # Rake main application object. When invoking +rake+ from the # command line, a Rake::Application object is created and run. - # + class Application include TaskManager include TraceOutput @@ -35,17 +35,20 @@ class Application # List of the top level task names (task names from the command line). attr_reader :top_level_tasks + # Override the detected TTY output state (mostly for testing) + attr_writer :tty_output + DEFAULT_RAKEFILES = [ - 'rakefile', - 'Rakefile', - 'rakefile.rb', - 'Rakefile.rb' + "rakefile", + "Rakefile", + "rakefile.rb", + "Rakefile.rb" ].freeze # Initialize a Rake::Application object. def initialize super - @name = 'rake' + @name = "rake" @rakefiles = DEFAULT_RAKEFILES.dup @rakefile = nil @pending_imports = [] @@ -54,11 +57,13 @@ def initialize @default_loader = Rake::DefaultLoader.new @original_dir = Dir.pwd @top_level_tasks = [] - add_loader('rb', DefaultLoader.new) - add_loader('rf', DefaultLoader.new) - add_loader('rake', DefaultLoader.new) + add_loader("rb", DefaultLoader.new) + add_loader("rf", DefaultLoader.new) + add_loader("rake", DefaultLoader.new) @tty_output = STDOUT.tty? - @terminal_columns = ENV['RAKE_COLUMNS'].to_i + @terminal_columns = ENV["RAKE_COLUMNS"].to_i + + set_default_options end # Run the Rake application. The run method performs the following @@ -71,20 +76,25 @@ def initialize # If you wish to build a custom rake command, you should call # +init+ on your application. Then define any tasks. Finally, # call +top_level+ to run your top level tasks. - def run + def run(argv = ARGV) standard_exception_handling do - init + init "rake", argv load_rakefile top_level end end # Initialize the command line parameters and app name. - def init(app_name='rake') + def init(app_name="rake", argv = ARGV) standard_exception_handling do @name = app_name - handle_options - collect_tasks + begin + args = handle_options argv + rescue ArgumentError + # Backward compatibility for capistrano + args = handle_options + end + collect_command_line_tasks(args) end end @@ -117,8 +127,8 @@ def run_with_threads thread_pool.join if options.job_stats stats = thread_pool.statistics - puts "Maximum active threads: #{stats[:max_active_threads]}" - puts "Total threads in play: #{stats[:total_threads_in_play]}" + puts "Maximum active threads: #{stats[:max_active_threads]} + main" + puts "Total threads in play: #{stats[:total_threads_in_play]} + main" end ThreadHistoryDisplay.new(thread_pool.history).show if options.job_stats == :history @@ -138,30 +148,41 @@ def options # Return the thread pool used for multithreaded processing. def thread_pool # :nodoc: - @thread_pool ||= ThreadPool.new(options.thread_pool_size || FIXNUM_MAX) + @thread_pool ||= ThreadPool.new(options.thread_pool_size || Rake.suggested_thread_count-1) end - # private ---------------------------------------------------------------- + # internal ---------------------------------------------------------------- - def invoke_task(task_string) + # Invokes a task with arguments that are extracted from +task_string+ + def invoke_task(task_string) # :nodoc: name, args = parse_task_string(task_string) t = self[name] t.invoke(*args) end - def parse_task_string(string) - if string =~ /^([^\[]+)(\[(.*)\])$/ - name = $1 - args = $3.split(/\s*,\s*/) - else - name = string - args = [] - end - [name, args] + def parse_task_string(string) # :nodoc: + /^([^\[]+)(?:\[(.*)\])$/ =~ string.to_s + + name = $1 + remaining_args = $2 + + return string, [] unless name + return name, [] if remaining_args.empty? + + args = [] + + begin + /\s*((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args + + remaining_args = $2 + args << $1.gsub(/\\(.)/, '\1') + end while remaining_args + + return name, args end # Provide standard exception handling for the given block. - def standard_exception_handling + def standard_exception_handling # :nodoc: yield rescue SystemExit # Exit silently with current status @@ -175,24 +196,58 @@ def standard_exception_handling exit_because_of_exception(ex) end - # Exit the program because of an unhandle exception. + # Exit the program because of an unhandled exception. # (may be overridden by subclasses) - def exit_because_of_exception(ex) + def exit_because_of_exception(ex) # :nodoc: exit(false) end # Display the error message that caused the exception. - def display_error_message(ex) + def display_error_message(ex) # :nodoc: trace "#{name} aborted!" - trace ex.message + display_exception_details(ex) + trace "Tasks: #{ex.chain}" if has_chain?(ex) + trace "(See full trace by running task with --trace)" unless + options.backtrace + end + + def display_exception_details(ex) # :nodoc: + display_exception_details_seen << ex + + display_exception_message_details(ex) + display_exception_backtrace(ex) + display_cause_details(ex.cause) if has_cause?(ex) + end + + def display_cause_details(ex) # :nodoc: + return if display_exception_details_seen.include? ex + + trace "\nCaused by:" + display_exception_details(ex) + end + + def display_exception_details_seen # :nodoc: + Thread.current[:rake_display_exception_details_seen] ||= [] + end + + def has_cause?(ex) # :nodoc: + ex.respond_to?(:cause) && ex.cause + end + + def display_exception_message_details(ex) # :nodoc: + if ex.instance_of?(RuntimeError) + trace ex.message + else + trace "#{ex.class.name}: #{ex.message}" + end + end + + def display_exception_backtrace(ex) # :nodoc: if options.backtrace trace ex.backtrace.join("\n") else trace Backtrace.collapse(ex.backtrace).join("\n") end - trace "Tasks: #{ex.chain}" if has_chain?(ex) - trace "(See full trace by running task with --trace)" unless - options.backtrace end # Warn about deprecated usage. @@ -200,7 +255,7 @@ def display_error_message(ex) # Example: # Rake.application.deprecate("import", "Rake.import", caller.first) # - def deprecate(old_usage, new_usage, call_site) + def deprecate(old_usage, new_usage, call_site) # :nodoc: unless options.ignore_deprecate $stderr.puts "WARNING: '#{old_usage}' is deprecated. " + "Please use '#{new_usage}' instead.\n" + @@ -209,19 +264,19 @@ def deprecate(old_usage, new_usage, call_site) end # Does the exception have a task invocation chain? - def has_chain?(exception) + def has_chain?(exception) # :nodoc: exception.respond_to?(:chain) && exception.chain end private :has_chain? # True if one of the files in RAKEFILES is in the current directory. # If a match is found, it is copied into @rakefile. - def have_rakefile + def have_rakefile # :nodoc: @rakefiles.each do |fn| if File.exist?(fn) others = FileList.glob(fn, File::FNM_CASEFOLD) return others.size == 1 ? others.first : fn - elsif fn == '' + elsif fn == "" return fn end end @@ -229,23 +284,18 @@ def have_rakefile end # True if we are outputting to TTY, false otherwise - def tty_output? + def tty_output? # :nodoc: @tty_output end - # Override the detected TTY output state (mostly for testing) - def tty_output=(tty_output_state) - @tty_output = tty_output_state - end - # We will truncate output if we are outputting to a TTY or if we've been # given an explicit column width to honor - def truncate_output? + def truncate_output? # :nodoc: tty_output? || @terminal_columns.nonzero? end # Display the tasks and comments. - def display_tasks_and_comments + def display_tasks_and_comments # :nodoc: displayable_tasks = tasks.select { |t| (options.show_all_tasks || t.comment) && t.name =~ options.show_task_pattern @@ -284,7 +334,7 @@ def display_tasks_and_comments end end - def terminal_width + def terminal_width # :nodoc: if @terminal_columns.nonzero? result = @terminal_columns else @@ -296,28 +346,28 @@ def terminal_width end # Calculate the dynamic width of the - def dynamic_width + def dynamic_width # :nodoc: @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput) end - def dynamic_width_stty + def dynamic_width_stty # :nodoc: %x{stty size 2>/dev/null}.split[1].to_i end - def dynamic_width_tput + def dynamic_width_tput # :nodoc: %x{tput cols 2>/dev/null}.to_i end - def unix? - RbConfig::CONFIG['host_os'] =~ + def unix? # :nodoc: + RbConfig::CONFIG["host_os"] =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i end - def windows? + def windows? # :nodoc: Win32.windows? end - def truncate(string, width) + def truncate(string, width) # :nodoc: if string.nil? "" elsif string.length <= width @@ -328,56 +378,62 @@ def truncate(string, width) end # Display the tasks and prerequisites - def display_prerequisites + def display_prerequisites # :nodoc: tasks.each do |t| puts "#{name} #{t.name}" t.prerequisites.each { |pre| puts " #{pre}" } end end - def trace(*strings) + def trace(*strings) # :nodoc: options.trace_output ||= $stderr trace_on(options.trace_output, *strings) end - def sort_options(options) + def sort_options(options) # :nodoc: options.sort_by { |opt| - opt.select { |o| o =~ /^-/ }.map { |o| o.downcase }.sort.reverse + opt.select { |o| o.is_a?(String) && o =~ /^-/ }.map(&:downcase).sort.reverse } end private :sort_options # A list of all the standard options used in rake, suitable for # passing to OptionParser. - def standard_rake_options + def standard_rake_options # :nodoc: sort_options( [ - ['--all', '-A', - "Show all tasks, even uncommented ones", + ["--all", "-A", + "Show all tasks, even uncommented ones (in combination with -T or -D)", lambda { |value| options.show_all_tasks = value } ], - ['--backtrace=[OUT]', + ["--backtrace=[OUT]", "Enable full backtrace. OUT can be stderr (default) or stdout.", lambda { |value| options.backtrace = true - select_trace_output(options, 'backtrace', value) + select_trace_output(options, "backtrace", value) } ], - ['--comments', + ["--build-all", "-B", + "Build all prerequisites, including those which are up-to-date.", + lambda { |value| + options.build_all = true + } + ], + ["--comments", "Show commented tasks only", lambda { |value| options.show_all_tasks = !value } ], - ['--describe', '-D [PATTERN]', + ["--describe", "-D [PATTERN]", "Describe the tasks (matching optional PATTERN), then exit.", lambda { |value| select_tasks_to_show(options, :describe, value) } ], - ['--dry-run', '-n', + ["--dry-run", "-n", "Do a dry run without executing actions.", lambda { |value| Rake.verbose(true) @@ -386,33 +442,41 @@ def standard_rake_options options.trace = true } ], - ['--execute', '-e CODE', + ["--execute", "-e CODE", "Execute some Ruby code and exit.", lambda { |value| eval(value) exit } ], - ['--execute-print', '-p CODE', + ["--execute-print", "-p CODE", "Execute some Ruby code, print the result, then exit.", lambda { |value| puts eval(value) exit } ], - ['--execute-continue', '-E CODE', + ["--execute-continue", "-E CODE", "Execute some Ruby code, " + "then continue with normal task processing.", lambda { |value| eval(value) } ], - ['--jobs', '-j [NUMBER]', + ["--jobs", "-j [NUMBER]", "Specifies the maximum number of tasks to execute in parallel. " + - "(default is 2)", + "(default is number of CPU cores + 4)", lambda { |value| - options.thread_pool_size = [(value || 2).to_i, 2].max + if value.nil? || value == "" + value = Float::INFINITY + elsif value =~ /^\d+$/ + value = value.to_i + else + value = Rake.suggested_thread_count + end + value = 1 if value < 1 + options.thread_pool_size = value - 1 } ], - ['--job-stats [LEVEL]', + ["--job-stats [LEVEL]", "Display job statistics. " + "LEVEL=history displays a complete job list", lambda { |value| @@ -423,42 +487,42 @@ def standard_rake_options end } ], - ['--libdir', '-I LIBDIR', + ["--libdir", "-I LIBDIR", "Include LIBDIR in the search path for required modules.", lambda { |value| $:.push(value) } ], - ['--multitask', '-m', + ["--multitask", "-m", "Treat all tasks as multitasks.", lambda { |value| options.always_multitask = true } ], - ['--no-search', '--nosearch', - '-N', "Do not search parent directories for the Rakefile.", + ["--no-search", "--nosearch", + "-N", "Do not search parent directories for the Rakefile.", lambda { |value| options.nosearch = true } ], - ['--prereqs', '-P', + ["--prereqs", "-P", "Display the tasks and dependencies, then exit.", lambda { |value| options.show_prereqs = true } ], - ['--quiet', '-q', + ["--quiet", "-q", "Do not log messages to standard output.", lambda { |value| Rake.verbose(false) } ], - ['--rakefile', '-f [FILE]', - "Use FILE as the rakefile.", + ["--rakefile", "-f [FILENAME]", + "Use FILENAME as the rakefile to search for.", lambda { |value| - value ||= '' + value ||= "" @rakefiles.clear @rakefiles << value } ], - ['--rakelibdir', '--rakelib', '-R RAKELIBDIR', + ["--rakelibdir", "--rakelib", "-R RAKELIBDIR", "Auto-import any .rake files in RAKELIBDIR. " + "(default is 'rakelib')", lambda { |value| options.rakelib = value.split(File::PATH_SEPARATOR) } ], - ['--require', '-r MODULE', + ["--require", "-r MODULE", "Require MODULE before executing rakefile.", lambda { |value| begin @@ -472,11 +536,11 @@ def standard_rake_options end } ], - ['--rules', + ["--rules", "Trace the rules resolution.", lambda { |value| options.trace_rules = true } ], - ['--silent', '-s', + ["--silent", "-s", "Like --quiet, but also suppresses the " + "'in directory' announcement.", lambda { |value| @@ -484,59 +548,60 @@ def standard_rake_options options.silent = true } ], - ['--suppress-backtrace PATTERN', + ["--suppress-backtrace PATTERN", "Suppress backtrace lines matching regexp PATTERN. " + "Ignored if --trace is on.", lambda { |value| options.suppress_backtrace_pattern = Regexp.new(value) } ], - ['--system', '-g', + ["--system", "-g", "Using system wide (global) rakefiles " + "(usually '~/.rake/*.rake').", lambda { |value| options.load_system = true } ], - ['--no-system', '--nosystem', '-G', + ["--no-system", "--nosystem", "-G", "Use standard project Rakefile search paths, " + "ignore system wide rakefiles.", lambda { |value| options.ignore_system = true } ], - ['--tasks', '-T [PATTERN]', + ["--tasks", "-T [PATTERN]", "Display the tasks (matching optional PATTERN) " + - "with descriptions, then exit.", + "with descriptions, then exit. " + + "-AT combination displays all of tasks contained no description.", lambda { |value| select_tasks_to_show(options, :tasks, value) } ], - ['--trace=[OUT]', '-t', + ["--trace=[OUT]", "-t", "Turn on invoke/execute tracing, enable full backtrace. " + "OUT can be stderr (default) or stdout.", lambda { |value| options.trace = true options.backtrace = true - select_trace_output(options, 'trace', value) + select_trace_output(options, "trace", value) Rake.verbose(true) } ], - ['--verbose', '-v', + ["--verbose", "-v", "Log message to standard output.", lambda { |value| Rake.verbose(true) } ], - ['--version', '-V', + ["--version", "-V", "Display the program version.", lambda { |value| - puts "rake, version #{RAKEVERSION}" + puts "rake, version #{Rake::VERSION}" exit } ], - ['--where', '-W [PATTERN]', + ["--where", "-W [PATTERN]", "Describe the tasks (matching optional PATTERN), then exit.", lambda { |value| select_tasks_to_show(options, :lines, value) options.show_all_tasks = true } ], - ['--no-deprecation-warnings', '-X', + ["--no-deprecation-warnings", "-X", "Disable the deprecation warnings.", lambda { |value| options.ignore_deprecate = true @@ -545,19 +610,19 @@ def standard_rake_options ]) end - def select_tasks_to_show(options, show_tasks, value) + def select_tasks_to_show(options, show_tasks, value) # :nodoc: options.show_tasks = show_tasks - options.show_task_pattern = Regexp.new(value || '') + options.show_task_pattern = Regexp.new(value || "") Rake::TaskManager.record_task_metadata = true end private :select_tasks_to_show - def select_trace_output(options, trace_option, value) + def select_trace_output(options, trace_option, value) # :nodoc: value = value.strip unless value.nil? case value - when 'stdout' + when "stdout" options.trace_output = $stdout - when 'stderr', nil + when "stderr", nil options.trace_output = $stderr else fail CommandLineOptionError, @@ -566,10 +631,11 @@ def select_trace_output(options, trace_option, value) end private :select_trace_output - # Read and handle the command line options. - def handle_options - options.rakelib = ['rakelib'] - options.trace_output = $stderr + # Read and handle the command line options. Returns the command line + # arguments that we didn't understand, which should (in theory) be just + # task names and env vars. + def handle_options(argv) # :nodoc: + set_default_options OptionParser.new do |opts| opts.banner = "#{Rake.application.name} [-f rakefile] {options} targets..." @@ -582,13 +648,13 @@ def handle_options end standard_rake_options.each { |args| opts.on(*args) } - opts.environment('RAKEOPT') - end.parse! + opts.environment("RAKEOPT") + end.parse(argv) end # Similar to the regular Ruby +require+ command, but will check # for *.rake files in addition to *.rb files. - def rake_require(file_name, paths=$LOAD_PATH, loaded=$") + def rake_require(file_name, paths=$LOAD_PATH, loaded=$") # :nodoc: fn = file_name + ".rake" return false if loaded.include?(fn) paths.each do |path| @@ -602,7 +668,7 @@ def rake_require(file_name, paths=$LOAD_PATH, loaded=$") fail LoadError, "Can't find #{file_name}" end - def find_rakefile_location + def find_rakefile_location # :nodoc: here = Dir.pwd until (fn = have_rakefile) Dir.chdir("..") @@ -614,14 +680,14 @@ def find_rakefile_location Dir.chdir(Rake.original_dir) end - def print_rakefile_directory(location) + def print_rakefile_directory(location) # :nodoc: $stderr.puts "(in #{Dir.pwd})" unless options.silent or original_dir == location end def raw_load_rakefile # :nodoc: rakefile, location = find_rakefile_location - if (! options.ignore_system) && + if (!options.ignore_system) && (options.load_system || rakefile.nil?) && system_dir && File.directory?(system_dir) print_rakefile_directory(location) @@ -635,7 +701,7 @@ def raw_load_rakefile # :nodoc: Dir.chdir(location) print_rakefile_directory(location) Rake.load_rakefile(File.expand_path(@rakefile)) if - @rakefile && @rakefile != '' + @rakefile && @rakefile != "" options.rakelib.each do |rlib| glob("#{rlib}/*.rake") do |name| add_import name @@ -645,17 +711,17 @@ def raw_load_rakefile # :nodoc: load_imports end - def glob(path, &block) - FileList.glob(path.gsub("\\", '/')).each(&block) + def glob(path, &block) # :nodoc: + FileList.glob(path.tr("\\", "/")).each(&block) end private :glob # The directory path containing the system wide rakefiles. - def system_dir + def system_dir # :nodoc: @system_dir ||= begin - if ENV['RAKE_SYSTEM'] - ENV['RAKE_SYSTEM'] + if ENV["RAKE_SYSTEM"] + ENV["RAKE_SYSTEM"] else standard_system_dir end @@ -669,7 +735,7 @@ def standard_system_dir #:nodoc: end else def standard_system_dir #:nodoc: - File.join(File.expand_path('~'), '.rake') + File.join(File.expand_path("~"), ".rake") end end private :standard_system_dir @@ -677,9 +743,14 @@ def standard_system_dir #:nodoc: # Collect the list of tasks on the command line. If no tasks are # given, return a list containing only the default task. # Environmental assignments are processed at this time as well. - def collect_tasks + # + # `args` is the list of arguments to peruse to get the list of tasks. + # It should be the command line that was given to rake, less any + # recognised command-line options, which OptionParser.parse will + # have taken care of already. + def collect_command_line_tasks(args) # :nodoc: @top_level_tasks = [] - ARGV.each do |arg| + args.each do |arg| if arg =~ /^(\w+)=(.*)$/m ENV[$1] = $2 else @@ -691,38 +762,63 @@ def collect_tasks # Default task name ("default"). # (May be overridden by subclasses) - def default_task_name + def default_task_name # :nodoc: "default" end # Add a file to the list of files to be imported. - def add_import(fn) + def add_import(fn) # :nodoc: @pending_imports << fn end # Load the pending list of imported files. - def load_imports + def load_imports # :nodoc: while fn = @pending_imports.shift next if @imported.member?(fn) fn_task = lookup(fn) and fn_task.invoke ext = File.extname(fn) loader = @loaders[ext] || @default_loader loader.load(fn) + if fn_task = lookup(fn) and fn_task.needed? + fn_task.reenable + fn_task.invoke + loader.load(fn) + end @imported << fn end end - def rakefile_location(backtrace=caller) + def rakefile_location(backtrace=caller) # :nodoc: backtrace.map { |t| t[/([^:]+):/, 1] } re = /^#{@rakefile}$/ re = /#{re.source}/i if windows? - backtrace.find { |str| str =~ re } || '' + backtrace.find { |str| str =~ re } || "" + end + + def set_default_options # :nodoc: + options.always_multitask = false + options.backtrace = false + options.build_all = false + options.dryrun = false + options.ignore_deprecate = false + options.ignore_system = false + options.job_stats = false + options.load_system = false + options.nosearch = false + options.rakelib = %w[rakelib] + options.show_all_tasks = false + options.show_prereqs = false + options.show_task_pattern = nil + options.show_tasks = nil + options.silent = false + options.suppress_backtrace_pattern = nil + options.thread_pool_size = Rake.suggested_thread_count + options.trace = false + options.trace_output = $stderr + options.trace_rules = false end - private - FIXNUM_MAX = (2**(0.size * 8 - 2) - 1) # :nodoc: - end end diff --git a/lib/rake/backtrace.rb b/lib/rake/backtrace.rb index 9b2ba6157..31ff05450 100644 --- a/lib/rake/backtrace.rb +++ b/lib/rake/backtrace.rb @@ -1,14 +1,18 @@ +# frozen_string_literal: true module Rake - module Backtrace - SYS_KEYS = RbConfig::CONFIG.keys.grep(/(prefix|libdir)/) + module Backtrace # :nodoc: all + SYS_KEYS = RbConfig::CONFIG.keys.grep(/(?:[a-z]prefix|libdir)\z/) SYS_PATHS = RbConfig::CONFIG.values_at(*SYS_KEYS).uniq + [ File.join(File.dirname(__FILE__), "..") ] SUPPRESSED_PATHS = SYS_PATHS. - map { |s| s.gsub("\\", "/") }. + map { |s| s.tr("\\", "/") }. map { |f| File.expand_path(f) }. reject { |s| s.nil? || s =~ /^ *$/ } SUPPRESSED_PATHS_RE = SUPPRESSED_PATHS.map { |f| Regexp.quote(f) }.join("|") + SUPPRESSED_PATHS_RE << "|^org\\/jruby\\/\\w+\\.java" if + Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == "jruby" + SUPPRESS_PATTERN = %r!(\A(#{SUPPRESSED_PATHS_RE})|bin/rake:\d+)!i def self.collapse(backtrace) diff --git a/lib/rake/clean.rb b/lib/rake/clean.rb index 8001ce569..b52e832a9 100644 --- a/lib/rake/clean.rb +++ b/lib/rake/clean.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # The 'rake/clean' file defines two file lists (CLEAN and CLOBBER) and # two rake tasks (:clean and :clobber). # @@ -11,7 +12,7 @@ # The intent of this task is to return a project to its # pristine, just unpacked state. -require 'rake' +require "rake" # :stopdoc: @@ -27,19 +28,41 @@ def cleanup_files(file_names) end end - def cleanup(file_name, opts={}) + def cleanup(file_name, **opts) begin - rm_r file_name, opts + opts = { verbose: Rake.application.options.trace }.merge(opts) + rm_r file_name, **opts rescue StandardError => ex - puts "Failed to remove #{file_name}: #{ex}" + puts "Failed to remove #{file_name}: #{ex}" unless file_already_gone?(file_name) end end + + def file_already_gone?(file_name) + return false if File.exist?(file_name) + + path = file_name + prev = nil + + while path = File.dirname(path) + return false if cant_be_deleted?(path) + break if [prev, "."].include?(path) + prev = path + end + true + end + private_class_method :file_already_gone? + + def cant_be_deleted?(path_name) + File.exist?(path_name) && + (!File.readable?(path_name) || !File.executable?(path_name)) + end + private_class_method :cant_be_deleted? end end CLEAN = ::Rake::FileList["**/*~", "**/*.bak", "**/core"] CLEAN.clear_exclude.exclude { |fn| - fn.pathmap("%f").downcase == 'core' && File.directory?(fn) + fn.pathmap("%f").downcase == "core" && File.directory?(fn) } desc "Remove any temporary products." @@ -49,7 +72,7 @@ def cleanup(file_name, opts={}) CLOBBER = ::Rake::FileList.new -desc "Remove any generated file." -task :clobber => [:clean] do +desc "Remove any generated files." +task clobber: [:clean] do Rake::Cleaner.cleanup_files(CLOBBER) end diff --git a/lib/rake/cloneable.rb b/lib/rake/cloneable.rb index ac6747123..eddb77e2f 100644 --- a/lib/rake/cloneable.rb +++ b/lib/rake/cloneable.rb @@ -1,9 +1,10 @@ +# frozen_string_literal: true module Rake - # ########################################################################## + ## # Mixin for creating easily cloned objects. - # - module Cloneable - # The hook that invoked by 'clone' and 'dup' methods. + + module Cloneable # :nodoc: + # The hook that is invoked by 'clone' and 'dup' methods. def initialize_copy(source) super source.instance_variables.each do |var| diff --git a/lib/rake/contrib/compositepublisher.rb b/lib/rake/contrib/compositepublisher.rb deleted file mode 100644 index 69952a080..000000000 --- a/lib/rake/contrib/compositepublisher.rb +++ /dev/null @@ -1,21 +0,0 @@ -module Rake - - # Manage several publishers as a single entity. - class CompositePublisher - def initialize - @publishers = [] - end - - # Add a publisher to the composite. - def add(pub) - @publishers << pub - end - - # Upload all the individual publishers. - def upload - @publishers.each { |p| p.upload } - end - end - -end - diff --git a/lib/rake/contrib/ftptools.rb b/lib/rake/contrib/ftptools.rb deleted file mode 100644 index 0dd50fdc8..000000000 --- a/lib/rake/contrib/ftptools.rb +++ /dev/null @@ -1,139 +0,0 @@ -# = Tools for FTP uploading. -# -# This file is still under development and is not released for general -# use. - -require 'date' -require 'net/ftp' -require 'rake/file_list' - -module Rake # :nodoc: - - #################################################################### - # Note: Not released for general use. - class FtpFile - attr_reader :name, :size, :owner, :group, :time - - def self.date - @date_class ||= Date - end - - def self.time - @time_class ||= Time - end - - def initialize(path, entry) - @path = path - @mode, _, @owner, @group, size, d1, d2, d3, @name = entry.split(' ') - @size = size.to_i - @time = determine_time(d1, d2, d3) - end - - def path - File.join(@path, @name) - end - - def directory? - @mode[0] == ?d - end - - def mode - parse_mode(@mode) - end - - def symlink? - @mode[0] == ?l - end - - private # -------------------------------------------------------- - - def parse_mode(m) - result = 0 - (1..9).each do |i| - result = 2 * result + ((m[i] == ?-) ? 0 : 1) - end - result - end - - def determine_time(d1, d2, d3) - now = self.class.time.now - if /:/ !~ d3 - result = Time.parse("#{d1} #{d2} #{d3}") - else - result = Time.parse("#{d1} #{d2} #{now.year} #{d3}") - result = Time.parse("#{d1} #{d2} #{now.year - 1} #{d3}") if - result > now - end - result - end - end - - #################################################################### - # Manage the uploading of files to an FTP account. - class FtpUploader - - # Log uploads to standard output when true. - attr_accessor :verbose - - class << FtpUploader - # Create an uploader and pass it to the given block as +up+. - # When the block is complete, close the uploader. - def connect(path, host, account, password) - up = self.new(path, host, account, password) - begin - yield(up) - ensure - up.close - end - end - end - - # Create an FTP uploader targeting the directory +path+ on +host+ - # using the given account and password. +path+ will be the root - # path of the uploader. - def initialize(path, host, account, password) - @created = Hash.new - @path = path - @ftp = Net::FTP.new(host, account, password) - makedirs(@path) - @ftp.chdir(@path) - end - - # Create the directory +path+ in the uploader root path. - def makedirs(path) - route = [] - File.split(path).each do |dir| - route << dir - current_dir = File.join(route) - if @created[current_dir].nil? - @created[current_dir] = true - $stderr.puts "Creating Directory #{current_dir}" if @verbose - @ftp.mkdir(current_dir) rescue nil - end - end - end - - # Upload all files matching +wildcard+ to the uploader's root - # path. - def upload_files(wildcard) - FileList.glob(wildcard).each do |fn| - upload(fn) - end - end - - # Close the uploader. - def close - @ftp.close - end - - private # -------------------------------------------------------- - - # Upload a single file to the uploader's root path. - def upload(file) - $stderr.puts "Uploading #{file}" if @verbose - dir = File.dirname(file) - makedirs(dir) - @ftp.putbinaryfile(file, file) unless File.directory?(file) - end - end -end diff --git a/lib/rake/contrib/publisher.rb b/lib/rake/contrib/publisher.rb deleted file mode 100644 index 8b11edb59..000000000 --- a/lib/rake/contrib/publisher.rb +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright 2003-2010 by Jim Weirich (jim.weirich@gmail.com) -# All rights reserved. - -# :stopdoc: - -# Configuration information about an upload host system. -# name :: Name of host system. -# webdir :: Base directory for the web information for the -# application. The application name (APP) is appended to -# this directory before using. -# pkgdir :: Directory on the host system where packages can be -# placed. -HostInfo = Struct.new(:name, :webdir, :pkgdir) - -# :startdoc: - -# Manage several publishers as a single entity. -class CompositePublisher - def initialize - @publishers = [] - end - - # Add a publisher to the composite. - def add(pub) - @publishers << pub - end - - # Upload all the individual publishers. - def upload - @publishers.each { |p| p.upload } - end -end - -# Publish an entire directory to an existing remote directory using -# SSH. -class SshDirPublisher - def initialize(host, remote_dir, local_dir) - @host = host - @remote_dir = remote_dir - @local_dir = local_dir - end - - def upload - run %{scp -rq #{@local_dir}/* #{@host}:#{@remote_dir}} - end -end - -# Publish an entire directory to a fresh remote directory using SSH. -class SshFreshDirPublisher < SshDirPublisher - def upload - run %{ssh #{@host} rm -rf #{@remote_dir}} rescue nil - run %{ssh #{@host} mkdir #{@remote_dir}} - super - end -end - -# Publish a list of files to an existing remote directory. -class SshFilePublisher - # Create a publisher using the give host information. - def initialize(host, remote_dir, local_dir, *files) - @host = host - @remote_dir = remote_dir - @local_dir = local_dir - @files = files - end - - # Upload the local directory to the remote directory. - def upload - @files.each do |fn| - run %{scp -q #{@local_dir}/#{fn} #{@host}:#{@remote_dir}} - end - end -end diff --git a/lib/rake/contrib/rubyforgepublisher.rb b/lib/rake/contrib/rubyforgepublisher.rb deleted file mode 100644 index a4b96936c..000000000 --- a/lib/rake/contrib/rubyforgepublisher.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'rake/contrib/sshpublisher' - -module Rake - - class RubyForgePublisher < SshDirPublisher - attr_reader :project, :proj_id, :user - - def initialize(projname, user) - super( - "#{user}@rubyforge.org", - "/var/www/gforge-projects/#{projname}", - "html") - end - end - -end diff --git a/lib/rake/contrib/sshpublisher.rb b/lib/rake/contrib/sshpublisher.rb deleted file mode 100644 index bd6adc127..000000000 --- a/lib/rake/contrib/sshpublisher.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'rake/dsl_definition' -require 'rake/contrib/compositepublisher' - -module Rake - - # Publish an entire directory to an existing remote directory using - # SSH. - class SshDirPublisher - include Rake::DSL - - def initialize(host, remote_dir, local_dir) - @host = host - @remote_dir = remote_dir - @local_dir = local_dir - end - - def upload - sh %{scp -rq #{@local_dir}/* #{@host}:#{@remote_dir}} - end - end - - # Publish an entire directory to a fresh remote directory using SSH. - class SshFreshDirPublisher < SshDirPublisher - def upload - sh %{ssh #{@host} rm -rf #{@remote_dir}} rescue nil - sh %{ssh #{@host} mkdir #{@remote_dir}} - super - end - end - - # Publish a list of files to an existing remote directory. - class SshFilePublisher - include Rake::DSL - - # Create a publisher using the give host information. - def initialize(host, remote_dir, local_dir, *files) - @host = host - @remote_dir = remote_dir - @local_dir = local_dir - @files = files - end - - # Upload the local directory to the remote directory. - def upload - @files.each do |fn| - sh %{scp -q #{@local_dir}/#{fn} #{@host}:#{@remote_dir}} - end - end - end -end diff --git a/lib/rake/contrib/sys.rb b/lib/rake/contrib/sys.rb deleted file mode 100644 index a3a9f69e2..000000000 --- a/lib/rake/contrib/sys.rb +++ /dev/null @@ -1,2 +0,0 @@ -fail "ERROR: 'rake/contrib/sys' is obsolete and no longer supported. " + - "Use 'FileUtils' instead." diff --git a/lib/rake/cpu_counter.rb b/lib/rake/cpu_counter.rb new file mode 100644 index 000000000..564a62859 --- /dev/null +++ b/lib/rake/cpu_counter.rb @@ -0,0 +1,107 @@ +# frozen_string_literal: true +module Rake + + # Based on a script at: + # http://stackoverflow.com/questions/891537/ruby-detect-number-of-cpus-installed + class CpuCounter # :nodoc: all + def self.count + new.count_with_default + end + + def count_with_default(default=4) + count || default + rescue StandardError + default + end + + begin + require "etc" + rescue LoadError + else + if Etc.respond_to?(:nprocessors) + def count + return Etc.nprocessors + end + end + end + end +end + +unless Rake::CpuCounter.method_defined?(:count) + Rake::CpuCounter.class_eval <<-'end;', __FILE__, __LINE__+1 + require 'rbconfig' + + def count + if RUBY_PLATFORM == 'java' + count_via_java_runtime + else + case RbConfig::CONFIG['host_os'] + when /linux/ + count_via_cpuinfo + when /darwin|bsd/ + count_via_sysctl + when /mswin|mingw/ + count_via_win32 + else + # Try everything + count_via_win32 || + count_via_sysctl || + count_via_cpuinfo + end + end + end + + def count_via_java_runtime + Java::Java.lang.Runtime.getRuntime.availableProcessors + rescue StandardError + nil + end + + def count_via_win32 + require 'win32ole' + wmi = WIN32OLE.connect("winmgmts://") + cpu = wmi.ExecQuery("select NumberOfCores from Win32_Processor") # TODO count hyper-threaded in this + cpu.to_enum.first.NumberOfCores + rescue StandardError, LoadError + nil + end + + def count_via_cpuinfo + open('/proc/cpuinfo') { |f| f.readlines }.grep(/processor/).size + rescue StandardError + nil + end + + def count_via_sysctl + run 'sysctl', '-n', 'hw.ncpu' + end + + def run(command, *args) + cmd = resolve_command(command) + if cmd + IO.popen [cmd, *args] do |io| + io.read.to_i + end + else + nil + end + end + + def resolve_command(command) + look_for_command("/usr/sbin", command) || + look_for_command("/sbin", command) || + in_path_command(command) + end + + def look_for_command(dir, command) + path = File.join(dir, command) + File.exist?(path) ? path : nil + end + + def in_path_command(command) + IO.popen ['which', command] do |io| + io.eof? ? nil : command + end + end + end; +end diff --git a/lib/rake/default_loader.rb b/lib/rake/default_loader.rb index 5dd3c0561..d3b4650d3 100644 --- a/lib/rake/default_loader.rb +++ b/lib/rake/default_loader.rb @@ -1,7 +1,12 @@ +# frozen_string_literal: true module Rake # Default Rakefile loader used by +import+. class DefaultLoader + + ## + # Loads a rakefile into the current application from +fn+ + def load(fn) Rake.load_rakefile(File.expand_path(fn)) end diff --git a/lib/rake/dsl_definition.rb b/lib/rake/dsl_definition.rb index b24a82138..c80464020 100644 --- a/lib/rake/dsl_definition.rb +++ b/lib/rake/dsl_definition.rb @@ -1,11 +1,15 @@ +# frozen_string_literal: true # Rake DSL functions. -require 'rake/file_utils_ext' +require "rake/file_utils_ext" module Rake ## # DSL is a module that provides #task, #desc, #namespace, etc. Use this # when you'd like to use rake outside the top level scope. + # + # For a Rakefile you run from the command line this module is automatically + # included. module DSL @@ -21,14 +25,38 @@ module DSL private - # Declare a basic task. + # :call-seq: + # task(task_name) + # task(task_name: dependencies) + # task(task_name, arguments => dependencies) # - # Example: - # task :clobber => [:clean] do + # Declare a basic task. The +task_name+ is always the first argument. If + # the task name contains a ":" it is defined in that namespace. + # + # The +dependencies+ may be a single task name or an Array of task names. + # The +argument+ (a single name) or +arguments+ (an Array of names) define + # the arguments provided to the task. + # + # The task, argument and dependency names may be either symbols or + # strings. + # + # A task with a single dependency: + # + # task clobber: %w[clean] do # rm_rf "html" # end # - def task(*args, &block) + # A task with an argument and a dependency: + # + # task :package, [:version] => :test do |t, args| + # # ... + # end + # + # To invoke this task from the command line: + # + # $ rake package[1.2.3] + # + def task(*args, &block) # :doc: Rake::Task.define_task(*args, &block) end @@ -45,7 +73,7 @@ def task(*args, &block) # end # end # - def file(*args, &block) + def file(*args, &block) # :doc: Rake::FileTask.define_task(*args, &block) end @@ -61,9 +89,10 @@ def file_create(*args, &block) # Example: # directory "testdata/doc" # - def directory(*args, &block) + def directory(*args, &block) # :doc: result = file_create(*args, &block) dir, _ = *Rake.application.resolve_args(args) + dir = Rake.from_pathname(dir) Rake.each_dir_parent(dir) do |d| file_create d do |t| mkdir_p t.name unless File.exist?(t.name) @@ -78,9 +107,9 @@ def directory(*args, &block) # about it) # # Example: - # multitask :deploy => [:deploy_gem, :deploy_rdoc] + # multitask deploy: %w[deploy_gem deploy_rdoc] # - def multitask(*args, &block) + def multitask(*args, &block) # :doc: Rake::MultiTask.define_task(*args, &block) end @@ -88,14 +117,22 @@ def multitask(*args, &block) # block. Returns a NameSpace object that can be used to lookup # tasks defined in the namespace. # - # E.g. + # Example: # # ns = namespace "nested" do + # # the "nested:run" task # task :run # end # task_run = ns[:run] # find :run in the given namespace. # - def namespace(name=nil, &block) + # Tasks can also be defined in a namespace by using a ":" in the task + # name: + # + # task "nested:test" do + # # ... + # end + # + def namespace(name=nil, &block) # :doc: name = name.to_s if name.kind_of?(Symbol) name = name.to_str if name.respond_to?(:to_str) unless name.kind_of?(String) || name.nil? @@ -108,23 +145,24 @@ def namespace(name=nil, &block) # # Example: # rule '.o' => '.c' do |t| - # sh %{cc -o #{t.name} #{t.source}} + # sh 'cc', '-o', t.name, t.source # end # - def rule(*args, &block) + def rule(*args, &block) # :doc: Rake::Task.create_rule(*args, &block) end - # Describe the next rake task. - # Duplicate descriptions are discarded. + # Describes the next rake task. Duplicate descriptions are discarded. + # Descriptions are shown with rake -T (up to the first + # sentence) and rake -D (the entire description). # # Example: # desc "Run the Unit Tests" - # task :test => [:build] - # runtests + # task test: [:build] + # # ... run tests # end # - def desc(description) + def desc(description) # :doc: Rake.application.last_description = description end @@ -142,7 +180,7 @@ def desc(description) # Example: # import ".depend", "my_rules" # - def import(*fns) + def import(*fns) # :doc: fns.each do |fn| Rake.application.add_import(fn) end diff --git a/lib/rake/early_time.rb b/lib/rake/early_time.rb index 8c0e7d333..80cc6bfad 100644 --- a/lib/rake/early_time.rb +++ b/lib/rake/early_time.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Rake # EarlyTime is a fake timestamp that occurs _before_ any other time value. @@ -5,11 +6,14 @@ class EarlyTime include Comparable include Singleton + ## + # The EarlyTime always comes before +other+! + def <=>(other) -1 end - def to_s + def to_s # :nodoc: "" end end diff --git a/lib/rake/ext/core.rb b/lib/rake/ext/core.rb index c924c7eab..226f2125b 100644 --- a/lib/rake/ext/core.rb +++ b/lib/rake/ext/core.rb @@ -1,8 +1,6 @@ -###################################################################### -# Core extension library -# +# frozen_string_literal: true class Module - # Check for an existing method in the current class before extending. IF + # Check for an existing method in the current class before extending. If # the method already exists, then a warning is printed and the extension is # not added. Otherwise the block is yielded and any definitions in the # block will take effect. @@ -17,7 +15,7 @@ class Module # end # end # - def rake_extension(method) + def rake_extension(method) # :nodoc: if method_defined?(method) $stderr.puts "WARNING: Possible conflict with Rake extension: " + "#{self}##{method} already exists" diff --git a/lib/rake/ext/module.rb b/lib/rake/ext/module.rb deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/rake/ext/string.rb b/lib/rake/ext/string.rb index 07ef167f8..c70236ae9 100644 --- a/lib/rake/ext/string.rb +++ b/lib/rake/ext/string.rb @@ -1,8 +1,6 @@ -require 'rake/ext/core' +# frozen_string_literal: true +require "rake/ext/core" -###################################################################### -# Rake extension methods for String. -# class String rake_extension("ext") do @@ -11,20 +9,26 @@ class String # is not given, or is the empty string, remove any existing extension. # # +ext+ is a user added method for the String class. - def ext(newext='') - return self.dup if ['.', '..'].include? self - newext = (newext =~ /^\./) ? newext : ("." + newext) if newext != '' + # + # This String extension comes from Rake + def ext(newext="") + return self.dup if [".", ".."].include? self + if newext != "" + newext = "." + newext unless newext =~ /^\./ + end self.chomp(File.extname(self)) << newext end end rake_extension("pathmap") do # Explode a path into individual components. Used by +pathmap+. + # + # This String extension comes from Rake def pathmap_explode head, tail = File.split(self) return [self] if head == self - return [tail] if head == '.' || tail == '/' - return [head, tail] if head == '/' + return [tail] if head == "." || tail == "/" + return [head, tail] if head == "/" return head.pathmap_explode + [tail] end protected :pathmap_explode @@ -32,6 +36,8 @@ def pathmap_explode # Extract a partial path from the path. Include +n+ directories from the # front end (left hand side) if +n+ is positive. Include |+n+| # directories from the back end (right hand side) if +n+ is negative. + # + # This String extension comes from Rake def pathmap_partial(n) dirs = File.dirname(self).pathmap_explode partial_dirs = @@ -46,19 +52,21 @@ def pathmap_partial(n) end protected :pathmap_partial - # Preform the pathmap replacement operations on the given path. The + # Perform the pathmap replacement operations on the given path. The # patterns take the form 'pat1,rep1;pat2,rep2...'. + # + # This String extension comes from Rake def pathmap_replace(patterns, &block) result = self - patterns.split(';').each do |pair| - pattern, replacement = pair.split(',') + patterns.split(";").each do |pair| + pattern, replacement = pair.split(",") pattern = Regexp.new(pattern) - if replacement == '*' && block_given? + if replacement == "*" && block_given? result = result.sub(pattern, &block) elsif replacement result = result.sub(pattern, replacement) else - result = result.sub(pattern, '') + result = result.sub(pattern, "") end end result @@ -69,35 +77,36 @@ def pathmap_replace(patterns, &block) # controls the details of the mapping. The following special patterns are # recognized: # - # * %p -- The complete path. - # * %f -- The base file name of the path, with its file extension, - # but without any directories. - # * %n -- The file name of the path without its file extension. - # * %d -- The directory list of the path. - # * %x -- The file extension of the path. An empty string if there - # is no extension. - # * %X -- Everything *but* the file extension. - # * %s -- The alternate file separator if defined, otherwise use - # the standard file separator. - # * %% -- A percent sign. - # - # The %d specifier can also have a numeric prefix (e.g. '%2d'). If the - # number is positive, only return (up to) +n+ directories in the path, - # starting from the left hand side. If +n+ is negative, return (up to) - # |+n+| directories from the right hand side of the path. + # %p :: The complete path. + # %f :: The base file name of the path, with its file extension, + # but without any directories. + # %n :: The file name of the path without its file extension. + # %d :: The directory list of the path. + # %x :: The file extension of the path. An empty string if there + # is no extension. + # %X :: Everything *but* the file extension. + # %s :: The alternate file separator if defined, otherwise use # + # the standard file separator. + # %% :: A percent sign. + # + # The %d specifier can also have a numeric prefix (e.g. '%2d'). + # If the number is positive, only return (up to) +n+ directories in the + # path, starting from the left hand side. If +n+ is negative, return (up + # to) +n+ directories from the right hand side of the path. # # Examples: # # 'a/b/c/d/file.txt'.pathmap("%2d") => 'a/b' # 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d' # - # Also the %d, %p, %f, %n, %x, and %X operators can take a - # pattern/replacement argument to perform simple string substitutions on a - # particular part of the path. The pattern and replacement are separated - # by a comma and are enclosed by curly braces. The replacement spec comes - # after the % character but before the operator letter. (e.g. - # "%{old,new}d"). Multiple replacement specs should be separated by - # semi-colons (e.g. "%{old,new;src,bin}d"). + # Also the %d, %p, %f, %n, + # %x, and %X operators can take a pattern/replacement + # argument to perform simple string substitutions on a particular part of + # the path. The pattern and replacement are separated by a comma and are + # enclosed by curly braces. The replacement spec comes after the % + # character but before the operator letter. (e.g. "%{old,new}d"). + # Multiple replacement specs should be separated by semi-colons (e.g. + # "%{old,new;src,bin}d"). # # Regular expressions may be used for the pattern, and back refs may be # used in the replacement text. Curly braces, commas and semi-colons are @@ -106,11 +115,11 @@ def pathmap_replace(patterns, &block) # # For example: # - # "src/org/onestepback/proj/A.java".pathmap("%{^src,bin}X.class") + # "src/org/onestepback/proj/A.java".pathmap("%{^src,class}X.class") # # returns: # - # "bin/org/onestepback/proj/A.class" + # "class/org/onestepback/proj/A.class" # # If the replacement text is '*', then a block may be provided to perform # some arbitrary calculation for the replacement. @@ -125,34 +134,35 @@ def pathmap_replace(patterns, &block) # # "/path/to/file.txt" # + # This String extension comes from Rake def pathmap(spec=nil, &block) return self if spec.nil? - result = '' + result = "".dup spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag| case frag - when '%f' + when "%f" result << File.basename(self) - when '%n' + when "%n" result << File.basename(self).ext - when '%d' + when "%d" result << File.dirname(self) - when '%x' + when "%x" result << File.extname(self) - when '%X' + when "%X" result << self.ext - when '%p' + when "%p" result << self - when '%s' + when "%s" result << (File::ALT_SEPARATOR || File::SEPARATOR) - when '%-' + when "%-" # do nothing - when '%%' + when "%%" result << "%" when /%(-?\d+)d/ result << pathmap_partial($1.to_i) when /^%\{([^}]*)\}(\d*[dpfnxX])/ patterns, operator = $1, $2 - result << pathmap('%' + operator).pathmap_replace(patterns, &block) + result << pathmap("%" + operator).pathmap_replace(patterns, &block) when /^%/ fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'" else diff --git a/lib/rake/ext/time.rb b/lib/rake/ext/time.rb deleted file mode 100644 index ea8b037e3..000000000 --- a/lib/rake/ext/time.rb +++ /dev/null @@ -1,15 +0,0 @@ -#-- -# Extensions to time to allow comparisons with an early time class. - -require 'rake/early_time' - -class Time - alias rake_original_time_compare :<=> - def <=>(other) - if Rake::EarlyTime === other - - other.<=>(self) - else - rake_original_time_compare(other) - end - end -end diff --git a/lib/rake/file_creation_task.rb b/lib/rake/file_creation_task.rb index c87e2192b..5a4c68492 100644 --- a/lib/rake/file_creation_task.rb +++ b/lib/rake/file_creation_task.rb @@ -1,5 +1,6 @@ -require 'rake/file_task' -require 'rake/early_time' +# frozen_string_literal: true +require "rake/file_task" +require "rake/early_time" module Rake @@ -11,7 +12,7 @@ module Rake class FileCreationTask < FileTask # Is this file task needed? Yes if it doesn't exist. def needed? - ! File.exist?(name) + !File.exist?(name) end # Time stamp for file creation task. This time stamp is earlier diff --git a/lib/rake/file_list.rb b/lib/rake/file_list.rb index 0b60925f0..22c339f24 100644 --- a/lib/rake/file_list.rb +++ b/lib/rake/file_list.rb @@ -1,11 +1,11 @@ -require 'rake/cloneable' -require 'rake/file_utils_ext' -require 'rake/pathmap' +# frozen_string_literal: true +require "rake/cloneable" +require "rake/file_utils_ext" +require "rake/ext/string" -###################################################################### module Rake - # ######################################################################### + ## # A FileList is essentially an array with a few helper methods defined to # make file manipulation a bit easier. # @@ -41,15 +41,14 @@ class FileList # List of array methods (that are not in +Object+) that need to be # delegated. - ARRAY_METHODS = (Array.instance_methods - Object.instance_methods). - map { |n| n.to_s } + ARRAY_METHODS = (Array.instance_methods - Object.instance_methods).map(&:to_s) # List of additional methods that must be delegated. MUST_DEFINE = %w[inspect <=>] # List of methods that should not be delegated here (we define special # versions of them explicitly below). - MUST_NOT_DEFINE = %w[to_a to_ary partition *] + MUST_NOT_DEFINE = %w[to_a to_ary partition * <<] # List of delegated methods that return new array values which need # wrapping. @@ -59,8 +58,7 @@ class FileList + - & | ] - DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE). - map { |s| s.to_s }.sort.uniq + DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).map(&:to_s).sort.uniq # Now do the delegation. DELEGATING_METHODS.each do |sym| @@ -70,7 +68,7 @@ class FileList def #{sym}(*args, &block) resolve result = @items.send(:#{sym}, *args, &block) - FileList.new.import(result) + self.class.new.import(result) end }, __FILE__, ln else @@ -85,6 +83,8 @@ def #{sym}(*args, &block) end end + GLOB_PATTERN = %r{[*?\[\{]} + # Create a file list from the globbable patterns given. If you wish to # perform multiple includes or excludes at object build time, use the # "yield self" pattern. @@ -119,7 +119,7 @@ def include(*filenames) if fn.respond_to? :to_ary include(*fn.to_ary) else - @pending_add << fn + @pending_add << Rake.from_pathname(fn) end end @pending = true @@ -149,14 +149,17 @@ def include(*filenames) # def exclude(*patterns, &block) patterns.each do |pat| - @exclude_patterns << pat + if pat.respond_to? :to_ary + exclude(*pat.to_ary) + else + @exclude_patterns << Rake.from_pathname(pat) + end end @exclude_procs << block if block_given? resolve_exclude unless @pending self end - # Clear all the exclude patterns so that we exclude nothing. def clear_exclude @exclude_patterns = [] @@ -164,7 +167,7 @@ def clear_exclude self end - # Define equality. + # A FileList is equal through array equality. def ==(array) to_ary == array end @@ -191,12 +194,18 @@ def *(other) result = @items * other case result when Array - FileList.new.import(result) + self.class.new.import(result) else result end end + def <<(obj) + resolve + @items << Rake.from_pathname(obj) + self + end + # Resolve all the pending adds now. def resolve if @pending @@ -208,9 +217,9 @@ def resolve self end - def resolve_add(fn) + def resolve_add(fn) # :nodoc: case fn - when %r{[*?\[\{]} + when GLOB_PATTERN add_matching(fn) else self << fn @@ -218,7 +227,7 @@ def resolve_add(fn) end private :resolve_add - def resolve_exclude + def resolve_exclude # :nodoc: reject! { |fn| excluded_from_list?(fn) } self end @@ -231,7 +240,7 @@ def resolve_exclude # FileList['a.c', 'b.c'].sub(/\.c$/, '.o') => ['a.o', 'b.o'] # def sub(pat, rep) - inject(FileList.new) { |res, fn| res << fn.sub(pat, rep) } + inject(self.class.new) { |res, fn| res << fn.sub(pat, rep) } end # Return a new FileList with the results of running +gsub+ against each @@ -242,7 +251,7 @@ def sub(pat, rep) # => ['lib\\test\\file', 'x\\y'] # def gsub(pat, rep) - inject(FileList.new) { |res, fn| res << fn.gsub(pat, rep) } + inject(self.class.new) { |res, fn| res << fn.gsub(pat, rep) } end # Same as +sub+ except that the original file list is modified. @@ -260,8 +269,8 @@ def gsub!(pat, rep) # Apply the pathmap spec to each of the included file names, returning a # new file list with the modified paths. (See String#pathmap for # details.) - def pathmap(spec=nil) - collect { |fn| fn.pathmap(spec) } + def pathmap(spec=nil, &block) + collect { |fn| fn.pathmap(spec, &block) } end # Return a new FileList with String#ext method applied to @@ -272,11 +281,10 @@ def pathmap(spec=nil) # array.collect { |item| item.ext(newext) } # # +ext+ is a user added method for the Array class. - def ext(newext='') + def ext(newext="") collect { |fn| fn.ext(newext) } end - # Grep each of the files in the filelist using the given pattern. If a # block is given, call the block on each matching line, passing the file # name, line number, and the matching line of text. If no block is given, @@ -286,7 +294,7 @@ def egrep(pattern, *options) matched = 0 each do |fn| begin - open(fn, "r", *options) do |inf| + File.open(fn, "r", *options) do |inf| count = 0 inf.each do |line| count += 1 @@ -310,14 +318,14 @@ def egrep(pattern, *options) # Return a new file list that only contains file names from the current # file list that exist on the file system. def existing - select { |fn| File.exist?(fn) } + select { |fn| File.exist?(fn) }.uniq end # Modify the current file list so that it contains only file name that # exist on the file system. def existing! resolve - @items = @items.select { |fn| File.exist?(fn) } + @items = @items.select { |fn| File.exist?(fn) }.uniq self end @@ -327,20 +335,20 @@ def partition(&block) # :nodoc: resolve result = @items.partition(&block) [ - FileList.new.import(result[0]), - FileList.new.import(result[1]), + self.class.new.import(result[0]), + self.class.new.import(result[1]), ] end # Convert a FileList to a string by joining all elements with a space. def to_s resolve - self.join(' ') + self.join(" ") end # Add matching glob patterns. def add_matching(pattern) - FileList.glob(pattern).each do |fn| + self.class.glob(pattern).each do |fn| self << fn unless excluded_from_list?(fn) end end @@ -348,7 +356,7 @@ def add_matching(pattern) # Should the given file name be excluded from the list? # - # NOTE: This method was formally named "exclude?", but Rails + # NOTE: This method was formerly named "exclude?", but Rails # introduced an exclude? method as an array method and setup a # conflict with file list. We renamed the method to avoid # confusion. If you were using "FileList#exclude?" in your user @@ -358,8 +366,11 @@ def excluded_from_list?(fn) case pat when Regexp fn =~ pat - when /[*?]/ - File.fnmatch?(pat, fn, File::FNM_PATHNAME) + when GLOB_PATTERN + flags = File::FNM_PATHNAME + # Ruby <= 1.9.3 does not support File::FNM_EXTGLOB + flags |= File::FNM_EXTGLOB if defined? File::FNM_EXTGLOB + File.fnmatch?(pat, fn, flags) else fn == pat end @@ -374,10 +385,10 @@ def excluded_from_list?(fn) /~$/ ] DEFAULT_IGNORE_PROCS = [ - proc { |fn| fn =~ /(^|[\/\\])core$/ && ! File.directory?(fn) } + proc { |fn| fn =~ /(^|[\/\\])core$/ && !File.directory?(fn) } ] - def import(array) + def import(array) # :nodoc: @items = array self end @@ -391,7 +402,7 @@ def [](*args) end # Get a sorted list of files matching the pattern. This method - # should be prefered to Dir[pattern] and Dir.glob(pattern) because + # should be preferred to Dir[pattern] and Dir.glob(pattern) because # the files returned are guaranteed to be sorted. def glob(pattern, *args) Dir.glob(pattern, *args).sort @@ -406,11 +417,19 @@ class << self # Yield each file or directory component. def each_dir_parent(dir) # :nodoc: old_length = nil - while dir != '.' && dir.length != old_length + while dir != "." && dir.length != old_length yield(dir) old_length = dir.length dir = File.dirname(dir) end end + + # Convert Pathname and Pathname-like objects to strings; + # leave everything else alone + def from_pathname(path) # :nodoc: + path = path.to_path if path.respond_to?(:to_path) + path = path.to_str if path.respond_to?(:to_str) + path + end end end # module Rake diff --git a/lib/rake/file_task.rb b/lib/rake/file_task.rb index 3e717c24b..db790e39f 100644 --- a/lib/rake/file_task.rb +++ b/lib/rake/file_task.rb @@ -1,8 +1,9 @@ -require 'rake/task.rb' -require 'rake/early_time' +# frozen_string_literal: true +require "rake/task" +require "rake/early_time" module Rake - # ######################################################################### + # A FileTask is a task that includes time based dependencies. If any of a # FileTask's prerequisites have a timestamp that is later than the file # represented by this task, then the file must be rebuilt (using the @@ -13,7 +14,7 @@ class FileTask < Task # Is this file task needed? Yes if it doesn't exist, or if its time stamp # is out of date. def needed? - ! File.exist?(name) || out_of_date?(timestamp) + !File.exist?(name) || out_of_date?(timestamp) || @application.options.build_all end # Time stamp for file task. @@ -21,7 +22,7 @@ def timestamp if File.exist?(name) File.mtime(name.to_s) else - Rake::EARLY + Rake::LATE end end @@ -29,7 +30,14 @@ def timestamp # Are there any prerequisites with a later time than the given time stamp? def out_of_date?(stamp) - @prerequisites.any? { |n| application[n, @scope].timestamp > stamp } + all_prerequisite_tasks.any? { |prereq| + prereq_task = application[prereq, @scope] + if prereq_task.instance_of?(Rake::FileTask) + prereq_task.timestamp > stamp || @application.options.build_all + else + prereq_task.timestamp > stamp + end + } end # ---------------------------------------------------------------- @@ -39,7 +47,7 @@ class << self # Apply the scope to the task name according to the rules for this kind # of task. File based tasks ignore the scope when creating the name. def scope_name(scope, task_name) - task_name + Rake.from_pathname(task_name) end end end diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb index 0f7f459d8..e979eedb2 100644 --- a/lib/rake/file_utils.rb +++ b/lib/rake/file_utils.rb @@ -1,31 +1,41 @@ -require 'rbconfig' -require 'fileutils' +# frozen_string_literal: true +require "rbconfig" +require "fileutils" #-- # This a FileUtils extension that defines several additional commands to be # added to the FileUtils utility functions. module FileUtils # Path to the currently running Ruby program - RUBY = ENV['RUBY'] || File.join( - RbConfig::CONFIG['bindir'], - RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']). + RUBY = ENV["RUBY"] || File.join( + RbConfig::CONFIG["bindir"], + RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"]). sub(/.*\s.*/m, '"\&"') - OPT_TABLE['sh'] = %w(noop verbose) - OPT_TABLE['ruby'] = %w(noop verbose) - - # Run the system command +cmd+. If multiple arguments are given the command - # is not run with the shell (same semantics as Kernel::exec and + # Run the system command +cmd+. If multiple arguments are given the command + # is run directly (without the shell, same semantics as Kernel::exec and # Kernel::system). # - # Example: - # sh %{ls -ltr} + # It is recommended you use the multiple argument form over interpolating + # user input for both usability and security reasons. With the multiple + # argument form you can easily process files with spaces or other shell + # reserved characters in them. With the multiple argument form your rake + # tasks are not vulnerable to users providing an argument like + # ; rm # -rf /. + # + # If a block is given, upon command completion the block is called with an + # OK flag (true on a zero exit status) and a Process::Status object. + # Without a block a RuntimeError is raised when the command exits non-zero. + # + # Examples: + # + # sh 'ls -ltr' # # sh 'ls', 'file with spaces' # # # check exit status after command runs # sh %{grep pattern file} do |ok, res| - # if ! ok + # if !ok # puts "pattern not found (status = #{res.exitstatus})" # end # end @@ -33,13 +43,15 @@ module FileUtils def sh(*cmd, &block) options = (Hash === cmd.last) ? cmd.pop : {} shell_runner = block_given? ? block : create_shell_runner(cmd) + set_verbose_option(options) - options[:noop] ||= Rake::FileUtilsExt.nowrite_flag - Rake.rake_check_options options, :noop, :verbose - Rake.rake_output_message cmd.join(" ") if options[:verbose] + verbose = options.delete :verbose + noop = options.delete(:noop) || Rake::FileUtilsExt.nowrite_flag - unless options[:noop] - res = rake_system(*cmd) + Rake.rake_output_message sh_show_command cmd if verbose + + unless noop + res = (Hash === cmd.last) ? system(*cmd) : system(*cmd, options) status = $? status = Rake::PseudoStatus.new(1) if !res && status.nil? shell_runner.call(res, status) @@ -47,8 +59,9 @@ def sh(*cmd, &block) end def create_shell_runner(cmd) # :nodoc: - show_command = cmd.join(" ") + show_command = sh_show_command cmd show_command = show_command[0, 42] + "..." unless $trace + lambda do |ok, status| ok or fail "Command failed with status (#{status.exitstatus}): " + @@ -57,6 +70,19 @@ def create_shell_runner(cmd) # :nodoc: end private :create_shell_runner + def sh_show_command(cmd) # :nodoc: + cmd = cmd.dup + + if Hash === cmd.first + env = cmd.first + env = env.map { |name, value| "#{name}=#{value}" }.join " " + cmd[0] = env + end + + cmd.join " " + end + private :sh_show_command + def set_verbose_option(options) # :nodoc: unless options.key? :verbose options[:verbose] = @@ -66,22 +92,16 @@ def set_verbose_option(options) # :nodoc: end private :set_verbose_option - def rake_system(*cmd) # :nodoc: - Rake::AltSystem.system(*cmd) - end - private :rake_system - # Run a Ruby interpreter with the given arguments. # # Example: # ruby %{-pe '$_.upcase!' 1 - sh(*([RUBY] + args + [options]), &block) + sh(RUBY, *args, **options, &block) else - sh("#{RUBY} #{args.first}", options, &block) + sh("#{RUBY} #{args.first}", **options, &block) end end @@ -89,17 +109,15 @@ def ruby(*args, &block) # Attempt to do a normal file link, but fall back to a copy if the link # fails. - def safe_ln(*args) - if ! LN_SUPPORTED[0] - cp(*args) - else + def safe_ln(*args, **options) + if LN_SUPPORTED[0] begin - ln(*args) + return options.empty? ? ln(*args) : ln(*args, **options) rescue StandardError, NotImplementedError LN_SUPPORTED[0] = false - cp(*args) end end + options.empty? ? cp(*args) : cp(*args, **options) end # Split a file path into individual directory names. @@ -109,8 +127,8 @@ def safe_ln(*args) # def split_all(path) head, tail = File.split(path) - return [tail] if head == '.' || tail == '/' - return [head, tail] if head == '/' + return [tail] if head == "." || tail == "/" + return [head, tail] if head == "/" return split_all(head) + [tail] end end diff --git a/lib/rake/file_utils_ext.rb b/lib/rake/file_utils_ext.rb index 309159aec..e91ad595f 100644 --- a/lib/rake/file_utils_ext.rb +++ b/lib/rake/file_utils_ext.rb @@ -1,4 +1,5 @@ -require 'rake/file_utils' +# frozen_string_literal: true +require "rake/file_utils" module Rake # @@ -22,19 +23,18 @@ class << self opts = FileUtils.options_of name default_options = [] if opts.include?("verbose") - default_options << ':verbose => FileUtilsExt.verbose_flag' + default_options << "verbose: FileUtilsExt.verbose_flag" end if opts.include?("noop") - default_options << ':noop => FileUtilsExt.nowrite_flag' + default_options << "noop: FileUtilsExt.nowrite_flag" end next if default_options.empty? module_eval(<<-EOS, __FILE__, __LINE__ + 1) - def #{name}( *args, &block ) - super( - *rake_merge_option(args, - #{default_options.join(', ')} - ), &block) + def #{name}(*args, **options, &block) + super(*args, + #{default_options.join(', ')}, + **options, &block) end EOS end @@ -112,16 +112,6 @@ def when_writing(msg=nil) end end - # Merge the given options with the default values. - def rake_merge_option(args, defaults) - if Hash === args.last - defaults.update(args.last) - args.pop - end - args.push defaults - args - end - # Send the message to the default rake output (which is $stderr). def rake_output_message(message) $stderr.puts(message) diff --git a/lib/rake/gempackagetask.rb b/lib/rake/gempackagetask.rb deleted file mode 100644 index 4ace0a6f0..000000000 --- a/lib/rake/gempackagetask.rb +++ /dev/null @@ -1,2 +0,0 @@ -fail "ERROR: 'rake/gempackagetask' is obsolete and no longer supported. " + - "Use 'rubygems/packagetask' instead." diff --git a/lib/rake/invocation_chain.rb b/lib/rake/invocation_chain.rb index dae9a3591..44a995496 100644 --- a/lib/rake/invocation_chain.rb +++ b/lib/rake/invocation_chain.rb @@ -1,6 +1,6 @@ +# frozen_string_literal: true module Rake - #################################################################### # InvocationChain tracks the chain of task invocations to detect # circular dependencies. class InvocationChain < LinkedList @@ -32,7 +32,7 @@ def self.append(invocation, chain) private def prefix - "#{tail.to_s} => " + "#{tail} => " end # Null object for an empty chain. diff --git a/lib/rake/invocation_exception_mixin.rb b/lib/rake/invocation_exception_mixin.rb index 84ff3353b..b0d307a48 100644 --- a/lib/rake/invocation_exception_mixin.rb +++ b/lib/rake/invocation_exception_mixin.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Rake module InvocationExceptionMixin # Return the invocation chain (list of Rake tasks) that were in diff --git a/lib/rake/late_time.rb b/lib/rake/late_time.rb new file mode 100644 index 000000000..8fe024943 --- /dev/null +++ b/lib/rake/late_time.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true +module Rake + # LateTime is a fake timestamp that occurs _after_ any other time value. + class LateTime + include Comparable + include Singleton + + def <=>(other) + 1 + end + + def to_s + "" + end + end + + LATE = LateTime.instance +end diff --git a/lib/rake/lib/.document b/lib/rake/lib/.document deleted file mode 100644 index 098e64716..000000000 --- a/lib/rake/lib/.document +++ /dev/null @@ -1 +0,0 @@ -# Ignore project.rake diff --git a/lib/rake/lib/project.rake b/lib/rake/lib/project.rake deleted file mode 100644 index a5497328a..000000000 --- a/lib/rake/lib/project.rake +++ /dev/null @@ -1,21 +0,0 @@ -task "create:project" => ["lib", "test", "Rakefile"] - -directory "lib" -directory "test" - -file "Rakefile" do - File.open("Rakefile", "w") do |out| - out.puts %{# -*- ruby -*- - -require 'rake/clean' -require 'rake/testtask' - -task :default => :test - -Rake::TestTask.new do |t| - t.verbose = false - t.test_files = FileList['test/test_*.rb'] -end -} - end -end diff --git a/lib/rake/linked_list.rb b/lib/rake/linked_list.rb index 26483703f..11fa46f0d 100644 --- a/lib/rake/linked_list.rb +++ b/lib/rake/linked_list.rb @@ -1,24 +1,22 @@ +# frozen_string_literal: true module Rake # Polylithic linked list structure used to implement several data # structures in Rake. class LinkedList include Enumerable - attr_reader :head, :tail - def initialize(head, tail=EMPTY) - @head = head - @tail = tail - end - # Polymorphically add a new element to the head of a list. The - # type of head node will be the same list type has the tail. + # type of head node will be the same list type as the tail. def conj(item) self.class.cons(item, self) end # Is the list empty? + # .make guards against a list being empty making any instantiated LinkedList + # object not empty by default + # You should consider overriding this method if you implement your own .make method def empty? false end @@ -26,7 +24,7 @@ def empty? # Lists are structurally equivalent. def ==(other) current = self - while ! current.empty? && ! other.empty? + while !current.empty? && !other.empty? return false if current.head != other.head current = current.tail other = other.tail @@ -36,20 +34,20 @@ def ==(other) # Convert to string: LL(item, item...) def to_s - items = map { |item| item.to_s }.join(", ") + items = map(&:to_s).join(", ") "LL(#{items})" end # Same as +to_s+, but with inspected items. def inspect - items = map { |item| item.inspect }.join(", ") + items = map(&:inspect).join(", ") "LL(#{items})" end # For each item in the list. def each current = self - while ! current.empty? + while !current.empty? yield(current.head) current = current.tail end @@ -59,11 +57,16 @@ def each # Make a list out of the given arguments. This method is # polymorphic def self.make(*args) - result = empty - args.reverse_each do |item| - result = cons(item, result) + # return an EmptyLinkedList if there are no arguments + return empty if !args || args.empty? + + # build a LinkedList by starting at the tail and iterating + # through each argument + # inject takes an EmptyLinkedList to start + args.reverse.inject(empty) do |list, item| + list = cons(item, list) + list # return the newly created list for each item in the block end - result end # Cons a new head onto the tail list. @@ -76,11 +79,18 @@ def self.empty self::EMPTY end + protected + + def initialize(head, tail=EMPTY) + @head = head + @tail = tail + end + # Represent an empty list, using the Null Object Pattern. # # When inheriting from the LinkedList class, you should implement # a type specific Empty class as well. Make sure you set the class - # instance variable @parent to the assocated list class (this + # instance variable @parent to the associated list class (this # allows conj, cons and make to work polymorphically). class EmptyLinkedList < LinkedList @parent = LinkedList @@ -99,5 +109,4 @@ def self.cons(head, tail) EMPTY = EmptyLinkedList.new end - end diff --git a/lib/rake/loaders/makefile.rb b/lib/rake/loaders/makefile.rb index 4ece4323a..46f4beaad 100644 --- a/lib/rake/loaders/makefile.rb +++ b/lib/rake/loaders/makefile.rb @@ -1,17 +1,31 @@ +# frozen_string_literal: true module Rake - # Makefile loader to be used with the import file loader. + # Makefile loader to be used with the import file loader. Use this to + # import dependencies from make dependency tools: + # + # require 'rake/loaders/makefile' + # + # file ".depends.mf" => [SRC_LIST] do |t| + # sh "makedepend -f- -- #{CFLAGS} -- #{t.prerequisites} > #{t.name}" + # end + # + # import ".depends.mf" + # + # See {Importing Dependencies}[link:doc/rakefile_rdoc.html#label-Importing+Dependencies] + # for further details. + class MakefileLoader include Rake::DSL - SPACE_MARK = "\0" + SPACE_MARK = "\0" # :nodoc: # Load the makefile dependencies in +fn+. - def load(fn) + def load(fn) # :nodoc: lines = File.read fn lines.gsub!(/\\ /, SPACE_MARK) lines.gsub!(/#[^\n]*\n/m, "") - lines.gsub!(/\\\n/, ' ') + lines.gsub!(/\\\n/, " ") lines.each_line do |line| process_line(line) end @@ -20,8 +34,8 @@ def load(fn) private # Process one logical line of makefile data. - def process_line(line) - file_tasks, args = line.split(':', 2) + def process_line(line) # :nodoc: + file_tasks, args = line.split(":", 2) return if args.nil? dependents = args.split.map { |d| respace(d) } file_tasks.scan(/\S+/) do |file_task| @@ -30,11 +44,11 @@ def process_line(line) end end - def respace(str) - str.tr SPACE_MARK, ' ' + def respace(str) # :nodoc: + str.tr SPACE_MARK, " " end end # Install the handler - Rake.application.add_loader('mf', MakefileLoader.new) + Rake.application.add_loader("mf", MakefileLoader.new) end diff --git a/lib/rake/multi_task.rb b/lib/rake/multi_task.rb index 5418a7a7b..3ae363cbe 100644 --- a/lib/rake/multi_task.rb +++ b/lib/rake/multi_task.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Rake # Same as a regular task, but the immediate prerequisites are done in @@ -5,9 +6,9 @@ module Rake # class MultiTask < Task private + def invoke_prerequisites(task_args, invocation_chain) # :nodoc: invoke_prerequisites_concurrently(task_args, invocation_chain) end end - end diff --git a/lib/rake/name_space.rb b/lib/rake/name_space.rb index e1cc0940b..32f8139fc 100644 --- a/lib/rake/name_space.rb +++ b/lib/rake/name_space.rb @@ -1,25 +1,38 @@ -module Rake - - # The NameSpace class will lookup task names in the the scope - # defined by a +namespace+ command. - # - class NameSpace - - # Create a namespace lookup object using the given task manager - # and the list of scopes. - def initialize(task_manager, scope_list) - @task_manager = task_manager - @scope = scope_list.dup - end - - # Lookup a task named +name+ in the namespace. - def [](name) - @task_manager.lookup(name, @scope) - end - - # Return the list of tasks defined in this and nested namespaces. - def tasks - @task_manager.tasks_in_scope(@scope) - end +# frozen_string_literal: true +## +# The NameSpace class will lookup task names in the scope defined by a +# +namespace+ command. + +class Rake::NameSpace + + ## + # Create a namespace lookup object using the given task manager + # and the list of scopes. + + def initialize(task_manager, scope_list) + @task_manager = task_manager + @scope = scope_list.dup end + + ## + # Lookup a task named +name+ in the namespace. + + def [](name) + @task_manager.lookup(name, @scope) + end + + ## + # The scope of the namespace (a LinkedList) + + def scope + @scope.dup + end + + ## + # Return the list of tasks defined in this and nested namespaces. + + def tasks + @task_manager.tasks_in_scope(@scope) + end + end diff --git a/lib/rake/packagetask.rb b/lib/rake/packagetask.rb index 029caa6d4..aeff81c29 100644 --- a/lib/rake/packagetask.rb +++ b/lib/rake/packagetask.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true # Define a package task library to aid in the definition of # redistributable package files. -require 'rake' -require 'rake/tasklib' +require "rake" +require "rake/tasklib" module Rake @@ -11,27 +12,27 @@ module Rake # # The PackageTask will create the following targets: # - # [:package] + # +:package+ :: # Create all the requested package files. # - # [:clobber_package] + # +:clobber_package+ :: # Delete all the package files. This target is automatically # added to the main clobber target. # - # [:repackage] + # +:repackage+ :: # Rebuild the package files from scratch, even if they are not out # of date. # - # ["package_dir/name-version.tgz"] + # "package_dir/name-version.tgz" :: # Create a gzipped tar package (if need_tar is true). # - # ["package_dir/name-version.tar.gz"] + # "package_dir/name-version.tar.gz" :: # Create a gzipped tar package (if need_tar_gz is true). # - # ["package_dir/name-version.tar.bz2"] + # "package_dir/name-version.tar.bz2" :: # Create a bzip2'd tar package (if need_tar_bz2 is true). # - # ["package_dir/name-version.zip"] + # "package_dir/name-version.zip" :: # Create a zip package archive (if need_zip is true). # # Example: @@ -63,6 +64,9 @@ class PackageTask < TaskLib # is false). attr_accessor :need_tar_bz2 + # True if a xz'd tar file (tar.xz) should be produced (default is false) + attr_accessor :need_tar_xz + # True if a zip file should be produced (default is false) attr_accessor :need_zip @@ -75,6 +79,9 @@ class PackageTask < TaskLib # Zip command for zipped archives. The default is 'zip'. attr_accessor :zip_command + # True if parent directory should be omited (default is false) + attr_accessor :without_parent_dir + # Create a Package Task with the given name and version. Use +:noversion+ # as the version to build a package without a version or to provide a # fully-versioned package name. @@ -90,13 +97,15 @@ def init(name, version) @name = name @version = version @package_files = Rake::FileList.new - @package_dir = 'pkg' + @package_dir = "pkg" @need_tar = false @need_tar_gz = false @need_tar_bz2 = false + @need_tar_xz = false @need_zip = false - @tar_command = 'tar' - @zip_command = 'zip' + @tar_command = "tar" + @zip_command = "zip" + @without_parent_dir = false end # Create the tasks defined by this task library. @@ -108,45 +117,41 @@ def define task :package desc "Force a rebuild of the package files" - task :repackage => [:clobber_package, :package] + task repackage: [:clobber_package, :package] desc "Remove package products" task :clobber_package do rm_r package_dir rescue nil end - task :clobber => [:clobber_package] + task clobber: [:clobber_package] [ [need_tar, tgz_file, "z"], [need_tar_gz, tar_gz_file, "z"], - [need_tar_bz2, tar_bz2_file, "j"] - ].each do |(need, file, flag)| + [need_tar_bz2, tar_bz2_file, "j"], + [need_tar_xz, tar_xz_file, "J"] + ].each do |need, file, flag| if need - task :package => ["#{package_dir}/#{file}"] + task package: ["#{package_dir}/#{file}"] file "#{package_dir}/#{file}" => [package_dir_path] + package_files do - chdir(package_dir) do - sh %{#{@tar_command} #{flag}cvf #{file} #{package_name}} - end + chdir(working_dir) { sh @tar_command, "#{flag}cvf", file, target_dir } + mv "#{package_dir_path}/#{target_dir}", package_dir if without_parent_dir end end end if need_zip - task :package => ["#{package_dir}/#{zip_file}"] + task package: ["#{package_dir}/#{zip_file}"] file "#{package_dir}/#{zip_file}" => [package_dir_path] + package_files do - chdir(package_dir) do - sh %{#{@zip_command} -r #{zip_file} #{package_name}} - end + chdir(working_dir) { sh @zip_command, "-r", zip_file, target_dir } + mv "#{package_dir_path}/#{zip_file}", package_dir if without_parent_dir end end - directory package_dir - - file package_dir_path => @package_files do - mkdir_p package_dir rescue nil + directory package_dir_path => @package_files do @package_files.each do |fn| f = File.join(package_dir_path, fn) fdir = File.dirname(f) @@ -162,29 +167,56 @@ def define self end + # The name of this package + def package_name @version ? "#{@name}-#{@version}" : @name end + # The directory this package will be built in + def package_dir_path "#{package_dir}/#{package_name}" end + # The package name with .tgz added + def tgz_file "#{package_name}.tgz" end + # The package name with .tar.gz added + def tar_gz_file "#{package_name}.tar.gz" end + # The package name with .tar.bz2 added + def tar_bz2_file "#{package_name}.tar.bz2" end + # The package name with .tar.xz added + + def tar_xz_file + "#{package_name}.tar.xz" + end + + # The package name with .zip added + def zip_file "#{package_name}.zip" end + + def working_dir + without_parent_dir ? package_dir_path : package_dir + end + + # target directory relative to working_dir + def target_dir + without_parent_dir ? "." : package_name + end end end diff --git a/lib/rake/pathmap.rb b/lib/rake/pathmap.rb deleted file mode 100644 index 227572434..000000000 --- a/lib/rake/pathmap.rb +++ /dev/null @@ -1 +0,0 @@ -require 'rake/ext/string' diff --git a/lib/rake/phony.rb b/lib/rake/phony.rb index 29633ae06..8caa5de17 100644 --- a/lib/rake/phony.rb +++ b/lib/rake/phony.rb @@ -1,10 +1,11 @@ +# frozen_string_literal: true # Defines a :phony task that you can use as a dependency. This allows # file-based tasks to use non-file-based tasks as prerequisites # without forcing them to rebuild. # # See FileTask#out_of_date? and Task#timestamp for more info. -require 'rake' +require "rake" task :phony diff --git a/lib/rake/private_reader.rb b/lib/rake/private_reader.rb index 162097857..2815ce643 100644 --- a/lib/rake/private_reader.rb +++ b/lib/rake/private_reader.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Rake # Include PrivateReader to use +private_reader+. diff --git a/lib/rake/promise.rb b/lib/rake/promise.rb index 31c456347..f45af4f3a 100644 --- a/lib/rake/promise.rb +++ b/lib/rake/promise.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Rake # A Promise object represents a promise to do work (a chore) in the @@ -27,11 +28,11 @@ def initialize(args, &block) # synchronously. We will wait. def value unless complete? - stat :sleeping_on, :item_id => object_id + stat :sleeping_on, item_id: object_id @mutex.synchronize do - stat :has_lock_on, :item_id => object_id + stat :has_lock_on, item_id: object_id chore - stat :releasing_lock_on, :item_id => object_id + stat :releasing_lock_on, item_id: object_id end end error? ? raise(@error) : @result @@ -39,14 +40,14 @@ def value # If no one else is working this promise, go ahead and do the chore. def work - stat :attempting_lock_on, :item_id => object_id + stat :attempting_lock_on, item_id: object_id if @mutex.try_lock - stat :has_lock_on, :item_id => object_id + stat :has_lock_on, item_id: object_id chore - stat :releasing_lock_on, :item_id => object_id + stat :releasing_lock_on, item_id: object_id @mutex.unlock else - stat :bailed_on, :item_id => object_id + stat :bailed_on, item_id: object_id end end @@ -55,27 +56,27 @@ def work # Perform the chore promised def chore if complete? - stat :found_completed, :item_id => object_id + stat :found_completed, item_id: object_id return end - stat :will_execute, :item_id => object_id + stat :will_execute, item_id: object_id begin @result = @block.call(*@args) rescue Exception => e @error = e end - stat :did_execute, :item_id => object_id + stat :did_execute, item_id: object_id discard end # Do we have a result for the promise def result? - ! @result.equal?(NOT_SET) + !@result.equal?(NOT_SET) end # Did the promise throw an error def error? - ! @error.equal?(NOT_SET) + !@error.equal?(NOT_SET) end # Are we done with the promise diff --git a/lib/rake/pseudo_status.rb b/lib/rake/pseudo_status.rb index 09d5c88c7..8b3c98949 100644 --- a/lib/rake/pseudo_status.rb +++ b/lib/rake/pseudo_status.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true module Rake - #################################################################### + ## # Exit status class for times the system just gives us a nil. - class PseudoStatus + class PseudoStatus # :nodoc: all attr_reader :exitstatus def initialize(code=0) diff --git a/lib/rake/rake_module.rb b/lib/rake/rake_module.rb index fcf580006..03c295624 100644 --- a/lib/rake/rake_module.rb +++ b/lib/rake/rake_module.rb @@ -1,9 +1,8 @@ -require 'rake/application' +# frozen_string_literal: true +require "rake/application" module Rake - # Rake module singleton methods. - # class << self # Current Rake Application def application @@ -15,6 +14,11 @@ def application=(app) @application = app end + def suggested_thread_count # :nodoc: + @cpu_count ||= Rake::CpuCounter.count + @cpu_count + 4 + end + # Return the original directory where the Rake application was started. def original_dir application.original_dir @@ -28,9 +32,35 @@ def load_rakefile(path) # Add files to the rakelib list def add_rakelib(*files) application.options.rakelib ||= [] - files.each do |file| - application.options.rakelib << file - end + application.options.rakelib.concat(files) + end + + # Make +block_application+ the default rake application inside a block so + # you can load rakefiles into a different application. + # + # This is useful when you want to run rake tasks inside a library without + # running rake in a sub-shell. + # + # Example: + # + # Dir.chdir 'other/directory' + # + # other_rake = Rake.with_application do |rake| + # rake.load_rakefile + # end + # + # puts other_rake.tasks + + def with_application(block_application = Rake::Application.new) + orig_application = Rake.application + + Rake.application = block_application + + yield block_application + + block_application + ensure + Rake.application = orig_application end end diff --git a/lib/rake/rake_test_loader.rb b/lib/rake/rake_test_loader.rb index 7e3a6b3f3..f0f7772ba 100644 --- a/lib/rake/rake_test_loader.rb +++ b/lib/rake/rake_test_loader.rb @@ -1,22 +1,27 @@ -require 'rake' +# frozen_string_literal: true +require "rake" # Load the test files from the command line. argv = ARGV.select do |argument| - case argument - when /^-/ then - argument - when /\*/ then - FileList[argument].to_a.each do |file| - require File.expand_path file - end + begin + case argument + when /^-/ then + argument + when /\*/ then + FileList[argument].to_a.each do |file| + require File.expand_path file + end - false - else - require File.expand_path argument + false + else + require File.expand_path argument - false + false + end + rescue LoadError => e + raise unless e.path + abort "\nFile does not exist: #{e.path}\n\n" end end ARGV.replace argv - diff --git a/lib/rake/rdoctask.rb b/lib/rake/rdoctask.rb deleted file mode 100644 index 50b7e269d..000000000 --- a/lib/rake/rdoctask.rb +++ /dev/null @@ -1,2 +0,0 @@ -fail "ERROR: 'rake/rdoctask' is obsolete and no longer supported. " + - "Use 'rdoc/task' (available in RDoc 2.4.2+) instead." diff --git a/lib/rake/ruby182_test_unit_fix.rb b/lib/rake/ruby182_test_unit_fix.rb deleted file mode 100644 index e47feeb09..000000000 --- a/lib/rake/ruby182_test_unit_fix.rb +++ /dev/null @@ -1,27 +0,0 @@ -# Local Rake override to fix bug in Ruby 0.8.2 -module Test # :nodoc: - # Local Rake override to fix bug in Ruby 0.8.2 - module Unit # :nodoc: - # Local Rake override to fix bug in Ruby 0.8.2 - module Collector # :nodoc: - # Local Rake override to fix bug in Ruby 0.8.2 - class Dir # :nodoc: - undef collect_file - def collect_file(name, suites, already_gathered) # :nodoc: - dir = File.dirname(File.expand_path(name)) - $:.unshift(dir) unless $:.first == dir - if @req - @req.require(name) - else - require(name) - end - find_test_cases(already_gathered).each do |t| - add_suite(suites, t.suite) - end - ensure - $:.delete_at $:.rindex(dir) - end - end - end - end -end diff --git a/lib/rake/rule_recursion_overflow_error.rb b/lib/rake/rule_recursion_overflow_error.rb index da4318da9..a51e77489 100644 --- a/lib/rake/rule_recursion_overflow_error.rb +++ b/lib/rake/rule_recursion_overflow_error.rb @@ -1,4 +1,4 @@ - +# frozen_string_literal: true module Rake # Error indicating a recursion overflow error in task selection. @@ -13,7 +13,7 @@ def add_target(target) end def message - super + ": [" + @targets.reverse.join(' => ') + "]" + super + ": [" + @targets.reverse.join(" => ") + "]" end end diff --git a/lib/rake/runtest.rb b/lib/rake/runtest.rb deleted file mode 100644 index 3f01b28ca..000000000 --- a/lib/rake/runtest.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'test/unit' -require 'test/unit/assertions' -require 'rake/file_list' - -module Rake - include Test::Unit::Assertions - - def run_tests(pattern='test/test*.rb', log_enabled=false) - FileList.glob(pattern).each do |fn| - $stderr.puts fn if log_enabled - begin - require fn - rescue Exception => ex - $stderr.puts "Error in #{fn}: #{ex.message}" - $stderr.puts ex.backtrace - assert false - end - end - end - - extend self -end diff --git a/lib/rake/scope.rb b/lib/rake/scope.rb index 33e1c08e7..fc1eb6c3a 100644 --- a/lib/rake/scope.rb +++ b/lib/rake/scope.rb @@ -1,9 +1,10 @@ +# frozen_string_literal: true module Rake - class Scope < LinkedList + class Scope < LinkedList # :nodoc: all # Path for the scope. def path - map { |item| item.to_s }.reverse.join(":") + map(&:to_s).reverse.join(":") end # Path for the scope + the named path. @@ -15,7 +16,7 @@ def path_with_task_name(task_name) # this trim beyond the toplevel scope. def trim(n) result = self - while n > 0 && ! result.empty? + while n > 0 && !result.empty? result = result.tail n -= 1 end diff --git a/lib/rake/task.rb b/lib/rake/task.rb index 5e4dd64d4..ec2c756e0 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -1,8 +1,9 @@ -require 'rake/invocation_exception_mixin' +# frozen_string_literal: true +require "rake/invocation_exception_mixin" module Rake - # ######################################################################### + ## # A Task is the basic unit of work in a Rakefile. Tasks have associated # actions (possibly more than one) and a list of prerequisites. When # invoked, a task will first ensure that all of its prerequisites have an @@ -14,6 +15,10 @@ module Rake class Task # List of prerequisites for a task. attr_reader :prerequisites + alias prereqs prerequisites + + # List of order only prerequisites for a task. + attr_reader :order_only_prerequisites # List of actions attached to a task. attr_reader :actions @@ -29,28 +34,40 @@ class Task # location option set). attr_reader :locations + # Has this task already been invoked? Already invoked tasks + # will be skipped unless you reenable them. + attr_reader :already_invoked + # Return task name def to_s name end - def inspect + def inspect # :nodoc: "<#{self.class} #{name} => [#{prerequisites.join(', ')}]>" end # List of sources for task. attr_writer :sources def sources - @sources ||= [] + if defined?(@sources) + @sources + else + prerequisites + end end # List of prerequisite tasks def prerequisite_tasks - prerequisites.map { |pre| lookup_prerequisite(pre) } + (prerequisites + order_only_prerequisites).map { |pre| lookup_prerequisite(pre) } end - def lookup_prerequisite(prerequisite_name) - application[prerequisite_name, @scope] + def lookup_prerequisite(prerequisite_name) # :nodoc: + scoped_prerequisite_task = application[prerequisite_name, @scope] + if scoped_prerequisite_task == self + unscoped_prerequisite_task = application[prerequisite_name] + end + unscoped_prerequisite_task || scoped_prerequisite_task end private :lookup_prerequisite @@ -63,7 +80,7 @@ def all_prerequisite_tasks seen.values end - def collect_prerequisites(seen) + def collect_prerequisites(seen) # :nodoc: prerequisite_tasks.each do |pre| next if seen[pre.name] seen[pre.name] = pre @@ -74,7 +91,7 @@ def collect_prerequisites(seen) # First source from a rule (nil if no sources) def source - @sources.first if defined?(@sources) + sources.first end # Create a task named +task_name+ with no actions or prerequisites. Use @@ -90,6 +107,8 @@ def initialize(task_name, app) @scope = app.current_scope @arg_names = nil @locations = [] + @invocation_exception = nil + @order_only_prerequisites = [] end # Enhance a task with prerequisites or actions. Returns self. @@ -127,13 +146,15 @@ def arg_names # is invoked again. def reenable @already_invoked = false + @invocation_exception = nil end - # Clear the existing prerequisites and actions of a rake task. + # Clear the existing prerequisites, actions, comments, and arguments of a rake task. def clear clear_prerequisites clear_actions clear_comments + clear_args self end @@ -155,6 +176,12 @@ def clear_comments self end + # Clear the existing arguments on a rake task. + def clear_args + @arg_names = nil + self + end + # Invoke the task if it is needed. Prerequisites are invoked first. def invoke(*args) task_args = TaskArguments.new(arg_names, args) @@ -163,24 +190,43 @@ def invoke(*args) # Same as invoke, but explicitly pass a call chain to detect # circular dependencies. - def invoke_with_call_chain(task_args, invocation_chain) # :nodoc: - new_chain = InvocationChain.append(self, invocation_chain) + # + # If multiple tasks depend on this + # one in parallel, they will all fail if the first execution of + # this task fails. + def invoke_with_call_chain(task_args, invocation_chain) + new_chain = Rake::InvocationChain.append(self, invocation_chain) @lock.synchronize do - if application.options.trace - application.trace "** Invoke #{name} #{format_trace_flags}" + begin + if application.options.trace + application.trace "** Invoke #{name} #{format_trace_flags}" + end + + if @already_invoked + if @invocation_exception + if application.options.trace + application.trace "** Previous invocation of #{name} failed #{format_trace_flags}" + end + raise @invocation_exception + else + return + end + end + + @already_invoked = true + + invoke_prerequisites(task_args, new_chain) + execute(task_args) if needed? + rescue Exception => ex + add_chain_to(ex, new_chain) + @invocation_exception = ex + raise ex end - return if @already_invoked - @already_invoked = true - invoke_prerequisites(task_args, new_chain) - execute(task_args) if needed? end - rescue Exception => ex - add_chain_to(ex, new_chain) - raise ex end protected :invoke_with_call_chain - def add_chain_to(exception, new_chain) + def add_chain_to(exception, new_chain) # :nodoc: exception.extend(InvocationExceptionMixin) unless exception.respond_to?(:chain) exception.chain = new_chain if exception.chain.nil? @@ -207,7 +253,8 @@ def invoke_prerequisites_concurrently(task_args, invocation_chain)# :nodoc: r.invoke_with_call_chain(prereq_args, invocation_chain) end end - futures.each { |f| f.value } + # Iterate in reverse to improve performance related to thread waiting and switching + futures.reverse_each(&:value) end # Format the trace flags for display. @@ -228,13 +275,10 @@ def execute(args=nil) end application.trace "** Execute #{name}" if application.options.trace application.enhance_with_matching_rule(name) if @actions.empty? - @actions.each do |act| - case act.arity - when 1 - act.call(self) - else - act.call(self, args) - end + if opts = Hash.try_convert(args) and !opts.empty? + @actions.each { |act| act.call(self, args, **opts)} + else + @actions.each { |act| act.call(self, args)} end end @@ -254,14 +298,15 @@ def timestamp def add_description(description) return unless description comment = description.strip - add_comment(comment) if comment && ! comment.empty? + add_comment(comment) if comment && !comment.empty? end - def comment=(comment) + def comment=(comment) # :nodoc: add_comment(comment) end - def add_comment(comment) + def add_comment(comment) # :nodoc: + return if comment.nil? @comments << comment unless @comments.include?(comment) end private :add_comment @@ -291,23 +336,23 @@ def transform_comments(separator, &block) private :transform_comments # Get the first sentence in a string. The sentence is terminated - # by the first period or the end of the line. Decimal points do - # not count as periods. + # by the first period, exclamation mark, or the end of the line. + # Decimal points do not count as periods. def first_sentence(string) - string.split(/\.[ \t]|\.$|\n/).first + string.split(/(?<=\w)(\.|!)[ \t]|(\.$|!)|\n/).first end private :first_sentence # Set the names of the arguments for this task. +args+ should be # an array of symbols, one for each argument name. def set_arg_names(args) - @arg_names = args.map { |a| a.to_sym } + @arg_names = args.map(&:to_sym) end # Return a string describing the internal state of a task. Useful for # debugging. def investigation - result = "------------------------------\n" + result = "------------------------------\n".dup result << "Investigating #{name}\n" result << "class: #{self.class}\n" result << "task needed: #{needed?}\n" @@ -318,12 +363,24 @@ def investigation prereqs.each do |p| result << "--#{p.name} (#{p.timestamp})\n" end - latest_prereq = prerequisite_tasks.map { |pre| pre.timestamp }.max + latest_prereq = prerequisite_tasks.map(&:timestamp).max result << "latest-prerequisite time: #{latest_prereq}\n" result << "................................\n\n" return result end + # Format dependencies parameter to pass to task. + def self.format_deps(deps) + deps = [deps] unless deps.respond_to?(:to_ary) + deps.map { |d| Rake.from_pathname(d).to_s } + end + + # Add order only dependencies. + def |(deps) + @order_only_prerequisites |= Task.format_deps(deps) - @prerequisites + self + end + # ---------------------------------------------------------------- # Rake Module Methods # @@ -369,7 +426,6 @@ def create_rule(*args, &block) # this kind of task. Generic tasks will accept the scope as # part of the name. def scope_name(scope, task_name) -# (scope + [task_name]).join(':') scope.path_with_task_name(task_name) end diff --git a/lib/rake/task_argument_error.rb b/lib/rake/task_argument_error.rb index 3e1dda64d..ef20076c6 100644 --- a/lib/rake/task_argument_error.rb +++ b/lib/rake/task_argument_error.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Rake # Error indicating an ill-formed task declaration. diff --git a/lib/rake/task_arguments.rb b/lib/rake/task_arguments.rb index 009468257..0d3001afd 100644 --- a/lib/rake/task_arguments.rb +++ b/lib/rake/task_arguments.rb @@ -1,32 +1,34 @@ +# frozen_string_literal: true module Rake - #################################################################### + ## # TaskArguments manage the arguments passed to a task. # class TaskArguments include Enumerable + # Argument names attr_reader :names - # Create a TaskArgument object with a list of named arguments - # (given by :names) and a set of associated values (given by - # :values). :parent is the parent argument object. + # Create a TaskArgument object with a list of argument +names+ and a set + # of associated +values+. +parent+ is the parent argument object. def initialize(names, values, parent=nil) @names = names @parent = parent @hash = {} @values = values names.each_with_index { |name, i| - @hash[name.to_sym] = values[i] unless values[i].nil? + next if values[i].nil? || values[i] == "" + @hash[name.to_sym] = values[i] } end - # Retrive the complete array of sequential values + # Retrieve the complete array of sequential values def to_a @values.dup end - # Retrive the list of values not associated with named arguments + # Retrieve the list of values not associated with named arguments def extras @values[@names.length..-1] || [] end @@ -50,33 +52,51 @@ def with_defaults(defaults) @hash = defaults.merge(@hash) end + # Enumerates the arguments and their values def each(&block) @hash.each(&block) end + # Extracts the argument values at +keys+ def values_at(*keys) keys.map { |k| lookup(k) } end + # Returns the value of the given argument via method_missing def method_missing(sym, *args) lookup(sym.to_sym) end + # Returns a Hash of arguments and their values def to_hash - @hash + @hash.dup end - def to_s - @hash.inspect + def to_s # :nodoc: + inspect end - def inspect - to_s + def inspect # :nodoc: + inspection = @hash.map do |k,v| + "#{k.to_s}: #{v.to_s}" + end.join(", ") + + "#<#{self.class} #{inspection}>" + end + + # Returns true if +key+ is one of the arguments + def has_key?(key) + @hash.has_key?(key) + end + alias key? has_key? + + def fetch(*args, &block) + @hash.fetch(*args, &block) end protected - def lookup(name) + def lookup(name) # :nodoc: if @hash.has_key?(name) @hash[name] elsif @parent @@ -85,5 +105,5 @@ def lookup(name) end end - EMPTY_TASK_ARGS = TaskArguments.new([], []) + EMPTY_TASK_ARGS = TaskArguments.new([], []) # :nodoc: end diff --git a/lib/rake/task_manager.rb b/lib/rake/task_manager.rb index 06c243a7b..97e3b9459 100644 --- a/lib/rake/task_manager.rb +++ b/lib/rake/task_manager.rb @@ -1,12 +1,12 @@ +# frozen_string_literal: true module Rake # The TaskManager module is a mixin for managing tasks. module TaskManager # Track the last comment made in the Rakefile. attr_accessor :last_description - alias :last_comment :last_description # Backwards compatibility - def initialize + def initialize # :nodoc: super @tasks = Hash.new @rules = Array.new @@ -14,24 +14,34 @@ def initialize @last_description = nil end - def create_rule(*args, &block) - pattern, args, deps = resolve_args(args) - pattern = Regexp.new(Regexp.quote(pattern) + '$') if String === pattern - @rules << [pattern, args, deps, block] + def create_rule(*args, &block) # :nodoc: + pattern, args, deps, order_only = resolve_args(args) + pattern = Regexp.new(Regexp.quote(pattern) + "$") if String === pattern + @rules << [pattern, args, deps, order_only, block] end - def define_task(task_class, *args, &block) - task_name, arg_names, deps = resolve_args(args) + def define_task(task_class, *args, &block) # :nodoc: + task_name, arg_names, deps, order_only = resolve_args(args) + + original_scope = @scope + if String === task_name and + not task_class.ancestors.include? Rake::FileTask + task_name, *definition_scope = *(task_name.split(":").reverse) + @scope = Scope.make(*(definition_scope + @scope.to_a)) + end + task_name = task_class.scope_name(@scope, task_name) - deps = [deps] unless deps.respond_to?(:to_ary) - deps = deps.map { |d| d.to_s } task = intern(task_class, task_name) task.set_arg_names(arg_names) unless arg_names.empty? if Rake::TaskManager.record_task_metadata add_location(task) task.add_description(get_description(task)) end - task.enhance(deps, &block) + task.enhance(Task.format_deps(deps), &block) + task | order_only unless order_only.nil? + task + ensure + @scope = original_scope end # Lookup a task. Return an existing task if found, otherwise @@ -46,16 +56,35 @@ def [](task_name, scopes=nil) self.lookup(task_name, scopes) or enhance_with_matching_rule(task_name) or synthesize_file_task(task_name) or - fail "Don't know how to build task '#{task_name}'" + fail generate_message_for_undefined_task(task_name) + end + + def generate_message_for_undefined_task(task_name) + message = "Don't know how to build task '#{task_name}' "\ + "(See the list of available tasks with `#{Rake.application.name} --tasks`)" + message + generate_did_you_mean_suggestions(task_name) end - def synthesize_file_task(task_name) + def generate_did_you_mean_suggestions(task_name) + return "" unless defined?(::DidYouMean::SpellChecker) + + suggestions = ::DidYouMean::SpellChecker.new(dictionary: @tasks.keys).correct(task_name.to_s) + if ::DidYouMean.respond_to?(:formatter)# did_you_mean v1.2.0 or later + ::DidYouMean.formatter.message_for(suggestions) + elsif defined?(::DidYouMean::Formatter) # before did_you_mean v1.2.0 + ::DidYouMean::Formatter.new(suggestions).to_s + else + "" + end + end + + def synthesize_file_task(task_name) # :nodoc: return nil unless File.exist?(task_name) define_task(Rake::FileTask, task_name) end - # Resolve the arguments for a task/rule. Returns a triplet of - # [task_name, arg_name_list, prerequisites]. + # Resolve the arguments for a task/rule. Returns a tuple of + # [task_name, arg_name_list, prerequisites, order_only_prerequisites]. def resolve_args(args) if args.last.is_a?(Hash) deps = args.pop @@ -80,7 +109,7 @@ def resolve_args_without_dependencies(args) else arg_names = args end - [task_name, arg_names, []] + [task_name, arg_names, [], nil] end private :resolve_args_without_dependencies @@ -89,23 +118,29 @@ def resolve_args_without_dependencies(args) # # The patterns recognized by this argument resolving function are: # + # task :t, order_only: [:e] # task :t => [:d] + # task :t => [:d], order_only: [:e] # task :t, [a] => [:d] + # task :t, [a] => [:d], order_only: [:e] # def resolve_args_with_dependencies(args, hash) # :nodoc: - fail "Task Argument Error" if hash.size != 1 + fail "Task Argument Error" if + hash.size != 1 && + (hash.size != 2 || !hash.key?(:order_only)) + order_only = hash.delete(:order_only) key, value = hash.map { |k, v| [k, v] }.first if args.empty? task_name = key arg_names = [] - deps = value + deps = value || [] else task_name = args.shift - arg_names = key - deps = value + arg_names = key || args.shift|| [] + deps = value || [] end deps = [deps] unless deps.respond_to?(:to_ary) - [task_name, arg_names, deps] + [task_name, arg_names, deps, order_only] end private :resolve_args_with_dependencies @@ -116,9 +151,10 @@ def resolve_args_with_dependencies(args, hash) # :nodoc: def enhance_with_matching_rule(task_name, level=0) fail Rake::RuleRecursionOverflowError, "Rule Recursion Too Deep" if level >= 16 - @rules.each do |pattern, args, extensions, block| - if pattern.match(task_name) - task = attempt_rule(task_name, args, extensions, block, level) + @rules.each do |pattern, args, extensions, order_only, block| + if pattern && pattern.match(task_name) + task = attempt_rule(task_name, pattern, args, extensions, block, level) + task | order_only unless order_only.nil? return task if task end end @@ -158,10 +194,10 @@ def lookup(task_name, initial_scope=nil) task_name = task_name.to_s if task_name =~ /^rake:/ scopes = Scope.make - task_name = task_name.sub(/^rake:/, '') + task_name = task_name.sub(/^rake:/, "") elsif task_name =~ /^(\^+)/ scopes = initial_scope.trim($1.size) - task_name = task_name.sub(/^(\^+)/, '') + task_name = task_name.sub(/^(\^+)/, "") else scopes = initial_scope end @@ -226,14 +262,14 @@ def generate_name "_anon_#{@seed}" end - def trace_rule(level, message) + def trace_rule(level, message) # :nodoc: options.trace_output.puts "#{" " * level}#{message}" if Rake.application.options.trace_rules end # Attempt to create a rule given the list of prerequisites. - def attempt_rule(task_name, args, extensions, block, level) - sources = make_sources(task_name, extensions) + def attempt_rule(task_name, task_pattern, args, extensions, block, level) + sources = make_sources(task_name, task_pattern, extensions) prereqs = sources.map { |source| trace_rule level, "Attempting Rule #{task_name} => #{source}" if File.exist?(source) || Rake::Task.task_defined?(source) @@ -247,14 +283,14 @@ def attempt_rule(task_name, args, extensions, block, level) return nil end } - task = FileTask.define_task(task_name, {args => prereqs}, &block) + task = FileTask.define_task(task_name, { args => prereqs }, &block) task.sources = prereqs task end # Make a list of sources from the list of file name extensions / # translation procs. - def make_sources(task_name, extensions) + def make_sources(task_name, task_pattern, extensions) result = extensions.map { |ext| case ext when /%/ @@ -262,10 +298,11 @@ def make_sources(task_name, extensions) when %r{/} ext when /^\./ - task_name.ext(ext) + source = task_name.sub(task_pattern, ext) + source == ext ? task_name.ext(ext) : source when String ext - when Proc + when Proc, Method if ext.arity == 1 ext.call(task_name) else @@ -278,9 +315,6 @@ def make_sources(task_name, extensions) result.flatten end - - private - # Return the current description, clearing it in the process. def get_description(task) desc = @last_description @@ -289,7 +323,7 @@ def get_description(task) end class << self - attr_accessor :record_task_metadata + attr_accessor :record_task_metadata # :nodoc: TaskManager.record_task_metadata = false end end diff --git a/lib/rake/tasklib.rb b/lib/rake/tasklib.rb index 48d27df9e..5354b4f94 100644 --- a/lib/rake/tasklib.rb +++ b/lib/rake/tasklib.rb @@ -1,4 +1,5 @@ -require 'rake' +# frozen_string_literal: true +require "rake" module Rake @@ -6,17 +7,6 @@ module Rake class TaskLib include Cloneable include Rake::DSL - - # Make a symbol by pasting two strings together. - # - # NOTE: DEPRECATED! This method is kinda stupid. I don't know why - # I didn't just use string interpolation. But now other task - # libraries depend on this so I can't remove it without breaking - # other people's code. So for now it stays for backwards - # compatibility. BUT DON'T USE IT. - def paste(a, b) # :nodoc: - (a.to_s + b.to_s).intern - end end end diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb index c693dd262..537627567 100644 --- a/lib/rake/testtask.rb +++ b/lib/rake/testtask.rb @@ -1,13 +1,13 @@ -# Define a task library for running unit tests. - -require 'rake' -require 'rake/tasklib' +# frozen_string_literal: true +require "rake" +require "rake/tasklib" module Rake # Create a task that runs a set of tests. # # Example: + # require "rake/testtask" # # Rake::TestTask.new do |t| # t.libs << "test" @@ -37,7 +37,7 @@ class TestTask < TaskLib # Name of test task. (default is :test) attr_accessor :name - # List of directories to added to $LOAD_PATH before running the + # List of directories added to $LOAD_PATH before running the # tests. (default is 'lib') attr_accessor :libs @@ -51,6 +51,7 @@ class TestTask < TaskLib # Request that the tests be run with the warning flag set. # E.g. warning=true implies "ruby -w" used to run the tests. + # (default is true) attr_accessor :warning # Glob pattern to match test files. (default is 'test/test*.rb') @@ -64,9 +65,15 @@ class TestTask < TaskLib # attr_accessor :loader - # Array of commandline options to pass to ruby when running test loader. + # Array of command line options to pass to ruby when running test loader. attr_accessor :ruby_opts + # Description of the test task. (default is 'Run tests') + attr_accessor :description + + # Task prerequisites. + attr_accessor :deps + # Explicitly define the list of test files to be included in a # test. +list+ is expected to be an array of file names (a # FileList is acceptable). If both +pattern+ and +test_files+ are @@ -83,19 +90,27 @@ def initialize(name=:test) @options = nil @test_files = nil @verbose = false - @warning = false + @warning = true @loader = :rake @ruby_opts = [] + @description = "Run tests" + (@name == :test ? "" : " for #{@name}") + @deps = [] + if @name.is_a?(Hash) + @deps = @name.values.first + @name = @name.keys.first + end yield self if block_given? - @pattern = 'test/test*.rb' if @pattern.nil? && @test_files.nil? + @pattern = "test/test*.rb" if @pattern.nil? && @test_files.nil? define end # Create the tasks defined by this task lib. def define - desc "Run tests" + (@name == :test ? "" : " for #{@name}") - task @name do + 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}" @@ -103,8 +118,16 @@ def define if !ok && status.respond_to?(:signaled?) && status.signaled? raise SignalException.new(status.termsig) elsif !ok - fail "Command failed with status (#{status.exitstatus}): " + - "[ruby #{args}]" + status = "Command failed with status (#{status.exitstatus})" + details = ": [ruby #{args}]" + message = + if Rake.application.options.trace or @verbose + status + details + else + status + end + + fail message end end end @@ -113,66 +136,57 @@ def define end def option_list # :nodoc: - (ENV['TESTOPTS'] || - ENV['TESTOPT'] || - ENV['TEST_OPTS'] || - ENV['TEST_OPT'] || + (ENV["TESTOPTS"] || + ENV["TESTOPT"] || + ENV["TEST_OPTS"] || + ENV["TEST_OPT"] || @options || "") end - def ruby_opts_string + def ruby_opts_string # :nodoc: opts = @ruby_opts.dup opts.unshift("-I\"#{lib_path}\"") unless @libs.empty? opts.unshift("-w") if @warning opts.join(" ") end - def lib_path + def lib_path # :nodoc: @libs.join(File::PATH_SEPARATOR) end - def file_list_string - file_list.map { |fn| "\"#{fn}\"" }.join(' ') + def file_list_string # :nodoc: + file_list.map { |fn| "\"#{fn}\"" }.join(" ") end def file_list # :nodoc: - if ENV['TEST'] - FileList[ENV['TEST']] + if ENV["TEST"] + FileList[ENV["TEST"]] else result = [] result += @test_files.to_a if @test_files - result << @pattern if @pattern + result += FileList[@pattern].to_a if @pattern result end end - def fix # :nodoc: - case ruby_version - when '1.8.2' - "\"#{find_file 'rake/ruby182_test_unit_fix'}\"" - else - nil - end || '' - end - - def ruby_version + def ruby_version # :nodoc: RUBY_VERSION end - def run_code + def run_code # :nodoc: case @loader when :direct "-e \"ARGV.each{|f| require f}\"" when :testrb - "-S testrb #{fix}" + "-S testrb" when :rake - "-I\"#{rake_lib_dir}\" \"#{rake_loader}\"" + "#{rake_include_arg} \"#{rake_loader}\"" end end def rake_loader # :nodoc: - find_file('rake/rake_test_loader') or + find_file("rake/rake_test_loader") or fail "unable to find rake test loader" end @@ -184,8 +198,17 @@ def find_file(fn) # :nodoc: nil end + def rake_include_arg # :nodoc: + spec = Gem.loaded_specs["rake"] + if spec.respond_to?(:default_gem?) && spec.default_gem? + "" + else + "-I\"#{rake_lib_dir}\"" + end + end + def rake_lib_dir # :nodoc: - find_dir('rake') or + find_dir("rake") or fail "unable to find rake lib" end diff --git a/lib/rake/thread_history_display.rb b/lib/rake/thread_history_display.rb index c2af9ecef..412ea37be 100644 --- a/lib/rake/thread_history_display.rb +++ b/lib/rake/thread_history_display.rb @@ -1,4 +1,5 @@ -require 'rake/private_reader' +# frozen_string_literal: true +require "rake/private_reader" module Rake @@ -9,8 +10,8 @@ class ThreadHistoryDisplay # :nodoc: all def initialize(stats) @stats = stats - @items = { :_seq_ => 1 } - @threads = { :_seq_ => "A" } + @items = { _seq_: 1 } + @threads = { _seq_: "A" } end def show diff --git a/lib/rake/thread_pool.rb b/lib/rake/thread_pool.rb index 44bc7483e..b01a5efe0 100644 --- a/lib/rake/thread_pool.rb +++ b/lib/rake/thread_pool.rb @@ -1,14 +1,14 @@ -require 'thread' -require 'set' +# frozen_string_literal: true +require "set" -require 'rake/promise' +require "rake/promise" module Rake - class ThreadPool # :nodoc: all + class ThreadPool # :nodoc: all - # Creates a ThreadPool object. - # The parameter is the size of the pool. + # Creates a ThreadPool object. The +thread_count+ parameter is the size + # of the pool. def initialize(thread_count) @max_active_threads = [thread_count, 0].max @threads = Set.new @@ -25,9 +25,9 @@ def initialize(thread_count) # Creates a future executed by the +ThreadPool+. # # The args are passed to the block when executing (similarly to - # Thread#new) The return value is an object representing + # Thread#new) The return value is an object representing # a future which has been created and added to the queue in the - # pool. Sending #value to the object will sleep the + # pool. Sending #value to the object will sleep the # current thread until the future is finished and will return the # result (or raise an exception thrown from the future) def future(*args, &block) @@ -35,7 +35,7 @@ def future(*args, &block) promise.recorder = lambda { |*stats| stat(*stats) } @queue.enq promise - stat :queued, :item_id => promise.object_id + stat :queued, item_id: promise.object_id start_thread promise end @@ -57,8 +57,7 @@ def join $stderr.puts e.backtrace.join("\n") @threads.each do |t| $stderr.print "Thread #{t} status = #{t.status}\n" - # 1.8 doesn't support Thread#backtrace - $stderr.puts t.backtrace.join("\n") if t.respond_to? :backtrace + $stderr.puts t.backtrace.join("\n") end raise e end @@ -84,8 +83,8 @@ def history # :nodoc: # Return a hash of always collected statistics for the thread pool. def statistics # :nodoc: { - :total_threads_in_play => @total_threads_in_play, - :max_active_threads => @max_active_threads, + total_threads_in_play: @total_threads_in_play, + max_active_threads: @max_active_threads, } end @@ -101,36 +100,43 @@ def process_queue_item #:nodoc: # is now gone. For this reason we pass true to Queue#deq # because we will sleep indefinitely if it is empty. promise = @queue.deq(true) - stat :dequeued, :item_id => promise.object_id + stat :dequeued, item_id: promise.object_id promise.work return true - rescue ThreadError # this means the queue is empty + rescue ThreadError # this means the queue is empty false end + def safe_thread_count + @threads_mon.synchronize do + @threads.count + end + end + def start_thread # :nodoc: @threads_mon.synchronize do next unless @threads.count < @max_active_threads t = Thread.new do begin - while @threads.count <= @max_active_threads + while safe_thread_count <= @max_active_threads break unless process_queue_item end ensure @threads_mon.synchronize do @threads.delete Thread.current - stat :ended, :thread_count => @threads.count + stat :ended, thread_count: @threads.count @join_cond.broadcast if @threads.empty? end end end + @threads << t stat( :spawned, - :new_thread => t.object_id, - :thread_count => @threads.count) + new_thread: t.object_id, + thread_count: @threads.count) @total_threads_in_play = @threads.count if @threads.count > @total_threads_in_play end @@ -139,10 +145,10 @@ def start_thread # :nodoc: def stat(event, data=nil) # :nodoc: return if @history_start_time.nil? info = { - :event => event, - :data => data, - :time => Time.now, - :thread => Thread.current.object_id, + event: event, + data: data, + time: Time.now, + thread: Thread.current.object_id, } @history_mon.synchronize { @history << info } end @@ -152,10 +158,6 @@ def stat(event, data=nil) # :nodoc: def __queue__ # :nodoc: @queue end - - def __threads__ # :nodoc: - @threads.dup - end end end diff --git a/lib/rake/trace_output.rb b/lib/rake/trace_output.rb index 1cd19451c..d713a0926 100644 --- a/lib/rake/trace_output.rb +++ b/lib/rake/trace_output.rb @@ -1,5 +1,6 @@ +# frozen_string_literal: true module Rake - module TraceOutput + module TraceOutput # :nodoc: all # Write trace output to output stream +out+. # @@ -13,7 +14,7 @@ def trace_on(out, *strings) else output = strings.map { |s| next if s.nil? - s =~ /#{sep}$/ ? s : s + sep + s.end_with?(sep) ? s : s + sep }.join end out.print(output) diff --git a/lib/rake/version.rb b/lib/rake/version.rb index 05c934d78..b5486ba79 100644 --- a/lib/rake/version.rb +++ b/lib/rake/version.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true module Rake - VERSION = '10.1.0' + VERSION = "13.0.1" module Version # :nodoc: all - MAJOR, MINOR, BUILD, *OTHER = Rake::VERSION.split '.' + MAJOR, MINOR, BUILD, *OTHER = Rake::VERSION.split "." NUMBERS = [MAJOR, MINOR, BUILD, *OTHER] end diff --git a/lib/rake/win32.rb b/lib/rake/win32.rb index edb33938b..6e6203181 100644 --- a/lib/rake/win32.rb +++ b/lib/rake/win32.rb @@ -1,10 +1,10 @@ +# frozen_string_literal: true +require "rbconfig" module Rake - require 'rake/alt_system' - # Win 32 interface methods for Rake. Windows specific functionality # will be placed here to collect that knowledge in one spot. - module Win32 + module Win32 # :nodoc: all # Error indicating a problem in locating the home directory on a # Win32 system. @@ -14,12 +14,7 @@ class Win32HomeError < RuntimeError class << self # True if running on a windows system. def windows? - AltSystem::WINDOWS - end - - # Run a command line on windows. - def rake_system(*cmd) - AltSystem.system(*cmd) + RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw|[Ww]indows)! end # The standard directory containing system wide rake files on @@ -33,22 +28,22 @@ def rake_system(*cmd) # # If the above are not defined, the return nil. def win32_system_dir #:nodoc: - win32_shared_path = ENV['HOME'] - if win32_shared_path.nil? && ENV['HOMEDRIVE'] && ENV['HOMEPATH'] - win32_shared_path = ENV['HOMEDRIVE'] + ENV['HOMEPATH'] + win32_shared_path = ENV["HOME"] + if win32_shared_path.nil? && ENV["HOMEDRIVE"] && ENV["HOMEPATH"] + win32_shared_path = ENV["HOMEDRIVE"] + ENV["HOMEPATH"] end - win32_shared_path ||= ENV['APPDATA'] - win32_shared_path ||= ENV['USERPROFILE'] + win32_shared_path ||= ENV["APPDATA"] + win32_shared_path ||= ENV["USERPROFILE"] raise Win32HomeError, "Unable to determine home path environment variable." if win32_shared_path.nil? or win32_shared_path.empty? - normalize(File.join(win32_shared_path, 'Rake')) + normalize(File.join(win32_shared_path, "Rake")) end # Normalize a win32 path so that the slashes are all forward slashes. def normalize(path) - path.gsub(/\\/, '/') + path.gsub(/\\/, "/") end end diff --git a/rake.blurb b/rake.blurb deleted file mode 100644 index f1b70d807..000000000 --- a/rake.blurb +++ /dev/null @@ -1,19 +0,0 @@ -name: rake -document: http://rake.rubyforge.org -download: http://rubyforge.org/project/showfiles.php?group_id=50 -description: > -

This package contains Rake, a simple ruby build program with - capabilities similar to make.

- -

Rake has the following features:

- -
    -
  • Rakefiles (rake’s version of Makefiles) are completely - defined in standard Ruby syntax. No XML files to edit. No quirky - Makefile syntax to worry about (is that a tab or a space?)
  • -
  • Users can specify tasks with prerequisites.
  • -
  • Rake supports rule patterns to synthesize implicit tasks.
  • -
  • Rake is lightweight. It can be distributed with other - projects as a single file. Projects that depend upon rake do not - require that rake be installed on target systems.
  • -
diff --git a/rake.gemspec b/rake.gemspec new file mode 100644 index 000000000..ecdec7299 --- /dev/null +++ b/rake.gemspec @@ -0,0 +1,43 @@ +# frozen_string_literal: true +$LOAD_PATH.unshift File.expand_path('../lib', __FILE__) +require 'rake/version' + +Gem::Specification.new do |s| + s.name = "rake".freeze + s.version = Rake::VERSION + s.authors = ["Hiroshi SHIBATA".freeze, "Eric Hodel".freeze, "Jim Weirich".freeze] + s.email = ["hsbt@ruby-lang.org".freeze, "drbrain@segment7.net".freeze, "".freeze] + + s.summary = "Rake is a Make-like program implemented in Ruby".freeze + s.description = <<-DESCRIPTION +Rake is a Make-like program implemented in Ruby. Tasks and dependencies are +specified in standard Ruby syntax. +Rake has the following features: + * Rakefiles (rake's version of Makefiles) are completely defined in standard Ruby syntax. + No XML files to edit. No quirky Makefile syntax to worry about (is that a tab or a space?) + * Users can specify tasks with prerequisites. + * Rake supports rule patterns to synthesize implicit tasks. + * Flexible FileLists that act like arrays but know about manipulating file names and paths. + * Supports parallel execution of tasks. + DESCRIPTION + s.homepage = "https://github.com/ruby/rake".freeze + s.licenses = ["MIT".freeze] + + s.metadata = { + "bug_tracker_uri" => "https://github.com/ruby/rake/issues", + "changelog_uri" => "https://github.com/ruby/rake/blob/v#{s.version}/History.rdoc", + "documentation_uri" => "https://ruby.github.io/rake", + "source_code_uri" => "https://github.com/ruby/rake/tree/v#{s.version}", + } + + s.files = %x[git ls-files -z].split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - + %w[.rubocop.yml .gitignore .travis.yml appveyor.yml] + s.bindir = "exe" + s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) } + s.require_paths = ["lib".freeze] + + s.required_ruby_version = Gem::Requirement.new(">= 2.2".freeze) + s.rubygems_version = "2.6.1".freeze + s.required_rubygems_version = Gem::Requirement.new(">= 1.3.2".freeze) + s.rdoc_options = ["--main".freeze, "README.rdoc".freeze] +end diff --git a/rakelib/metrics.rake b/rakelib/metrics.rake deleted file mode 100644 index 7b9dfdeb7..000000000 --- a/rakelib/metrics.rake +++ /dev/null @@ -1,10 +0,0 @@ -METRICS_FILES = FileList['lib/**/*.rb'] - -task :flog, [:all] do |t, args| - flags = args.all ? "--all" : "" - sh "flog #{flags} #{METRICS_FILES}" -end - -task :flay do - sh "flay #{METRICS_FILES}" -end diff --git a/rakelib/publish.rake b/rakelib/publish.rake deleted file mode 100644 index 40474abab..000000000 --- a/rakelib/publish.rake +++ /dev/null @@ -1,20 +0,0 @@ -# Optional publish task for Rake - -begin - require 'rake/contrib/sshpublisher' - require 'rake/contrib/rubyforgepublisher' - - publisher = Rake::SshDirPublisher.new( - 'linode', - 'htdocs/software/rake', - 'html') - - desc "Publish the Documentation to RubyForge." - task :publish => [:rdoc] do - publisher.upload - end - -rescue LoadError => ex - puts "#{ex.message} (#{ex.class})" - puts "No Publisher Task Available" -end diff --git a/rakelib/tags.rake b/rakelib/tags.rake deleted file mode 100644 index 7541577b0..000000000 --- a/rakelib/tags.rake +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env ruby - -module Tags - extend Rake::DSL if defined?(Rake::DSL) - - PROG = ENV['TAGS'] || 'ctags' - - RAKEFILES = FileList['Rakefile', '**/*.rake'] - - FILES = FileList['**/*.rb', '**/*.js'] + RAKEFILES - FILES.exclude('pkg', 'dist') - - DIR_LIST = ['.'] - DIR_LIST << Gem.dir - DIRS = DIR_LIST.join(" ") - - module_function - - # Convert key_word to --key-word. - def keyword(key) - k = key.to_s.gsub(/_/, '-') - (k.length == 1) ? "-#{k}" : "--#{k}" - end - - # Run ctags command - def run(*args) - opts = { - :e => true, - :totals => true, - :recurse => true, - } - opts = opts.merge(args.pop) if args.last.is_a?(Hash) - command_args = opts.map { |k, v| - (v == true) ? keyword(k) : "#{keyword(k)}=#{v}" - }.join(" ") - sh %{#{Tags::PROG} #{command_args} #{args.join(' ')}} - end -end - -namespace "tags" do - desc "Generate an Emacs TAGS file" - task :emacs => Tags::FILES do - puts "Making Emacs TAGS file" - verbose(true) do - Tags.run(Tags::DIRS) - Tags.run(Tags::RAKEFILES, - :language_force => "ruby", - :append => true) - end - end -end - -desc "Generate the TAGS file" -task :tags => ["tags:emacs"] - diff --git a/rakelib/test_times.rake b/rakelib/test_times.rake deleted file mode 100644 index daf1bc6e9..000000000 --- a/rakelib/test_times.rake +++ /dev/null @@ -1,25 +0,0 @@ -module TestTimes - def self.run(test_results, limit=0) - limit = limit.nonzero? || 10 - tests = [] - test_results.split(/\n/).each do |line| - if line =~ /^(.+?#[^:]+): ([0-9.]+) s: \.$/ - tests << [$1, $2.to_f, line] - end - end - - puts "#{limit} Slowest tests" - puts tests.sort_by { |item| - item[1] - }.reverse[0...limit].map { |item| - "%6.3f: %-s\n" % [item[1], item[0]] - } - end -end - -namespace :test do - desc "Find the slowest unit tests" - task :times, [:limit] do |t, args| - TestTimes.run `rake test:units TESTOPTS='--verbose'`, args.limit.to_i - end -end diff --git a/test/helper.rb b/test/helper.rb index 5e8700dfd..32456fde4 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -1,26 +1,25 @@ -require 'rubygems' -$:.unshift File.expand_path('../../lib', __FILE__) +# frozen_string_literal: true +$:.unshift File.expand_path("../../lib", __FILE__) begin - gem 'minitest' + if ENV["COVERALLS"] + gem "coveralls" + require "coveralls" + Coveralls.wear! + end rescue Gem::LoadError end -require 'minitest/autorun' -require 'rake' -require 'tmpdir' -require File.expand_path('../file_creation', __FILE__) - -require 'test/support/ruby_runner' -require 'test/support/rakefile_definitions' +gem "minitest", "~> 5" +require "minitest/autorun" +require "rake" +require "tmpdir" -begin - require_relative '../ruby/envutil' -rescue NoMethodError, LoadError - # for ruby trunk -end +require_relative "support/file_creation" +require_relative "support/ruby_runner" +require_relative "support/rakefile_definitions" -class Rake::TestCase < MiniTest::Unit::TestCase +class Rake::TestCase < Minitest::Test include FileCreation include Rake::DSL @@ -29,40 +28,30 @@ class TaskManager include Rake::TaskManager end - RUBY = defined?(EnvUtil) ? EnvUtil.rubybin : Gem.ruby + RUBY = File.realpath(ENV["RUBY"] || Gem.ruby) def setup ARGV.clear - test_dir = File.basename File.dirname File.expand_path __FILE__ - - @rake_root = - if test_dir == 'test' - # rake repository - File.expand_path '../../', __FILE__ - else - # ruby repository - File.expand_path '../../../', __FILE__ - end - - @verbose = ENV['VERBOSE'] + @verbose = ENV["VERBOSE"] - @rake_exec = File.join @rake_root, 'bin', 'rake' - @rake_lib = File.join @rake_root, 'lib' + @rake_root = File.expand_path "../../", __FILE__ + @rake_exec = File.join @rake_root, "exe", "rake" + @rake_lib = File.join @rake_root, "lib" @ruby_options = ["-I#{@rake_lib}", "-I."] @orig_pwd = Dir.pwd - @orig_appdata = ENV['APPDATA'] - @orig_home = ENV['HOME'] - @orig_homedrive = ENV['HOMEDRIVE'] - @orig_homepath = ENV['HOMEPATH'] - @orig_rake_columns = ENV['RAKE_COLUMNS'] - @orig_rake_system = ENV['RAKE_SYSTEM'] - @orig_rakeopt = ENV['RAKEOPT'] - @orig_userprofile = ENV['USERPROFILE'] - ENV.delete 'RAKE_COLUMNS' - ENV.delete 'RAKE_SYSTEM' - ENV.delete 'RAKEOPT' + @orig_appdata = ENV["APPDATA"] + @orig_home = ENV["HOME"] + @orig_homedrive = ENV["HOMEDRIVE"] + @orig_homepath = ENV["HOMEPATH"] + @orig_rake_columns = ENV["RAKE_COLUMNS"] + @orig_rake_system = ENV["RAKE_SYSTEM"] + @orig_rakeopt = ENV["RAKEOPT"] + @orig_userprofile = ENV["USERPROFILE"] + ENV.delete "RAKE_COLUMNS" + ENV.delete "RAKE_SYSTEM" + ENV.delete "RAKEOPT" tmpdir = Dir.chdir Dir.tmpdir do Dir.pwd end @tempdir = File.join tmpdir, "test_rake_#{$$}" @@ -81,18 +70,18 @@ def teardown FileUtils.rm_rf @tempdir if @orig_appdata - ENV['APPDATA'] = @orig_appdata + ENV["APPDATA"] = @orig_appdata else - ENV.delete 'APPDATA' + ENV.delete "APPDATA" end - ENV['HOME'] = @orig_home - ENV['HOMEDRIVE'] = @orig_homedrive - ENV['HOMEPATH'] = @orig_homepath - ENV['RAKE_COLUMNS'] = @orig_rake_columns - ENV['RAKE_SYSTEM'] = @orig_rake_system - ENV['RAKEOPT'] = @orig_rakeopt - ENV['USERPROFILE'] = @orig_userprofile + ENV["HOME"] = @orig_home + ENV["HOMEDRIVE"] = @orig_homedrive + ENV["HOMEPATH"] = @orig_homepath + ENV["RAKE_COLUMNS"] = @orig_rake_columns + ENV["RAKE_SYSTEM"] = @orig_rake_system + ENV["RAKEOPT"] = @orig_rakeopt + ENV["USERPROFILE"] = @orig_userprofile end def ignore_deprecations @@ -103,11 +92,11 @@ def ignore_deprecations end def rake_system_dir - @system_dir = 'system' + @system_dir = "system" FileUtils.mkdir_p @system_dir - open File.join(@system_dir, 'sys1.rake'), 'w' do |io| + open File.join(@system_dir, "sys1.rake"), "w" do |io| io << <<-SYS task "sys1" do puts "SYS1" @@ -115,14 +104,26 @@ def rake_system_dir SYS end - ENV['RAKE_SYSTEM'] = @system_dir + ENV["RAKE_SYSTEM"] = @system_dir end def rakefile(contents) - open 'Rakefile', 'w' do |io| + open "Rakefile", "w" do |io| io << contents end end + def jruby? + defined?(JRUBY_VERSION) + end + + def jruby17? + jruby? && (JRUBY_VERSION < "9.0.0.0") + end + + def jruby9? + jruby? && (JRUBY_VERSION >= "9.0.0.0") + end + include RakefileDefinitions end diff --git a/test/file_creation.rb b/test/support/file_creation.rb similarity index 96% rename from test/file_creation.rb rename to test/support/file_creation.rb index facc57a03..a1313bc0e 100644 --- a/test/file_creation.rb +++ b/test/support/file_creation.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module FileCreation OLDFILE = "old" NEWFILE = "new" diff --git a/test/support/rakefile_definitions.rb b/test/support/rakefile_definitions.rb index 5cc2ae129..5dacd3783 100644 --- a/test/support/rakefile_definitions.rb +++ b/test/support/rakefile_definitions.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module RakefileDefinitions include FileUtils @@ -19,9 +20,7 @@ def a_top_level_function end end -# TODO: remove `disabled_' when DeprecatedObjectDSL removed -task :obj -task :disabled_obj do +task :obj do begin Object.new.instance_eval { task :xyzzy } puts "BAD:D Rake DSL are polluting objects" @@ -41,6 +40,26 @@ def a_top_level_function ACCESS end + def rakefile_test_task + rakefile <<-RAKEFILE + require "rake/testtask" + + Rake::TestTask.new(:unit) do |t| + t.description = "custom test task description" + end + RAKEFILE + end + + def rakefile_test_task_verbose + rakefile <<-RAKEFILE + require "rake/testtask" + + Rake::TestTask.new(:unit) do |t| + t.verbose = true + end + RAKEFILE + end + def rakefile_chains rakefile <<-DEFAULT task :default => "play.app" @@ -59,6 +78,24 @@ def rakefile_chains DEFAULT end + def rakefile_file_chains + rakefile <<-RAKEFILE +file "fileA" do |t| + sh "echo contentA >\#{t.name}" +end + +file "fileB" => "fileA" do |t| + sh "(cat fileA; echo transformationB) >\#{t.name}" +end + +file "fileC" => "fileB" do |t| + sh "(cat fileB; echo transformationC) >\#{t.name}" +end + +task default: "fileC" + RAKEFILE + end + def rakefile_comments rakefile <<-COMMENTS # comment for t1 @@ -82,6 +119,18 @@ def rakefile_comments COMMENTS end + def rakefile_override + rakefile <<-OVERRIDE + task :t1 do + puts :foo + end + + task :t1 do + puts :bar + end + OVERRIDE + end + def rakefile_default rakefile <<-DEFAULT if ENV['TESTTOPSCOPE'] @@ -128,16 +177,16 @@ def rakefile_dryrun end DRYRUN - FileUtils.touch 'temp_main' - FileUtils.touch 'temp_two' + FileUtils.touch "temp_main" + FileUtils.touch "temp_two" end def rakefile_extra - rakefile 'task :default' + rakefile "task :default" - FileUtils.mkdir_p 'rakelib' + FileUtils.mkdir_p "rakelib" - open File.join('rakelib', 'extra.rake'), 'w' do |io| + open File.join("rakelib", "extra.rake"), "w" do |io| io << <<-EXTRA_RAKE # Added for testing @@ -206,7 +255,7 @@ def rakefile_imports puts "FIRST" IMPORTS - open 'deps.mf', 'w' do |io| + open "deps.mf", "w" do |io| io << <<-DEPS default: other DEPS @@ -217,6 +266,30 @@ def rakefile_imports end end + def rakefile_regenerate_imports + rakefile <<-REGENERATE_IMPORTS +task :default + +task :regenerate do + open("deps", "w") do |f| + f << <<-CONTENT +file "deps" => :regenerate +puts "REGENERATED" + CONTENT + end +end + +import "deps" + REGENERATE_IMPORTS + + open "deps", "w" do |f| + f << <<-CONTENT +file "deps" => :regenerate +puts "INITIAL" + CONTENT + end + end + def rakefile_multidesc rakefile <<-MULTIDESC task :b @@ -307,14 +380,14 @@ def rakefile_namespace end def rakefile_nosearch - FileUtils.touch 'dummy' + FileUtils.touch "dummy" end def rakefile_rakelib - FileUtils.mkdir_p 'rakelib' + FileUtils.mkdir_p "rakelib" - Dir.chdir 'rakelib' do - open 'test1.rb', 'w' do |io| + Dir.chdir "rakelib" do + open "test1.rb", "w" do |io| io << <<-TEST1 task :default do puts "TEST1" @@ -322,7 +395,7 @@ def rakefile_rakelib TEST1 end - open 'test2.rake', 'w' do |io| + open "test2.rake", "w" do |io| io << <<-TEST1 task :default do puts "TEST2" @@ -333,15 +406,15 @@ def rakefile_rakelib end def rakefile_rbext - open 'rakefile.rb', 'w' do |io| + open "rakefile.rb", "w" do |io| io << 'task :default do puts "OK" end' end end def rakefile_unittest - rakefile '# Empty Rakefile for Unit Test' + rakefile "# Empty Rakefile for Unit Test" - readme = File.join 'subdir', 'README' + readme = File.join "subdir", "README" FileUtils.mkdir_p File.dirname readme FileUtils.touch readme @@ -404,14 +477,14 @@ def rakefile_test_signal task :default => :test TEST_SIGNAL - open 'a_test.rb', 'w' do |io| + open "a_test.rb", "w" do |io| io << 'puts "ATEST"' << "\n" - io << '$stdout.flush' << "\n" + io << "$stdout.flush" << "\n" io << 'Process.kill("TERM", $$)' << "\n" end - open 'b_test.rb', 'w' do |io| + open "b_test.rb", "w" do |io| io << 'puts "BTEST"' << "\n" - io << '$stdout.flush' << "\n" + io << "$stdout.flush" << "\n" end end @@ -424,9 +497,9 @@ def rakefile_failing_test_task t.test_files = ['a_test.rb'] end TEST_TASK - open 'a_test.rb', 'w' do |io| + open "a_test.rb", "w" do |io| io << "require 'minitest/autorun'\n" - io << "class ExitTaskTest < MiniTest::Unit::TestCase\n" + io << "class ExitTaskTest < Minitest::Test\n" io << " def test_exit\n" io << " assert false, 'this should fail'\n" io << " end\n" @@ -435,7 +508,7 @@ def rakefile_failing_test_task end def rakefile_stand_alone_filelist - open 'stand_alone_filelist.rb', 'w' do |io| + open "stand_alone_filelist.rb", "w" do |io| io << "require 'rake/file_list'\n" io << "FL = Rake::FileList['*.rb']\n" io << "puts FL\n" diff --git a/test/support/ruby_runner.rb b/test/support/ruby_runner.rb index 404e61a66..160a57090 100644 --- a/test/support/ruby_runner.rb +++ b/test/support/ruby_runner.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module RubyRunner include FileUtils @@ -18,12 +19,13 @@ def rake(*rake_options) def run_ruby(option_list) puts "COMMAND: [#{RUBY} #{option_list.join ' '}]" if @verbose - inn, out, err, wait = Open3.popen3(RUBY, *option_list) - inn.close + Open3.popen3(RUBY, *option_list) do |inn, out, err, wait| + inn.close - @exit = wait ? wait.value : $? - @out = out.read - @err = err.read + @exit = wait ? wait.value : $? + @out = out.read + @err = err.read + end puts "OUTPUT: [#{@out}]" if @verbose puts "ERROR: [#{@err}]" if @verbose diff --git a/test/test_private_reader.rb b/test/test_private_reader.rb index f86d4249b..ee22e1b40 100644 --- a/test/test_private_reader.rb +++ b/test/test_private_reader.rb @@ -1,9 +1,10 @@ -require File.expand_path('../helper', __FILE__) -require 'rake/private_reader' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "rake/private_reader" -class TestPrivateAttrs < Rake::TestCase +class TestPrivateAttrs < Rake::TestCase # :nodoc: - class Sample + class Sample # :nodoc: include Rake::PrivateReader private_reader :reader, :a diff --git a/test/test_rake.rb b/test/test_rake.rb index b2a3928b2..a6d08fd35 100644 --- a/test/test_rake.rb +++ b/test/test_rake.rb @@ -1,18 +1,19 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRake < Rake::TestCase +class TestRake < Rake::TestCase # :nodoc: def test_each_dir_parent - assert_equal ['a'], alldirs('a') - assert_equal ['a/b', 'a'], alldirs('a/b') - assert_equal ['/a/b', '/a', '/'], alldirs('/a/b') + assert_equal ["a"], alldirs("a") + assert_equal ["a/b", "a"], alldirs("a/b") + assert_equal ["/a/b", "/a", "/"], alldirs("/a/b") if File.dirname("c:/foo") == "c:" # Under Unix - assert_equal ['c:/a/b', 'c:/a', 'c:'], alldirs('c:/a/b') - assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b') + assert_equal ["c:/a/b", "c:/a", "c:"], alldirs("c:/a/b") + assert_equal ["c:a/b", "c:a"], alldirs("c:a/b") else # Under Windows - assert_equal ['c:/a/b', 'c:/a', 'c:/'], alldirs('c:/a/b') - assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b') + assert_equal ["c:/a/b", "c:/a", "c:/"], alldirs("c:/a/b") + assert_equal ["c:a/b", "c:a"], alldirs("c:a/b") end end diff --git a/test/test_rake_application.rb b/test/test_rake_application.rb index aa5ed39f8..8514da354 100644 --- a/test/test_rake_application.rb +++ b/test/test_rake_application.rb @@ -1,6 +1,7 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakeApplication < Rake::TestCase +class TestRakeApplication < Rake::TestCase # :nodoc: def setup super @@ -9,6 +10,95 @@ def setup @app.options.rakelib = [] end + def test_class_with_application + orig_app = Rake.application + + return_app = Rake.with_application do |yield_app| + refute_equal orig_app, yield_app, "new application must be yielded" + + assert_equal yield_app, Rake.application, + "new application must be default in block" + end + + refute_equal orig_app, return_app, "new application not returned" + assert_equal orig_app, Rake.application, "original application not default" + end + + def test_class_with_application_user_defined + orig_app = Rake.application + + user_app = Rake::Application.new + + return_app = Rake.with_application user_app do |yield_app| + assert_equal user_app, yield_app, "user application must be yielded" + + assert_equal user_app, Rake.application, + "user application must be default in block" + end + + assert_equal user_app, return_app, "user application not returned" + assert_equal orig_app, Rake.application, "original application not default" + end + + def test_display_exception_details + obj = Object.new + obj.instance_eval("def #{__method__}; raise 'test'; end", "ruby") + begin + obj.__send__(__method__) + rescue => ex + end + + out, err = capture_io do + @app.set_default_options # reset trace output IO + + @app.display_error_message ex + end + + assert_empty out + + assert_match "rake aborted!", err + assert_match __method__.to_s, err + end + + def test_display_exception_details_bad_encoding + begin + raise "El Niño is coming!".dup.force_encoding("US-ASCII") + rescue => ex + end + + out, err = capture_io do + @app.set_default_options # reset trace output IO + + @app.display_error_message ex + end + + assert_empty out + assert_match "El Niño is coming!", err.force_encoding("UTF-8") + end + + def test_display_exception_details_cause + begin + raise "cause a" + rescue + begin + raise "cause b" + rescue => ex + end + end + + out, err = capture_io do + @app.set_default_options # reset trace output IO + + @app.display_error_message ex + end + + assert_empty out + + assert_match "Caused by:", err + assert_match "cause a", err + assert_match "cause b", err + end + def test_display_tasks @app.options.show_tasks = :tasks @app.options.show_task_pattern = // @@ -103,7 +193,7 @@ def test_show_lines @app.options.show_task_pattern = // @app.last_description = "COMMENT" @app.define_task(Rake::Task, "t") - @app['t'].locations << "HERE:1" + @app["t"].locations << "HERE:1" out, = capture_io do @app.instance_eval { display_tasks_and_comments } end assert_match(/^rake t +[^:]+:\d+ *$/, out) end @@ -115,7 +205,7 @@ def test_finding_rakefile end def test_not_finding_rakefile - @app.instance_eval { @rakefiles = ['NEVER_FOUND'] } + @app.instance_eval { @rakefiles = ["NEVER_FOUND"] } assert(! @app.instance_eval do have_rakefile end) assert_nil @app.rakefile end @@ -124,7 +214,7 @@ def test_load_rakefile rakefile_unittest @app.instance_eval do - handle_options + handle_options [] options.silent = true load_rakefile end @@ -149,10 +239,10 @@ def test_load_rakefile_doesnt_print_rakefile_directory_from_same_dir def test_load_rakefile_from_subdir rakefile_unittest - Dir.chdir 'subdir' + Dir.chdir "subdir" @app.instance_eval do - handle_options + handle_options [] options.silent = true load_rakefile end @@ -163,7 +253,7 @@ def test_load_rakefile_from_subdir def test_load_rakefile_prints_rakefile_directory_from_subdir rakefile_unittest - Dir.chdir 'subdir' + Dir.chdir "subdir" app = Rake::Application.new app.options.rakelib = [] @@ -179,11 +269,11 @@ def test_load_rakefile_prints_rakefile_directory_from_subdir def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent rakefile_unittest - Dir.chdir 'subdir' + Dir.chdir "subdir" _, err = capture_io do @app.instance_eval do - handle_options + handle_options [] options.silent = true raw_load_rakefile end @@ -193,16 +283,20 @@ def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent end def test_load_rakefile_not_found + skip if jruby9? + Dir.chdir @tempdir - ENV['RAKE_SYSTEM'] = 'not_exist' + ENV["RAKE_SYSTEM"] = "not_exist" @app.instance_eval do - handle_options + handle_options [] options.silent = true end ex = assert_raises(RuntimeError) do - @app.instance_eval do raw_load_rakefile end + @app.instance_eval do + raw_load_rakefile + end end assert_match(/no rakefile found/i, ex.message) @@ -212,7 +306,7 @@ def test_load_from_system_rakefile rake_system_dir @app.instance_eval do - handle_options + handle_options [] options.silent = true options.load_system = true options.rakelib = [] @@ -222,7 +316,7 @@ def test_load_from_system_rakefile assert_equal @system_dir, @app.system_dir assert_nil @app.rakefile rescue SystemExit - flunk 'failed to load rakefile' + flunk "failed to load rakefile" end def test_load_from_calculated_system_rakefile @@ -231,10 +325,10 @@ def @app.standard_system_dir "__STD_SYS_DIR__" end - ENV['RAKE_SYSTEM'] = nil + ENV["RAKE_SYSTEM"] = nil @app.instance_eval do - handle_options + handle_options [] options.silent = true options.load_system = true options.rakelib = [] @@ -243,22 +337,22 @@ def @app.standard_system_dir assert_equal "__STD_SYS_DIR__", @app.system_dir rescue SystemExit - flunk 'failed to find system rakefile' + flunk "failed to find system rakefile" end def test_terminal_columns - old_rake_columns = ENV['RAKE_COLUMNS'] + old_rake_columns = ENV["RAKE_COLUMNS"] - ENV['RAKE_COLUMNS'] = '42' + ENV["RAKE_COLUMNS"] = "42" app = Rake::Application.new assert_equal 42, app.terminal_columns ensure if old_rake_columns - ENV['RAKE_COLUMNS'].delete + ENV["RAKE_COLUMNS"] = old_rake_columns else - ENV['RAKE_COLUMNS'] = old_rake_columns + ENV.delete "RAKE_COLUMNS" end end @@ -291,34 +385,25 @@ def test_building_imported_files_on_demand # HACK no assertions end - def test_handle_options_should_strip_options_from_argv + def test_handle_options_should_not_strip_options_from_argv assert !@app.options.trace - valid_option = '--trace' - ARGV.clear - ARGV << valid_option - - @app.handle_options + argv = %w[--trace] + @app.handle_options argv - assert !ARGV.include?(valid_option) + assert_includes argv, "--trace" assert @app.options.trace end def test_handle_options_trace_default_is_stderr - ARGV.clear - ARGV << "--trace" - - @app.handle_options + @app.handle_options %w[--trace] assert_equal STDERR, @app.options.trace_output assert @app.options.trace end def test_handle_options_trace_overrides_to_stdout - ARGV.clear - ARGV << "--trace=stdout" - - @app.handle_options + @app.handle_options %w[--trace=stdout] assert_equal STDOUT, @app.options.trace_output assert @app.options.trace @@ -327,19 +412,16 @@ def test_handle_options_trace_overrides_to_stdout def test_handle_options_trace_does_not_eat_following_task_names assert !@app.options.trace - ARGV.clear - ARGV << "--trace" << "sometask" + argv = %w[--trace sometask] + @app.handle_options argv - @app.handle_options - assert ARGV.include?("sometask") + assert argv.include?("sometask") assert @app.options.trace end def test_good_run ran = false - ARGV << '--rakelib=""' - @app.options.silent = true @app.instance_eval do @@ -349,7 +431,7 @@ def test_good_run rakefile_default out, err = capture_io do - @app.run + @app.run %w[--rakelib=""] end assert ran @@ -359,11 +441,9 @@ def test_good_run def test_display_task_run ran = false - ARGV.clear - ARGV << '-f' << '-s' << '--tasks' << '--rakelib=""' @app.last_description = "COMMENT" @app.define_task(Rake::Task, "default") - out, = capture_io { @app.run } + out, = capture_io { @app.run %w[-f -s --tasks --rakelib=""] } assert @app.options.show_tasks assert ! ran assert_match(/rake default/, out) @@ -372,14 +452,12 @@ def test_display_task_run def test_display_prereqs ran = false - ARGV.clear - ARGV << '-f' << '-s' << '--prereqs' << '--rakelib=""' @app.last_description = "COMMENT" t = @app.define_task(Rake::Task, "default") t.enhance([:a, :b]) @app.define_task(Rake::Task, "a") @app.define_task(Rake::Task, "b") - out, = capture_io { @app.run } + out, = capture_io { @app.run %w[-f -s --prereqs --rakelib=""] } assert @app.options.show_prereqs assert ! ran assert_match(/rake a$/, out) @@ -389,56 +467,95 @@ def test_display_prereqs def test_bad_run @app.intern(Rake::Task, "default").enhance { fail } - ARGV.clear - ARGV << '-f' << '-s' << '--rakelib=""' - assert_raises(SystemExit) { - _, err = capture_io { @app.run } - assert_match(/see full trace/, err) + _, err = capture_io { + assert_raises(SystemExit) { @app.run %w[-f -s --rakelib=""] } } - ensure - ARGV.clear + assert_match(/see full trace/i, err) end def test_bad_run_with_trace @app.intern(Rake::Task, "default").enhance { fail } - ARGV.clear - ARGV << '-f' << '-s' << '-t' - assert_raises(SystemExit) { - _, err = capture_io { @app.run } - refute_match(/see full trace/, err) + _, err = capture_io { + @app.set_default_options + assert_raises(SystemExit) { @app.run %w[-f -s -t] } } - ensure - ARGV.clear + refute_match(/see full trace/i, err) end def test_bad_run_with_backtrace @app.intern(Rake::Task, "default").enhance { fail } - ARGV.clear - ARGV << '-f' << '-s' << '--backtrace' - assert_raises(SystemExit) { - _, err = capture_io { @app.run } - refute_match(/see full trace/, err) + _, err = capture_io { + assert_raises(SystemExit) { + @app.run %w[-f -s --backtrace] + } } - ensure - ARGV.clear + refute_match(/see full trace/, err) + end + + CustomError = Class.new(RuntimeError) + + def test_bad_run_includes_exception_name + @app.intern(Rake::Task, "default").enhance { + raise CustomError, "intentional" + } + _, err = capture_io { + assert_raises(SystemExit) { + @app.run %w[-f -s] + } + } + assert_match(/CustomError: intentional/, err) + end + + def test_rake_error_excludes_exception_name + @app.intern(Rake::Task, "default").enhance { + fail "intentional" + } + _, err = capture_io { + assert_raises(SystemExit) { + @app.run %w[-f -s] + } + } + refute_match(/RuntimeError/, err) + assert_match(/intentional/, err) + end + + def cause_supported? + ex = StandardError.new + ex.respond_to?(:cause) + end + + def test_printing_original_exception_cause + custom_error = Class.new(StandardError) + @app.intern(Rake::Task, "default").enhance { + begin + raise custom_error, "Original Error" + rescue custom_error + raise custom_error, "Secondary Error" + end + } + _ ,err = capture_io { + assert_raises(SystemExit) { + @app.run %w[-f -s] + } + } + if cause_supported? + assert_match(/Original Error/, err) + end + assert_match(/Secondary Error/, err) end def test_run_with_bad_options @app.intern(Rake::Task, "default").enhance { fail } - ARGV.clear - ARGV << '-f' << '-s' << '--xyzzy' assert_raises(SystemExit) { - capture_io { @app.run } + capture_io { @app.run %w[-f -s --xyzzy] } } - ensure - ARGV.clear end def test_standard_exception_handling_invalid_option out, err = capture_io do e = assert_raises SystemExit do @app.standard_exception_handling do - raise OptionParser::InvalidOption, 'blah' + raise OptionParser::InvalidOption, "blah" end end @@ -451,9 +568,11 @@ def test_standard_exception_handling_invalid_option def test_standard_exception_handling_other out, err = capture_io do + @app.set_default_options # reset trace output IO + e = assert_raises SystemExit do @app.standard_exception_handling do - raise 'blah' + raise "blah" end end @@ -499,15 +618,13 @@ def util_loader loader = Object.new loader.instance_variable_set :@load_called, false - def loader.load arg - raise 'called more than once' if @load_called - raise ArgumentError, arg unless arg == 'x.dummy' + def loader.load(arg) + raise ArgumentError, arg unless arg == "x.dummy" @load_called = true end loader.instance_variable_set :@make_dummy_called, false def loader.make_dummy - raise 'called more than once' if @make_dummy_called @make_dummy_called = true end diff --git a/test/test_rake_application_options.rb b/test/test_rake_application_options.rb index b3220b8a9..0ca06e264 100644 --- a/test/test_rake_application_options.rb +++ b/test/test_rake_application_options.rb @@ -1,52 +1,49 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) TESTING_REQUIRE = [] -class TestRakeApplicationOptions < Rake::TestCase +class TestRakeApplicationOptions < Rake::TestCase # :nodoc: def setup super - clear_argv + @testkey = ENV["TESTKEY"] Rake::FileUtilsExt.verbose_flag = false Rake::FileUtilsExt.nowrite_flag = false TESTING_REQUIRE.clear end def teardown - clear_argv + ENV["TESTKEY"] = @testkey Rake::FileUtilsExt.verbose_flag = false Rake::FileUtilsExt.nowrite_flag = false super end - def clear_argv - ARGV.pop until ARGV.empty? - end - def test_default_options opts = command_line - assert_nil opts.backtrace - assert_nil opts.dryrun - assert_nil opts.ignore_system - assert_nil opts.load_system - assert_nil opts.always_multitask - assert_nil opts.nosearch - assert_equal ['rakelib'], opts.rakelib - assert_nil opts.show_prereqs + assert_equal false, opts.backtrace + assert_equal false, opts.dryrun + assert_equal false, opts.ignore_system + assert_equal false, opts.load_system + assert_equal false, opts.always_multitask + assert_equal false, opts.nosearch + assert_equal ["rakelib"], opts.rakelib + assert_equal false, opts.show_prereqs assert_nil opts.show_task_pattern assert_nil opts.show_tasks - assert_nil opts.silent - assert_nil opts.trace - assert_nil opts.thread_pool_size - assert_equal ['rakelib'], opts.rakelib + assert_equal false, opts.silent + assert_equal false, opts.trace + assert_equal Rake.suggested_thread_count, opts.thread_pool_size + assert_equal ["rakelib"], opts.rakelib assert ! Rake::FileUtilsExt.verbose_flag assert ! Rake::FileUtilsExt.nowrite_flag end def test_dry_run - flags('--dry-run', '-n') do |opts| + flags("--dry-run", "-n") do |opts| assert opts.dryrun assert opts.trace assert Rake::FileUtilsExt.verbose_flag @@ -55,14 +52,14 @@ def test_dry_run end def test_describe - flags('--describe') do |opts| + flags("--describe") do |opts| assert_equal :describe, opts.show_tasks assert_equal(//.to_s, opts.show_task_pattern.to_s) end end def test_describe_with_pattern - flags('--describe=X') do |opts| + flags("--describe=X") do |opts| assert_equal :describe, opts.show_tasks assert_equal(/X/.to_s, opts.show_task_pattern.to_s) end @@ -70,7 +67,7 @@ def test_describe_with_pattern def test_execute $xyzzy = 0 - flags('--execute=$xyzzy=1', '-e $xyzzy=1') do |opts| + flags("--execute=$xyzzy=1", "-e $xyzzy=1") do assert_equal 1, $xyzzy assert_equal :exit, @exit $xyzzy = 0 @@ -79,7 +76,7 @@ def test_execute def test_execute_and_continue $xyzzy = 0 - flags('--execute-continue=$xyzzy=1', '-E $xyzzy=1') do |opts| + flags("--execute-continue=$xyzzy=1", "-E $xyzzy=1") do assert_equal 1, $xyzzy refute_equal :exit, @exit $xyzzy = 0 @@ -89,8 +86,8 @@ def test_execute_and_continue def test_execute_and_print $xyzzy = 0 out, = capture_io do - flags('--execute-print=$xyzzy="pugh"', '-p $xyzzy="pugh"') do |opts| - assert_equal 'pugh', $xyzzy + flags('--execute-print=$xyzzy="pugh"', '-p $xyzzy="pugh"') do + assert_equal "pugh", $xyzzy assert_equal :exit, @exit $xyzzy = 0 end @@ -101,7 +98,7 @@ def test_execute_and_print def test_help out, = capture_io do - flags '--help', '-H', '-h' + flags "--help", "-H", "-h" end assert_match(/\Arake/, out) @@ -111,56 +108,65 @@ def test_help end def test_jobs - flags(['--jobs', '4'], ['-j', '4']) do |opts| - assert_equal 4, opts.thread_pool_size + flags([]) do |opts| + assert_equal Rake.suggested_thread_count, opts.thread_pool_size + end + flags(["--jobs", "0"], ["-j", "0"]) do |opts| + assert_equal 0, opts.thread_pool_size + end + flags(["--jobs", "1"], ["-j", "1"]) do |opts| + assert_equal 0, opts.thread_pool_size + end + flags(["--jobs", "4"], ["-j", "4"]) do |opts| + assert_equal 3, opts.thread_pool_size end - flags(['--jobs', 'asdas'], ['-j', 'asdas']) do |opts| - assert_equal 2, opts.thread_pool_size + flags(["--jobs", "asdas"], ["-j", "asdas"]) do |opts| + assert_equal Rake.suggested_thread_count-1, opts.thread_pool_size end - flags('--jobs', '-j') do |opts| - assert_equal 2, opts.thread_pool_size + flags("--jobs", "-j") do |opts| + assert opts.thread_pool_size > 1_000_000, "thread pool size should be huge (was #{opts.thread_pool_size})" end end def test_libdir - flags(['--libdir', 'xx'], ['-I', 'xx'], ['-Ixx']) do |opts| - $:.include?('xx') + flags(["--libdir", "xx"], ["-I", "xx"], ["-Ixx"]) do + $:.include?("xx") end ensure - $:.delete('xx') + $:.delete("xx") end def test_multitask - flags('--multitask', '-m') do |opts| + flags("--multitask", "-m") do |opts| assert_equal opts.always_multitask, true end end def test_rakefile - flags(['--rakefile', 'RF'], ['--rakefile=RF'], ['-f', 'RF'], ['-fRF']) do |opts| - assert_equal ['RF'], @app.instance_eval { @rakefiles } + flags(["--rakefile", "RF"], ["--rakefile=RF"], ["-f", "RF"], ["-fRF"]) do + assert_equal ["RF"], @app.instance_eval { @rakefiles } end end def test_rakelib dirs = %w(A B C).join(File::PATH_SEPARATOR) flags( - ['--rakelibdir', dirs], + ["--rakelibdir", dirs], ["--rakelibdir=#{dirs}"], - ['-R', dirs], + ["-R", dirs], ["-R#{dirs}"]) do |opts| - assert_equal ['A', 'B', 'C'], opts.rakelib + assert_equal ["A", "B", "C"], opts.rakelib end end def test_require $LOAD_PATH.unshift @tempdir - open 'reqfile.rb', 'w' do |io| io << 'TESTING_REQUIRE << 1' end - open 'reqfile2.rb', 'w' do |io| io << 'TESTING_REQUIRE << 2' end - open 'reqfile3.rake', 'w' do |io| io << 'TESTING_REQUIRE << 3' end + open "reqfile.rb", "w" do |io| io << "TESTING_REQUIRE << 1" end + open "reqfile2.rb", "w" do |io| io << "TESTING_REQUIRE << 2" end + open "reqfile3.rake", "w" do |io| io << "TESTING_REQUIRE << 3" end - flags(['--require', 'reqfile'], '-rreqfile2', '-rreqfile3') + flags(["--require", "reqfile"], "-rreqfile2", "-rreqfile3") assert_includes TESTING_REQUIRE, 1 assert_includes TESTING_REQUIRE, 2 @@ -173,7 +179,7 @@ def test_require def test_missing_require ex = assert_raises(LoadError) do - flags(['--require', 'test/missing']) do |opts| + flags(["--require", "test/missing"]) do |opts| end end assert_match(/such file/, ex.message) @@ -181,47 +187,47 @@ def test_missing_require end def test_prereqs - flags('--prereqs', '-P') do |opts| + flags("--prereqs", "-P") do |opts| assert opts.show_prereqs end end def test_quiet Rake::FileUtilsExt.verbose_flag = true - flags('--quiet', '-q') do |opts| - assert ! Rake::FileUtilsExt.verbose_flag, "verbose flag shoud be false" + flags("--quiet", "-q") do |opts| + assert ! Rake::FileUtilsExt.verbose_flag, "verbose flag should be false" assert ! opts.silent, "should not be silent" end end def test_no_search - flags('--nosearch', '--no-search', '-N') do |opts| + flags("--nosearch", "--no-search", "-N") do |opts| assert opts.nosearch end end def test_silent Rake::FileUtilsExt.verbose_flag = true - flags('--silent', '-s') do |opts| + flags("--silent", "-s") do |opts| assert ! Rake::FileUtilsExt.verbose_flag, "verbose flag should be false" assert opts.silent, "should be silent" end end def test_system - flags('--system', '-g') do |opts| + flags("--system", "-g") do |opts| assert opts.load_system end end def test_no_system - flags('--no-system', '-G') do |opts| + flags("--no-system", "-G") do |opts| assert opts.ignore_system end end def test_trace - flags('--trace', '-t') do |opts| + flags("--trace", "-t") do |opts| assert opts.trace, "should enable trace option" assert opts.backtrace, "should enabled backtrace option" assert_equal $stderr, opts.trace_output @@ -231,7 +237,7 @@ def test_trace end def test_trace_with_stdout - flags('--trace=stdout', '-tstdout') do |opts| + flags("--trace=stdout", "-tstdout") do |opts| assert opts.trace, "should enable trace option" assert opts.backtrace, "should enabled backtrace option" assert_equal $stdout, opts.trace_output @@ -241,7 +247,7 @@ def test_trace_with_stdout end def test_trace_with_stderr - flags('--trace=stderr', '-tstderr') do |opts| + flags("--trace=stderr", "-tstderr") do |opts| assert opts.trace, "should enable trace option" assert opts.backtrace, "should enabled backtrace option" assert_equal $stderr, opts.trace_output @@ -252,23 +258,23 @@ def test_trace_with_stderr def test_trace_with_error ex = assert_raises(Rake::CommandLineOptionError) do - flags('--trace=xyzzy') do |opts| end + flags("--trace=xyzzy") do |opts| end end assert_match(/un(known|recognized).*\btrace\b.*xyzzy/i, ex.message) end def test_trace_with_following_task_name - flags(['--trace', 'taskname'], ['-t', 'taskname']) do |opts| + flags(["--trace", "taskname"], ["-t", "taskname"]) do |opts| assert opts.trace, "should enable trace option" assert opts.backtrace, "should enabled backtrace option" assert_equal $stderr, opts.trace_output assert Rake::FileUtilsExt.verbose_flag - assert_equal ['taskname'], @app.top_level_tasks + assert_equal ["taskname"], @app.top_level_tasks end end def test_backtrace - flags('--backtrace') do |opts| + flags("--backtrace") do |opts| assert opts.backtrace, "should enable backtrace option" assert_equal $stderr, opts.trace_output assert ! opts.trace, "should not enable trace option" @@ -276,7 +282,7 @@ def test_backtrace end def test_backtrace_with_stdout - flags('--backtrace=stdout') do |opts| + flags("--backtrace=stdout") do |opts| assert opts.backtrace, "should enable backtrace option" assert_equal $stdout, opts.trace_output assert ! opts.trace, "should not enable trace option" @@ -284,7 +290,7 @@ def test_backtrace_with_stdout end def test_backtrace_with_stderr - flags('--backtrace=stderr') do |opts| + flags("--backtrace=stderr") do |opts| assert opts.backtrace, "should enable backtrace option" assert_equal $stderr, opts.trace_output assert ! opts.trace, "should not enable trace option" @@ -293,38 +299,38 @@ def test_backtrace_with_stderr def test_backtrace_with_error ex = assert_raises(Rake::CommandLineOptionError) do - flags('--backtrace=xyzzy') do |opts| end + flags("--backtrace=xyzzy") do |opts| end end assert_match(/un(known|recognized).*\bbacktrace\b.*xyzzy/i, ex.message) end def test_backtrace_with_following_task_name - flags(['--backtrace', 'taskname']) do |opts| + flags(["--backtrace", "taskname"]) do |opts| assert ! opts.trace, "should enable trace option" assert opts.backtrace, "should enabled backtrace option" assert_equal $stderr, opts.trace_output - assert_equal ['taskname'], @app.top_level_tasks + assert_equal ["taskname"], @app.top_level_tasks end end def test_trace_rules - flags('--rules') do |opts| + flags("--rules") do |opts| assert opts.trace_rules end end def test_tasks - flags('--tasks', '-T') do |opts| + flags("--tasks", "-T") do |opts| assert_equal :tasks, opts.show_tasks assert_equal(//.to_s, opts.show_task_pattern.to_s) - assert_equal nil, opts.show_all_tasks + assert_equal false, opts.show_all_tasks end - flags(['--tasks', 'xyz'], ['-Txyz']) do |opts| + flags(["--tasks", "xyz"], ["-Txyz"]) do |opts| assert_equal :tasks, opts.show_tasks assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s) - assert_equal nil, opts.show_all_tasks + assert_equal false, opts.show_all_tasks end - flags(['--tasks', 'xyz', '--comments']) do |opts| + flags(["--tasks", "xyz", "--comments"]) do |opts| assert_equal :tasks, opts.show_tasks assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s) assert_equal false, opts.show_all_tasks @@ -332,17 +338,17 @@ def test_tasks end def test_where - flags('--where', '-W') do |opts| + flags("--where", "-W") do |opts| assert_equal :lines, opts.show_tasks assert_equal(//.to_s, opts.show_task_pattern.to_s) assert_equal true, opts.show_all_tasks end - flags(['--where', 'xyz'], ['-Wxyz']) do |opts| + flags(["--where", "xyz"], ["-Wxyz"]) do |opts| assert_equal :lines, opts.show_tasks assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s) assert_equal true, opts.show_all_tasks end - flags(['--where', 'xyz', '--comments'], ['-Wxyz', '--comments']) do |opts| + flags(["--where", "xyz", "--comments"], ["-Wxyz", "--comments"]) do |opts| assert_equal :lines, opts.show_tasks assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s) assert_equal false, opts.show_all_tasks @@ -350,14 +356,14 @@ def test_where end def test_no_deprecated_messages - flags('--no-deprecation-warnings', '-X') do |opts| + flags("--no-deprecation-warnings", "-X") do |opts| assert opts.ignore_deprecate end end def test_verbose capture_io do - flags('--verbose', '-v') do |opts| + flags("--verbose", "-v") do |opts| assert Rake::FileUtilsExt.verbose_flag, "verbose should be true" assert ! opts.silent, "opts should not be silent" end @@ -366,18 +372,18 @@ def test_verbose def test_version out, _ = capture_io do - flags '--version', '-V' + flags "--version", "-V" end assert_match(/\bversion\b/, out) - assert_match(/\b#{RAKEVERSION}\b/, out) + assert_match(/\b#{Rake::VERSION}\b/, out) assert_equal :exit, @exit end def test_bad_option _, err = capture_io do ex = assert_raises(OptionParser::InvalidOption) do - flags('--bad-option') + flags("--bad-option") end if ex.message =~ /^While/ # Ruby 1.9 error message @@ -388,7 +394,7 @@ def test_bad_option end end - assert_equal '', err + assert_equal "", err end def test_task_collection @@ -402,26 +408,26 @@ def test_default_task_collection end def test_environment_definition - ENV.delete('TESTKEY') + ENV.delete("TESTKEY") command_line("TESTKEY=12") - assert_equal '12', ENV['TESTKEY'] + assert_equal "12", ENV["TESTKEY"] end def test_multiline_environment_definition - ENV.delete('TESTKEY') + ENV.delete("TESTKEY") command_line("TESTKEY=a\nb\n") - assert_equal "a\nb\n", ENV['TESTKEY'] + assert_equal "a\nb\n", ENV["TESTKEY"] end def test_environment_and_tasks_together - ENV.delete('TESTKEY') + ENV.delete("TESTKEY") command_line("a", "b", "TESTKEY=12") assert_equal ["a", "b"], @tasks.sort - assert_equal '12', ENV['TESTKEY'] + assert_equal "12", ENV["TESTKEY"] end def test_rake_explicit_task_library - Rake.add_rakelib 'app/task', 'other' + Rake.add_rakelib "app/task", "other" libs = Rake.application.options.rakelib @@ -433,8 +439,6 @@ def test_rake_explicit_task_library def flags(*sets) sets.each do |set| - ARGV.clear - @exit = catch(:system_exit) { command_line(*set) } yield(@app.options) if block_given? @@ -442,14 +446,13 @@ def flags(*sets) end def command_line(*options) - options.each do |opt| ARGV << opt end @app = Rake::Application.new def @app.exit(*args) throw :system_exit, :exit end @app.instance_eval do - handle_options - collect_tasks + args = handle_options options + collect_command_line_tasks(args) end @tasks = @app.top_level_tasks @app.options diff --git a/test/test_rake_backtrace.rb b/test/test_rake_backtrace.rb index 8db3b5ab5..05a2dfda1 100644 --- a/test/test_rake_backtrace.rb +++ b/test/test_rake_backtrace.rb @@ -1,7 +1,8 @@ -require File.expand_path('../helper', __FILE__) -require 'open3' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "open3" -class TestBacktraceSuppression < Rake::TestCase +class TestBacktraceSuppression < Rake::TestCase # :nodoc: def test_bin_rake_suppressed paths = ["something/bin/rake:12"] @@ -11,7 +12,9 @@ def test_bin_rake_suppressed end def test_system_dir_suppressed - path = RbConfig::CONFIG['rubylibprefix'] + path = RbConfig::CONFIG["rubylibprefix"] + path = File.expand_path path + paths = [path + ":12"] actual = Rake::Backtrace.collapse(paths) @@ -20,7 +23,9 @@ def test_system_dir_suppressed end def test_near_system_dir_isnt_suppressed - path = RbConfig::CONFIG['rubylibprefix'] + path = RbConfig::CONFIG["rubylibprefix"] + path = File.expand_path path + paths = [" " + path + ":12"] actual = Rake::Backtrace.collapse(paths) @@ -29,14 +34,14 @@ def test_near_system_dir_isnt_suppressed end end -class TestRakeBacktrace < Rake::TestCase +class TestRakeBacktrace < Rake::TestCase # :nodoc: include RubyRunner def setup super - skip 'tmpdir is suppressed in backtrace' if - Dir.pwd =~ Rake::Backtrace::SUPPRESS_PATTERN + skip "tmpdir is suppressed in backtrace" if + Rake::Backtrace::SUPPRESS_PATTERN =~ Dir.pwd end def invoke(*args) diff --git a/test/test_rake_clean.rb b/test/test_rake_clean.rb index a6539fb21..b0b1ad602 100644 --- a/test/test_rake_clean.rb +++ b/test/test_rake_clean.rb @@ -1,13 +1,14 @@ -require File.expand_path('../helper', __FILE__) -require 'rake/clean' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "rake/clean" -class TestRakeClean < Rake::TestCase +class TestRakeClean < Rake::TestCase # :nodoc: def test_clean - load 'rake/clean.rb', true + load "rake/clean.rb", true - assert Rake::Task['clean'], "Should define clean" - assert Rake::Task['clobber'], "Should define clobber" - assert Rake::Task['clobber'].prerequisites.include?("clean"), + assert Rake::Task["clean"], "Should define clean" + assert Rake::Task["clobber"], "Should define clobber" + assert Rake::Task["clobber"].prerequisites.include?("clean"), "Clobber should require clean" end @@ -23,8 +24,65 @@ def test_cleanup remove_undeletable_file end + def test_cleanup_ignores_missing_files + file_name = File.join(@tempdir, "missing_directory", "no_such_file") + + out, _ = capture_io do + Rake::Cleaner.cleanup(file_name, verbose: false) + end + refute_match(/failed to remove/i, out) + end + + def test_cleanup_trace + file_name = create_file + + assert_output "", "rm -r #{file_name}\n" do + with_trace true do + Rake::Cleaner.cleanup(file_name) + end + end + end + + def test_cleanup_without_trace + file_name = create_file + + assert_output "", "" do + with_trace false do + Rake::Cleaner.cleanup(file_name) + end + end + end + + def test_cleanup_opt_overrides_trace_silent + file_name = create_file + + assert_output "", "" do + with_trace true do + Rake::Cleaner.cleanup(file_name, verbose: false) + end + end + end + + def test_cleanup_opt_overrides_trace_verbose + file_name = create_file + + assert_output "", "rm -r #{file_name}\n" do + with_trace false do + Rake::Cleaner.cleanup(file_name, verbose: true) + end + end + end + private + def create_file + dir_name = File.join(@tempdir, "deletedir") + file_name = File.join(dir_name, "deleteme") + FileUtils.mkdir(dir_name) + FileUtils.touch(file_name) + file_name + end + def create_undeletable_file dir_name = File.join(@tempdir, "deletedir") file_name = File.join(dir_name, "deleteme") @@ -32,7 +90,13 @@ def create_undeletable_file FileUtils.touch(file_name) FileUtils.chmod(0, file_name) FileUtils.chmod(0, dir_name) - file_name + begin + FileUtils.chmod(0644, file_name) + rescue + file_name + else + skip "Permission to delete files is different on this system" + end end def remove_undeletable_file @@ -43,4 +107,16 @@ def remove_undeletable_file Rake::Cleaner.cleanup(file_name, verbose: false) Rake::Cleaner.cleanup(dir_name, verbose: false) end + + def with_trace(value) + old, Rake.application.options.trace = + Rake.application.options.trace, value + + # FileUtils caches the $stderr object, which breaks capture_io et. al. + # We hack it here where it's convenient to do so. + Rake::Cleaner.instance_variable_set :@fileutils_output, nil + yield + ensure + Rake.application.options.trace = old + end end diff --git a/test/test_rake_cpu_counter.rb b/test/test_rake_cpu_counter.rb new file mode 100644 index 000000000..5d04e7c97 --- /dev/null +++ b/test/test_rake_cpu_counter.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) + +class TestRakeCpuCounter < Rake::TestCase # :nodoc: + + def setup + super + + @cpu_counter = Rake::CpuCounter.new + end + + def test_count + num = @cpu_counter.count + skip "cannot count CPU" if num == nil + assert_kind_of Numeric, num + assert_operator num, :>=, 1 + end + + def test_count_with_default_nil + def @cpu_counter.count; nil; end + assert_equal(8, @cpu_counter.count_with_default(8)) + assert_equal(4, @cpu_counter.count_with_default) + end + + def test_count_with_default_raise + def @cpu_counter.count; raise; end + assert_equal(8, @cpu_counter.count_with_default(8)) + assert_equal(4, @cpu_counter.count_with_default) + end + + class TestClassMethod < Rake::TestCase # :nodoc: + def setup + super + + @klass = Class.new(Rake::CpuCounter) + end + + def test_count + @klass.class_eval do + def count; 8; end + end + assert_equal(8, @klass.count) + end + + def test_count_nil + counted = false + @klass.class_eval do + define_method(:count) do + counted = true + nil + end + end + assert_equal(4, @klass.count) + assert_equal(true, counted) + end + + def test_count_raise + counted = false + @klass.class_eval do + define_method(:count) do + counted = true + raise + end + end + assert_equal(4, @klass.count) + assert_equal(true, counted) + end + end +end diff --git a/test/test_rake_definitions.rb b/test/test_rake_definitions.rb index 4b2de9d1d..52e468e3b 100644 --- a/test/test_rake_definitions.rb +++ b/test/test_rake_definitions.rb @@ -1,7 +1,8 @@ -require File.expand_path('../helper', __FILE__) -require 'fileutils' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "fileutils" -class TestRakeDefinitions < Rake::TestCase +class TestRakeDefinitions < Rake::TestCase # :nodoc: include Rake EXISTINGFILE = "existing" @@ -14,9 +15,9 @@ def setup def test_task done = false - task :one => [:two] do done = true end + task one: [:two] do done = true end task :two - task :three => [:one, :two] + task three: [:one, :two] check_tasks(:one, :two, :three) assert done, "Should be done" end @@ -34,19 +35,19 @@ def check_tasks(n1, n2, n3) t = Task[n1] assert Task === t, "Should be a Task" assert_equal n1.to_s, t.name - assert_equal [n2.to_s], t.prerequisites.map { |n| n.to_s } + assert_equal [n2.to_s], t.prerequisites.map(&:to_s) t.invoke t2 = Task[n2] assert_equal FileList[], t2.prerequisites t3 = Task[n3] - assert_equal [n1.to_s, n2.to_s], t3.prerequisites.map { |n| n.to_s } + assert_equal [n1.to_s, n2.to_s], t3.prerequisites.map(&:to_s) end def test_incremental_definitions runs = [] - task :t1 => [:t2] do runs << "A"; 4321 end - task :t1 => [:t3] do runs << "B"; 1234 end - task :t1 => [:t3] + task t1: [:t2] do runs << "A"; 4321 end + task t1: [:t3] do runs << "B"; 1234 end + task t1: [:t3] task :t2 task :t3 Task[:t1].invoke @@ -55,16 +56,21 @@ def test_incremental_definitions end def test_missing_dependencies - task :x => ["missing"] + task x: ["missing"] assert_raises(RuntimeError) { Task[:x].invoke } end + def test_falsey_dependencies + task x: nil + assert_equal [], Task[:x].prerequisites + end + def test_implicit_file_dependencies runs = [] create_existing_file - task :y => [EXISTINGFILE] do |t| runs << t.name end + task y: [EXISTINGFILE] do |t| runs << t.name end Task[:y].invoke - assert_equal runs, ['y'] + assert_equal runs, ["y"] end private # ---------------------------------------------------------- diff --git a/test/test_rake_directory_task.rb b/test/test_rake_directory_task.rb index 8ae7537b5..5635afd13 100644 --- a/test/test_rake_directory_task.rb +++ b/test/test_rake_directory_task.rb @@ -1,7 +1,9 @@ -require File.expand_path('../helper', __FILE__) -require 'fileutils' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "fileutils" +require "pathname" -class TestRakeDirectoryTask < Rake::TestCase +class TestRakeDirectoryTask < Rake::TestCase # :nodoc: include Rake def test_directory @@ -18,24 +20,30 @@ def test_directory assert_equal "DESC", Task["a/b/c"].comment verbose(false) { - Task['a/b'].invoke + Task["a/b"].invoke } assert File.exist?("a/b") refute File.exist?("a/b/c") end + def test_directory_colon + directory "a:b" + + assert_equal FileCreationTask, Task["a:b"].class + end unless Rake::Win32.windows? + if Rake::Win32.windows? def test_directory_win32 desc "WIN32 DESC" - directory 'c:/a/b/c' - assert_equal FileTask, Task['c:'].class - assert_equal FileCreationTask, Task['c:/a'].class - assert_equal FileCreationTask, Task['c:/a/b'].class - assert_equal FileCreationTask, Task['c:/a/b/c'].class - assert_nil Task['c:/'].comment - assert_equal "WIN32 DESC", Task['c:/a/b/c'].comment - assert_nil Task['c:/a/b'].comment + directory "c:/a/b/c" + assert_equal FileTask, Task["c:"].class + assert_equal FileCreationTask, Task["c:/a"].class + assert_equal FileCreationTask, Task["c:/a/b"].class + assert_equal FileCreationTask, Task["c:/a/b/c"].class + assert_nil Task["c:/"].comment + assert_equal "WIN32 DESC", Task["c:/a/b/c"].comment + assert_nil Task["c:/a/b"].comment end end @@ -54,4 +62,16 @@ def test_can_use_blocks assert_equal ["t2", "a/b/c"], runlist assert File.directory?("a/b/c") end + + def test_can_use_pathname + directory Pathname.new "a/b/c" + + assert_equal FileCreationTask, Task["a/b/c"].class + + verbose(false) { + Task["a/b/c"].invoke + } + + assert File.directory?("a/b/c") + end end diff --git a/test/test_rake_dsl.rb b/test/test_rake_dsl.rb index ad52f760b..6d0e7344d 100644 --- a/test/test_rake_dsl.rb +++ b/test/test_rake_dsl.rb @@ -1,6 +1,7 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakeDsl < Rake::TestCase +class TestRakeDsl < Rake::TestCase # :nodoc: def setup super diff --git a/test/test_rake_early_time.rb b/test/test_rake_early_time.rb index 18c4dad32..95040f67a 100644 --- a/test/test_rake_early_time.rb +++ b/test/test_rake_early_time.rb @@ -1,6 +1,7 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakeEarlyTime < Rake::TestCase +class TestRakeEarlyTime < Rake::TestCase # :nodoc: def test_create early = Rake::EarlyTime.instance assert early <= Time.now diff --git a/test/test_rake_extension.rb b/test/test_rake_extension.rb index 18d55f19f..aeb8ce148 100644 --- a/test/test_rake_extension.rb +++ b/test/test_rake_extension.rb @@ -1,9 +1,10 @@ -require File.expand_path('../helper', __FILE__) -require 'stringio' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "stringio" -class TestRakeExtension < Rake::TestCase +class TestRakeExtension < Rake::TestCase # :nodoc: - module Redirect + module Redirect # :nodoc: def error_redirect old_err = $stderr result = StringIO.new @@ -15,7 +16,7 @@ def error_redirect end end - class Sample + class Sample # :nodoc: extend Redirect def duplicate_method @@ -29,7 +30,6 @@ def ok_method end end - DUP_ERRS = error_redirect do rake_extension("duplicate_method") do def duplicate_method diff --git a/test/test_rake_file_creation_task.rb b/test/test_rake_file_creation_task.rb index d8dcd965a..05af13bb1 100644 --- a/test/test_rake_file_creation_task.rb +++ b/test/test_rake_file_creation_task.rb @@ -1,12 +1,11 @@ -require File.expand_path('../helper', __FILE__) -require 'fileutils' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "fileutils" -###################################################################### -class TestRakeFileCreationTask < Rake::TestCase +class TestRakeFileCreationTask < Rake::TestCase # :nodoc: include Rake - include Rake::DSL - DUMMY_DIR = 'dummy_dir' + DUMMY_DIR = "dummy_dir" def setup super @@ -21,7 +20,7 @@ def test_file_needed FileUtils.rm_rf fc_task.name assert fc_task.needed?, "file should be needed" FileUtils.mkdir fc_task.name - assert_equal nil, fc_task.prerequisites.map { |n| Task[n].timestamp }.max + assert_nil fc_task.prerequisites.map { |n| Task[n].timestamp }.max assert ! fc_task.needed?, "file should not be needed" end diff --git a/test/test_rake_file_list.rb b/test/test_rake_file_list.rb index 899f3bc50..eda55d29f 100644 --- a/test/test_rake_file_list.rb +++ b/test/test_rake_file_list.rb @@ -1,7 +1,9 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "pathname" -class TestRakeFileList < Rake::TestCase - FileList = Rake::FileList +class TestRakeFileList < Rake::TestCase # :nodoc: + FileList = Rake::FileList # :nodoc: def setup super @@ -21,9 +23,9 @@ def setup FileUtils.touch "abc.x" FileUtils.touch "existing" - open 'xyzzy.txt', 'w' do |io| - io.puts 'x' - io.puts 'XYZZY' + open "xyzzy.txt", "w" do |io| + io.puts "x" + io.puts "XYZZY" end end @@ -46,6 +48,12 @@ def test_create_with_args fl.sort end + def test_create_with_pathname + fl = FileList.new(Pathname.new("*.c")) + assert_equal ["abc.c", "x.c", "xyz.c"].sort, + fl.sort + end + def test_create_with_block fl = FileList.new { |f| f.include("x") } assert_equal ["x"], fl.resolve @@ -74,18 +82,30 @@ def test_include_with_another_filelist fl.sort end + def test_include_with_pathname + fl = FileList.new.include(Pathname.new("*.c")) + assert_equal ["abc.c", "x.c", "xyz.c"].sort, + fl.sort + end + def test_append fl = FileList.new fl << "a.rb" << "b.rb" - assert_equal ['a.rb', 'b.rb'], fl + assert_equal ["a.rb", "b.rb"], fl + end + + def test_append_pathname + fl = FileList.new + fl << Pathname.new("a.rb") + assert_equal ["a.rb"], fl end def test_add_many fl = FileList.new fl.include %w(a d c) - fl.include('x', 'y') - assert_equal ['a', 'd', 'c', 'x', 'y'], fl - assert_equal ['a', 'd', 'c', 'x', 'y'], fl.resolve + fl.include("x", "y") + assert_equal ["a", "d", "c", "x", "y"], fl + assert_equal ["a", "d", "c", "x", "y"], fl.resolve end def test_add_return @@ -98,7 +118,7 @@ def test_add_return def test_match fl = FileList.new - fl.include '*.c' + fl.include "*.c" assert_equal %w[abc.c x.c xyz.c], fl.sort end @@ -106,18 +126,18 @@ def test_match def test_add_matching fl = FileList.new fl << "a.java" - fl.include '*.c' + fl.include "*.c" assert_equal %w[a.java abc.c x.c xyz.c], fl.sort end def test_multiple_patterns fl = FileList.new - fl.include('*.z', '*foo*') + fl.include("*.z", "*foo*") assert_equal [], fl - fl.include('*.c', '*xist*') + fl.include("*.c", "*xist*") assert_equal %w[x.c xyz.c abc.c existing].sort, fl.sort end @@ -145,8 +165,8 @@ def test_reject end def test_exclude - fl = FileList['x.c', 'abc.c', 'xyz.c', 'existing'] - fl.each { |fn| touch fn, :verbose => false } + fl = FileList["x.c", "abc.c", "xyz.c", "existing"] + fl.each { |fn| touch fn, verbose: false } x = fl.exclude(%r{^x.+\.}) @@ -154,34 +174,59 @@ def test_exclude assert_equal %w(x.c abc.c existing), fl assert_equal fl.object_id, x.object_id - fl.exclude('*.c') + fl.exclude("*.c") - assert_equal ['existing'], fl + assert_equal ["existing"], fl - fl.exclude('existing') + fl.exclude("existing") assert_equal [], fl end + def test_exclude_pathname + fl = FileList["x.c", "abc.c", "other"] + fl.each { |fn| touch fn, verbose: false } + + fl.exclude(Pathname.new("*.c")) + + assert_equal ["other"], fl + end + def test_excluding_via_block - fl = FileList['a.c', 'b.c', 'xyz.c'] - fl.exclude { |fn| fn.pathmap('%n') == 'xyz' } + fl = FileList["a.c", "b.c", "xyz.c"] + fl.exclude { |fn| fn.pathmap("%n") == "xyz" } assert fl.excluded_from_list?("xyz.c"), "Should exclude xyz.c" - assert_equal ['a.c', 'b.c'], fl + assert_equal ["a.c", "b.c"], fl end def test_exclude_return_on_create - fl = FileList['*'].exclude(/.*\.[hcx]$/) + fl = FileList["*"].exclude(/.*\.[hcx]$/) assert_equal %w[cfiles existing xyzzy.txt], fl.sort assert_equal FileList, fl.class end def test_exclude_with_string_return_on_create - fl = FileList['*'].exclude('abc.c') + fl = FileList["*"].exclude("abc.c") assert_equal %w[abc.h abc.x cfiles existing x.c xyz.c xyzzy.txt], fl.sort assert_equal FileList, fl.class end + def test_exclude_curly_bracket_pattern + fl = FileList["*"].exclude("{abc,xyz}.c") + assert_equal %w[abc.h abc.x cfiles existing x.c xyzzy.txt], fl + end + + def test_exclude_an_array + fl = FileList["*"].exclude(["existing", "*.c"]) + assert_equal %w[abc.h abc.x cfiles xyzzy.txt], fl + end + + def test_exclude_a_filelist + excluded = FileList["existing", "*.c"] + fl = FileList["*"].exclude(excluded) + assert_equal %w[abc.h abc.x cfiles xyzzy.txt], fl + end + def test_default_exclude fl = FileList.new fl.clear_exclude @@ -193,9 +238,9 @@ def test_default_exclude def test_unique fl = FileList.new fl << "x.c" << "a.c" << "b.rb" << "a.c" - assert_equal ['x.c', 'a.c', 'b.rb', 'a.c'], fl + assert_equal ["x.c", "a.c", "b.rb", "a.c"], fl fl.uniq! - assert_equal ['x.c', 'a.c', 'b.rb'], fl + assert_equal ["x.c", "a.c", "b.rb"], fl end def test_to_string @@ -206,15 +251,15 @@ def test_to_string end def test_to_array - fl = FileList['a.java', 'b.java'] - assert_equal ['a.java', 'b.java'], fl.to_a + fl = FileList["a.java", "b.java"] + assert_equal ["a.java", "b.java"], fl.to_a assert_equal Array, fl.to_a.class - assert_equal ['a.java', 'b.java'], fl.to_ary + assert_equal ["a.java", "b.java"], fl.to_ary assert_equal Array, fl.to_ary.class end def test_to_s_pending - fl = FileList['abc.*'] + fl = FileList["abc.*"] result = fl.to_s assert_match(%r{abc\.c}, result) assert_match(%r{abc\.h}, result) @@ -223,7 +268,7 @@ def test_to_s_pending end def test_inspect_pending - fl = FileList['abc.*'] + fl = FileList["abc.*"] result = fl.inspect assert_match(%r{"abc\.c"}, result) assert_match(%r{"abc\.h"}, result) @@ -244,24 +289,24 @@ def test_sub end def test_claim_to_be_a_kind_of_array - fl = FileList['*.c'] + fl = FileList["*.c"] assert fl.is_a?(Array) assert fl.kind_of?(Array) end def test_claim_to_be_a_kind_of_filelist - fl = FileList['*.c'] + fl = FileList["*.c"] assert fl.is_a?(FileList) assert fl.kind_of?(FileList) end def test_claim_to_be_a_filelist_instance - fl = FileList['*.c'] + fl = FileList["*.c"] assert fl.instance_of?(FileList) end def test_dont_claim_to_be_an_array_instance - fl = FileList['*.c'] + fl = FileList["*.c"] assert ! fl.instance_of?(Array) end @@ -298,7 +343,7 @@ def test_string_ext assert_equal ".onerc.net", ".onerc.dot".ext("net") assert_equal ".onerc.net", ".onerc".ext("net") assert_equal ".a/.onerc.net", ".a/.onerc".ext("net") - assert_equal "one", "one.two".ext('') + assert_equal "one", "one.two".ext("") assert_equal "one", "one.two".ext assert_equal ".one", ".one.two".ext assert_equal ".one", ".one".ext @@ -312,8 +357,8 @@ def test_string_ext end def test_filelist_ext - assert_equal FileList['one.c', '.one.c'], - FileList['one.net', '.one'].ext('c') + assert_equal FileList["one.c", ".one.c"], + FileList["one.net", ".one"].ext("c") end def test_gsub @@ -331,12 +376,12 @@ def test_gsub! end def test_egrep_returns_0_if_no_matches - files = FileList['test/lib/*_test.rb'].exclude("test/lib/filelist_test.rb") - assert_equal 0, files.egrep(/XYZZY/) { } + files = FileList["test/lib/*_test.rb"].exclude("test/lib/filelist_test.rb") + assert_equal 0, files.egrep(/XYZZY/) {} end def test_egrep_with_output - files = FileList['*.txt'] + files = FileList["*.txt"] out, = capture_io do files.egrep(/XYZZY/) @@ -346,7 +391,7 @@ def test_egrep_with_output end def test_egrep_with_block - files = FileList['*.txt'] + files = FileList["*.txt"] found = nil files.egrep(/XYZZY/) do |fn, ln, line| @@ -357,7 +402,7 @@ def test_egrep_with_block end def test_egrep_with_error - files = FileList['*.txt'] + files = FileList["*.txt"] _, err = capture_io do files.egrep(/XYZZY/) do |fn, ln, line | @@ -369,20 +414,20 @@ def test_egrep_with_error end def test_existing - fl = FileList['abc.c', 'notthere.c'] + fl = FileList["*c.c", "notthere.c", "a*.c"] assert_equal ["abc.c"], fl.existing assert fl.existing.is_a?(FileList) end def test_existing! - fl = FileList['abc.c', 'notthere.c'] + fl = FileList["*c.c", "notthere.c", "a*.c"] result = fl.existing! assert_equal ["abc.c"], fl assert_equal fl.object_id, result.object_id end def test_ignore_special - f = FileList['*'] + f = FileList["*"] assert ! f.include?("CVS"), "Should not contain CVS" assert ! f.include?(".svn"), "Should not contain .svn" assert ! f.include?(".dummy"), "Should not contain dot files" @@ -392,7 +437,7 @@ def test_ignore_special end def test_clear_ignore_patterns - f = FileList['*', '.svn'] + f = FileList["*", ".svn"] f.clear_exclude assert f.include?("abc.c") assert f.include?("xyz.c") @@ -425,63 +470,65 @@ def test_add_default_exclude_list end def test_basic_array_functions - f = FileList['b', 'c', 'a'] - assert_equal 'b', f.first - assert_equal 'b', f[0] - assert_equal 'a', f.last - assert_equal 'a', f[2] - assert_equal 'a', f[-1] - assert_equal ['a', 'b', 'c'], f.sort + f = FileList["b", "c", "a"] + assert_equal "b", f.first + assert_equal "b", f[0] + assert_equal "a", f.last + assert_equal "a", f[2] + assert_equal "a", f[-1] + assert_equal ["a", "b", "c"], f.sort f.sort! - assert_equal ['a', 'b', 'c'], f + assert_equal ["a", "b", "c"], f end def test_flatten - assert_equal ['a', 'x.c', 'xyz.c', 'abc.c'].sort, - ['a', FileList['*.c']].flatten.sort + assert_equal ["a", "x.c", "xyz.c", "abc.c"].sort, + ["a", FileList["*.c"]].flatten.sort end def test_clone_and_dup - a = FileList['a', 'b', 'c'] - c = a.clone - d = a.dup - a << 'd' - assert_equal ['a', 'b', 'c', 'd'], a - assert_equal ['a', 'b', 'c'], c - assert_equal ['a', 'b', 'c'], d - end - - def test_dup_and_clone_replicate_taint - a = FileList['a', 'b', 'c'] - a.taint + a = FileList["a", "b", "c"] c = a.clone d = a.dup - assert c.tainted?, "Clone should be tainted" - assert d.tainted?, "Dup should be tainted" + a << "d" + assert_equal ["a", "b", "c", "d"], a + assert_equal ["a", "b", "c"], c + assert_equal ["a", "b", "c"], d + end + + if RUBY_VERSION < '2.7' + def test_dup_and_clone_replicate_taint + a = FileList["a", "b", "c"] + a.taint + c = a.clone + d = a.dup + assert c.tainted?, "Clone should be tainted" + assert d.tainted?, "Dup should be tainted" + end end def test_duped_items_will_thaw - a = FileList['a', 'b', 'c'] + a = FileList["a", "b", "c"] a.freeze d = a.dup - d << 'more' - assert_equal ['a', 'b', 'c', 'more'], d + d << "more" + assert_equal ["a", "b", "c", "more"], d end def test_cloned_items_stay_frozen - a = FileList['a', 'b', 'c'] + a = FileList["a", "b", "c"] a.freeze c = a.clone assert_raises(TypeError, RuntimeError) do - c << 'more' + c << "more" end end def test_array_comparisons - fl = FileList['b', 'b'] - a = ['b', 'a'] - b = ['b', 'b'] - c = ['b', 'c'] + fl = FileList["b", "b"] + a = ["b", "a"] + b = ["b", "b"] + c = ["b", "c"] assert_equal(1, fl <=> a) assert_equal(0, fl <=> b) assert_equal(-1, fl <=> c) @@ -491,8 +538,8 @@ def test_array_comparisons end def test_array_equality - a = FileList['a', 'b'] - b = ['a', 'b'] + a = FileList["a", "b"] + b = ["a", "b"] assert a == b assert b == a # assert a.eql?(b) @@ -502,126 +549,141 @@ def test_array_equality end def test_enumeration_methods - a = FileList['a', 'b'] - b = a.map { |it| it.upcase } - assert_equal ['A', 'B'], b + a = FileList["a", "b"] + b = a.map(&:upcase) + assert_equal ["A", "B"], b assert_equal FileList, b.class - b = a.map { |it| it.upcase } - assert_equal ['A', 'B'], b + b = a.map(&:upcase) + assert_equal ["A", "B"], b assert_equal FileList, b.class b = a.sort - assert_equal ['a', 'b'], b + assert_equal ["a", "b"], b assert_equal FileList, b.class b = a.sort_by { |it| it } - assert_equal ['a', 'b'], b + assert_equal ["a", "b"], b assert_equal FileList, b.class - b = a.select { |it| it == 'b' } - assert_equal ['b'], b + b = a.select { |it| it == "b" } + assert_equal ["b"], b assert_equal FileList, b.class b = a.select { |it| it.size == 1 } - assert_equal ['a', 'b'], b + assert_equal ["a", "b"], b assert_equal FileList, b.class - b = a.reject { |it| it == 'b' } - assert_equal ['a'], b + b = a.reject { |it| it == "b" } + assert_equal ["a"], b assert_equal FileList, b.class b = a.grep(/./) - assert_equal ['a', 'b'], b + assert_equal ["a", "b"], b assert_equal FileList, b.class - b = a.partition { |it| it == 'b' } - assert_equal [['b'], ['a']], b + b = a.partition { |it| it == "b" } + assert_equal [["b"], ["a"]], b assert_equal Array, b.class assert_equal FileList, b[0].class assert_equal FileList, b[1].class - b = a.zip(['x', 'y']).to_a - assert_equal [['a', 'x'], ['b', 'y']], b + b = a.zip(["x", "y"]).to_a + assert_equal [["a", "x"], ["b", "y"]], b assert_equal Array, b.class assert_equal Array, b[0].class assert_equal Array, b[1].class end def test_array_operators - a = ['a', 'b'] - b = ['c', 'd'] - f = FileList['x', 'y'] - g = FileList['w', 'z'] + a = ["a", "b"] + b = ["c", "d"] + f = FileList["x", "y"] + g = FileList["w", "z"] r = f + g - assert_equal ['x', 'y', 'w', 'z'], r + assert_equal ["x", "y", "w", "z"], r assert_equal FileList, r.class r = a + g - assert_equal ['a', 'b', 'w', 'z'], r + assert_equal ["a", "b", "w", "z"], r assert_equal Array, r.class r = f + b - assert_equal ['x', 'y', 'c', 'd'], r + assert_equal ["x", "y", "c", "d"], r assert_equal FileList, r.class - r = FileList['w', 'x', 'y', 'z'] - f - assert_equal ['w', 'z'], r + r = FileList["w", "x", "y", "z"] - f + assert_equal ["w", "z"], r assert_equal FileList, r.class - r = FileList['w', 'x', 'y', 'z'] & f - assert_equal ['x', 'y'], r + r = FileList["w", "x", "y", "z"] & f + assert_equal ["x", "y"], r assert_equal FileList, r.class r = f * 2 - assert_equal ['x', 'y', 'x', 'y'], r + assert_equal ["x", "y", "x", "y"], r assert_equal FileList, r.class - r = f * ',' - assert_equal 'x,y', r + r = f * "," + assert_equal "x,y", r assert_equal String, r.class - r = f | ['a', 'x'] - assert_equal ['a', 'x', 'y'].sort, r.sort + r = f | ["a", "x"] + assert_equal ["a", "x", "y"].sort, r.sort assert_equal FileList, r.class end def test_other_array_returning_methods - f = FileList['a', nil, 'b'] + f = FileList["a", nil, "b"] r = f.compact - assert_equal ['a', 'b'], r + assert_equal ["a", "b"], r assert_equal FileList, r.class - f = FileList['a', 'b'] - r = f.concat(['x', 'y']) - assert_equal ['a', 'b', 'x', 'y'], r + f = FileList["a", "b"] + r = f.concat(["x", "y"]) + assert_equal ["a", "b", "x", "y"], r assert_equal FileList, r.class - f = FileList['a', ['b', 'c'], FileList['d', 'e']] + f = FileList["a", ["b", "c"], FileList["d", "e"]] r = f.flatten - assert_equal ['a', 'b', 'c', 'd', 'e'], r + assert_equal ["a", "b", "c", "d", "e"], r assert_equal FileList, r.class - f = FileList['a', 'b', 'a'] + f = FileList["a", "b", "a"] r = f.uniq - assert_equal ['a', 'b'], r + assert_equal ["a", "b"], r assert_equal FileList, r.class - f = FileList['a', 'b', 'c', 'd'] + f = FileList["a", "b", "c", "d"] r = f.values_at(1, 3) - assert_equal ['b', 'd'], r + assert_equal ["b", "d"], r assert_equal FileList, r.class end + def test_special_return_delegating_methods_object_type + custom_file_list = Class.new(FileList) + f = custom_file_list.new + + FileList::SPECIAL_RETURN.each do |m| + r = if [].method(m).arity == 1 + f.send(m, []) + else + f.send(m) + end + + assert_equal custom_file_list, r.class + end + end + def test_file_utils_can_use_filelists - cfiles = FileList['*.c'] + cfiles = FileList["*.c"] - cp cfiles, @cdir, :verbose => false + cp cfiles, @cdir, verbose: false - assert File.exist?(File.join(@cdir, 'abc.c')) - assert File.exist?(File.join(@cdir, 'xyz.c')) - assert File.exist?(File.join(@cdir, 'x.c')) + assert File.exist?(File.join(@cdir, "abc.c")) + assert File.exist?(File.join(@cdir, "xyz.c")) + assert File.exist?(File.join(@cdir, "x.c")) end end diff --git a/test/test_rake_file_list_path_map.rb b/test/test_rake_file_list_path_map.rb index 5935dc268..2c51a2d72 100644 --- a/test/test_rake_file_list_path_map.rb +++ b/test/test_rake_file_list_path_map.rb @@ -1,8 +1,15 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakeFileListPathMap < Rake::TestCase +class TestRakeFileListPathMap < Rake::TestCase # :nodoc: def test_file_list_supports_pathmap - assert_equal ['a', 'b'], FileList['dir/a.rb', 'dir/b.rb'].pathmap("%n") + assert_equal ["a", "b"], FileList["dir/a.rb", "dir/b.rb"].pathmap("%n") end -end + def test_file_list_supports_pathmap_with_a_block + mapped = FileList["dir/a.rb", "dir/b.rb"].pathmap("%{.*,*}n") do |name| + name.upcase + end + assert_equal ["A", "B"], mapped + end +end diff --git a/test/test_rake_file_task.rb b/test/test_rake_file_task.rb index fa3241b78..61303d88a 100644 --- a/test/test_rake_file_task.rb +++ b/test/test_rake_file_task.rb @@ -1,7 +1,9 @@ -require File.expand_path('../helper', __FILE__) -require 'fileutils' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "fileutils" +require "pathname" -class TestRakeFileTask < Rake::TestCase +class TestRakeFileTask < Rake::TestCase # :nodoc: include Rake def setup @@ -23,10 +25,11 @@ def test_file_need File.delete(ftask.name) rescue nil assert ftask.needed?, "file should be needed" + assert_equal Rake::LATE, ftask.timestamp open(ftask.name, "w") { |f| f.puts "HI" } - assert_equal nil, ftask.prerequisites.map { |n| Task[n].timestamp }.max + assert_nil ftask.prerequisites.map { |n| Task[n].timestamp }.max assert ! ftask.needed?, "file should not be needed" ensure File.delete(ftask.name) rescue nil @@ -74,7 +77,7 @@ def test_file_depends_on_task_depend_on_file create_timed_files(OLDFILE, NEWFILE) file NEWFILE => [:obj] do |t| @runs << t.name end - task :obj => [OLDFILE] do |t| @runs << t.name end + task obj: [OLDFILE] do |t| @runs << t.name end file OLDFILE do |t| @runs << t.name end Task[:obj].invoke @@ -83,19 +86,92 @@ def test_file_depends_on_task_depend_on_file end def test_existing_file_depends_on_non_existing_file - @ran = false - create_file(OLDFILE) delete_file(NEWFILE) - file NEWFILE do - @ran = true - end - - file OLDFILE => NEWFILE + file NEWFILE do |t| @runs << t.name end + file OLDFILE => NEWFILE do |t| @runs << t.name end Task[OLDFILE].invoke - assert @ran + assert_equal [NEWFILE, OLDFILE], @runs + end + + def test_needed_eh_build_all + create_file "a" + + file "a" + + a_task = Task["a"] + + refute a_task.needed? + + Rake.application.options.build_all = true + + assert a_task.needed? + ensure + delete_file "a" + end + + def test_needed_eh_dependency + create_file "a", Time.now + create_file "b", Time.now - 60 + + create_file "c", Time.now + create_file "d", Time.now - 60 + + file "b" => "a" + + b_task = Task["b"] + + assert b_task.needed? + + file "c" => "d" + + c_task = Task["c"] + + refute c_task.needed? + ensure + delete_file "old" + delete_file "new" + end + + def test_needed_eh_exists + name = "dummy" + file name + + ftask = Task[name] + + assert ftask.needed? + + create_file name + + refute ftask.needed? + ensure + delete_file name + end + + def test_source_is_first_prerequisite + t = file f: ["preqA", "preqB"] + assert_equal "preqA", t.source + end + + def test_sources_is_all_prerequisites + t = file f: ["preqA", "preqB"] + assert_equal ["preqA", "preqB"], t.sources + end + + def test_task_can_be_pathname + name = "dummy" + file Pathname.new name + + ftask = Task[name] + + assert_equal name.to_s, ftask.name + end + + def test_prerequisite_can_be_pathname + t = file f: Pathname.new("preq") + assert_equal "preq", t.source end # I have currently disabled this test. I'm not convinced that diff --git a/test/test_rake_file_utils.rb b/test/test_rake_file_utils.rb index 37d33dc39..ebedd56b2 100644 --- a/test/test_rake_file_utils.rb +++ b/test/test_rake_file_utils.rb @@ -1,12 +1,18 @@ -require File.expand_path('../helper', __FILE__) -require 'fileutils' -require 'stringio' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "fileutils" +require "stringio" -class TestRakeFileUtils < Rake::TestCase +class TestRakeFileUtils < Rake::TestCase # :nodoc: + def setup + super + @rake_test_sh = ENV["RAKE_TEST_SH"] + end def teardown FileUtils::LN_SUPPORTED[0] = true RakeFileUtils.verbose_flag = Rake::FileUtilsExt::DEFAULT + ENV["RAKE_TEST_SH"] = @rake_test_sh super end @@ -33,15 +39,31 @@ def test_rm_filelist refute File.exist?("b") end + def test_rm_nowrite + create_file("a") + nowrite(true) { + rm_rf "a" + } + assert File.exist?("a") + nowrite(false) { + rm_rf "a", noop: true + } + assert File.exist?("a") + nowrite(true) { + rm_rf "a", noop: false + } + refute File.exist?("a") + end + def test_ln open("a", "w") { |f| f.puts "TEST_LN" } - Rake::FileUtilsExt.safe_ln("a", "b", :verbose => false) + Rake::FileUtilsExt.safe_ln("a", "b", verbose: false) - assert_equal "TEST_LN\n", File.read('b') + assert_equal "TEST_LN\n", File.read("b") end - class BadLink + class BadLink # :nodoc: include Rake::FileUtilsExt attr_reader :cp_args @@ -64,16 +86,16 @@ def test_safe_ln_failover_to_cp_on_standard_error FileUtils::LN_SUPPORTED[0] = true c = BadLink.new(StandardError) c.safe_ln "a", "b" - assert_equal ['a', 'b'], c.cp_args + assert_equal ["a", "b"], c.cp_args c.safe_ln "x", "y" - assert_equal ['x', 'y'], c.cp_args + assert_equal ["x", "y"], c.cp_args end def test_safe_ln_failover_to_cp_on_not_implemented_error FileUtils::LN_SUPPORTED[0] = true c = BadLink.new(NotImplementedError) c.safe_ln "a", "b" - assert_equal ['a', 'b'], c.cp_args + assert_equal ["a", "b"], c.cp_args end def test_safe_ln_fails_on_script_error @@ -130,18 +152,57 @@ def test_sh def test_sh_with_a_single_string_argument check_expansion - ENV['RAKE_TEST_SH'] = 'someval' + ENV["RAKE_TEST_SH"] = "someval" verbose(false) { sh %{#{RUBY} check_expansion.rb #{env_var} someval} } end + def test_sh_with_env + check_environment + + env = { + "RAKE_TEST_SH" => "someval" + } + + verbose(false) { + sh env, RUBY, "check_environment.rb", "RAKE_TEST_SH", "someval" + } + end + def test_sh_with_multiple_arguments + skip if jruby9? # https://github.com/jruby/jruby/issues/3653 + check_no_expansion - ENV['RAKE_TEST_SH'] = 'someval' + ENV["RAKE_TEST_SH"] = "someval" verbose(false) { - sh RUBY, 'check_no_expansion.rb', env_var, 'someval' + sh RUBY, "check_no_expansion.rb", env_var, "someval" + } + end + + def test_sh_with_spawn_options + skip "JRuby does not support spawn options" if jruby? + + echocommand + + r, w = IO.pipe + + verbose(false) { + sh RUBY, "echocommand.rb", out: w + } + + w.close + + assert_equal "echocommand.rb\n", r.read + end + + def test_sh_with_hash_option + skip "JRuby does not support spawn options" if jruby? + check_expansion + + verbose(false) { + sh "#{RUBY} check_expansion.rb", { chdir: "." }, verbose: false } end @@ -175,15 +236,19 @@ def test_sh_special_handling def test_sh_noop shellcommand - verbose(false) { sh %{shellcommand.rb 1}, :noop=>true } + verbose(false) { sh %{shellcommand.rb 1}, noop: true } assert true, "should not fail" end def test_sh_bad_option + # Skip on JRuby because option checking is performed by spawn via system + # now. + skip "JRuby does not support spawn options" if jruby? + shellcommand ex = assert_raises(ArgumentError) { - verbose(false) { sh %{shellcommand.rb}, :bad_option=>true } + verbose(false) { sh %{shellcommand.rb}, bad_option: true } } assert_match(/bad_option/, ex.message) end @@ -193,7 +258,7 @@ def test_sh_verbose _, err = capture_io do verbose(true) { - sh %{shellcommand.rb}, :noop=>true + sh %{shellcommand.rb}, noop: true } end @@ -205,11 +270,11 @@ def test_sh_verbose_false _, err = capture_io do verbose(false) { - sh %{shellcommand.rb}, :noop=>true + sh %{shellcommand.rb}, noop: true } end - assert_equal '', err + assert_equal "", err end def test_sh_verbose_flag_nil @@ -218,14 +283,14 @@ def test_sh_verbose_flag_nil RakeFileUtils.verbose_flag = nil assert_silent do - sh %{shellcommand.rb}, :noop=>true + sh %{shellcommand.rb}, noop: true end end def test_ruby_with_a_single_string_argument check_expansion - ENV['RAKE_TEST_SH'] = 'someval' + ENV["RAKE_TEST_SH"] = "someval" verbose(false) { replace_ruby { @@ -234,34 +299,50 @@ def test_ruby_with_a_single_string_argument } end + def test_sh_show_command + env = { + "RAKE_TEST_SH" => "someval" + } + + cmd = [env, RUBY, "some_file.rb", "some argument"] + + show_cmd = send :sh_show_command, cmd + + expected_cmd = "RAKE_TEST_SH=someval #{RUBY} some_file.rb some argument" + + assert_equal expected_cmd, show_cmd + end + def test_ruby_with_multiple_arguments + skip if jruby9? # https://github.com/jruby/jruby/issues/3653 + check_no_expansion - ENV['RAKE_TEST_SH'] = 'someval' + ENV["RAKE_TEST_SH"] = "someval" verbose(false) { replace_ruby { - ruby 'check_no_expansion.rb', env_var, 'someval' + ruby "check_no_expansion.rb", env_var, "someval" } } end def test_split_all - assert_equal ['a'], Rake::FileUtilsExt.split_all('a') - assert_equal ['..'], Rake::FileUtilsExt.split_all('..') - assert_equal ['/'], Rake::FileUtilsExt.split_all('/') - assert_equal ['a', 'b'], Rake::FileUtilsExt.split_all('a/b') - assert_equal ['/', 'a', 'b'], Rake::FileUtilsExt.split_all('/a/b') - assert_equal ['..', 'a', 'b'], Rake::FileUtilsExt.split_all('../a/b') + assert_equal ["a"], Rake::FileUtilsExt.split_all("a") + assert_equal [".."], Rake::FileUtilsExt.split_all("..") + assert_equal ["/"], Rake::FileUtilsExt.split_all("/") + assert_equal ["a", "b"], Rake::FileUtilsExt.split_all("a/b") + assert_equal ["/", "a", "b"], Rake::FileUtilsExt.split_all("/a/b") + assert_equal ["..", "a", "b"], Rake::FileUtilsExt.split_all("../a/b") end def command(name, text) - open name, 'w', 0750 do |io| + open name, "w", 0750 do |io| io << text end end def check_no_expansion - command 'check_no_expansion.rb', <<-CHECK_EXPANSION + command "check_no_expansion.rb", <<-CHECK_EXPANSION if ARGV[0] != ARGV[1] exit 0 else @@ -270,8 +351,18 @@ def check_no_expansion CHECK_EXPANSION end + def check_environment + command "check_environment.rb", <<-CHECK_ENVIRONMENT +if ENV[ARGV[0]] != ARGV[1] + exit 1 +else + exit 0 +end + CHECK_ENVIRONMENT + end + def check_expansion - command 'check_expansion.rb', <<-CHECK_EXPANSION + command "check_expansion.rb", <<-CHECK_EXPANSION if ARGV[0] != ARGV[1] exit 1 else @@ -280,6 +371,16 @@ def check_expansion CHECK_EXPANSION end + def echocommand + command "echocommand.rb", <<-ECHOCOMMAND +#!/usr/bin/env ruby + +puts "echocommand.rb" + +exit 0 + ECHOCOMMAND + end + def replace_ruby ruby = FileUtils::RUBY FileUtils.send :remove_const, :RUBY @@ -291,7 +392,7 @@ def replace_ruby end def shellcommand - command 'shellcommand.rb', <<-SHELLCOMMAND + command "shellcommand.rb", <<-SHELLCOMMAND #!/usr/bin/env ruby exit((ARGV[0] || "0").to_i) @@ -299,7 +400,7 @@ def shellcommand end def env_var - windows? ? '%RAKE_TEST_SH%' : '$RAKE_TEST_SH' + windows? ? "%RAKE_TEST_SH%" : "$RAKE_TEST_SH" end def windows? diff --git a/test/test_rake_ftp_file.rb b/test/test_rake_ftp_file.rb deleted file mode 100644 index 5749b8a5e..000000000 --- a/test/test_rake_ftp_file.rb +++ /dev/null @@ -1,74 +0,0 @@ -require File.expand_path('../helper', __FILE__) -require 'date' -require 'time' -require 'rake/contrib/ftptools' - -class FakeDate - def self.today - Date.new(2003, 10, 3) - end - - def self.now - Time.local(2003, 10, 3, 12, 00, 00) - end -end - -class TestRakeFtpFile < Rake::TestCase - - def setup - super - - Rake::FtpFile.class_eval { - @date_class = FakeDate - @time_class = FakeDate - } - end - - def test_general - file = Rake::FtpFile.new( - "here", - "-rw-r--r-- 1 a279376 develop 121770 Mar 6 14:50 wiki.pl") - assert_equal "wiki.pl", file.name - assert_equal "here/wiki.pl", file.path - assert_equal "a279376", file.owner - assert_equal "develop", file.group - assert_equal 0644, file.mode - assert_equal 121_770, file.size - assert_equal Time.mktime(2003, 3, 6, 14, 50, 0, 0), file.time - assert ! file.directory? - assert ! file.symlink? - end - - def test_far_date - file = Rake::FtpFile.new( - ".", - "drwxr-xr-x 3 a279376 develop 4096 Nov 26 2001 vss") - assert_equal Time.mktime(2001, 11, 26, 0, 0, 0, 0), file.time - end - - def test_close_date - file = Rake::FtpFile.new( - ".", - "drwxr-xr-x 3 a279376 develop 4096 Nov 26 15:35 vss") - assert_equal Time.mktime(2002, 11, 26, 15, 35, 0, 0), file.time - end - - def test_directory - file = Rake::FtpFile.new( - ".", - "drwxrwxr-x 9 a279376 develop 4096 Mar 13 14:32 working") - assert file.directory? - assert !file.symlink? - end - - def test_symlink - file = Rake::FtpFile.new( - ".", - "lrwxrwxrwx 1 a279376 develop 64 Mar 26 2002 " + - "xtrac -> /home/a279376/working/ics/development/java/" + - "com/fmr/fwp/ics/xtrac") - assert_equal 'xtrac', file.name - assert file.symlink? - assert !file.directory? - end -end diff --git a/test/test_rake_functional.rb b/test/test_rake_functional.rb index f2ce2f78f..afc31d28f 100644 --- a/test/test_rake_functional.rb +++ b/test/test_rake_functional.rb @@ -1,8 +1,9 @@ -require File.expand_path('../helper', __FILE__) -require 'fileutils' -require 'open3' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "fileutils" +require "open3" -class TestRakeFunctional < Rake::TestCase +class TestRakeFunctional < Rake::TestCase # :nodoc: include RubyRunner def setup @@ -11,9 +12,9 @@ def setup if @verbose puts puts - puts '-' * 80 + puts "-" * 80 puts @__name__ - puts '-' * 80 + puts "-" * 80 end end @@ -28,7 +29,7 @@ def test_rake_default def test_rake_error_on_bad_task rakefile_default - rake '-t', 'xyz' + rake "-t", "xyz" assert_match(/rake aborted/, @err) end @@ -44,13 +45,21 @@ def test_env_available_at_top_scope def test_env_available_at_task_scope rakefile_default - rake 'TESTTASKSCOPE=1', 'task_scope' + rake "TESTTASKSCOPE=1", "task_scope" assert_match(/^TASKSCOPE$/, @out) end + def test_task_override + rakefile_override + + rake "t1" + + assert_match(/foo\nbar\n/, @out) + end + def test_multi_desc - ENV['RAKE_COLUMNS'] = '80' + ENV["RAKE_COLUMNS"] = "80" rakefile_multidesc rake "-T" @@ -91,7 +100,7 @@ def test_rbext def test_system rake_system_dir - rake '-g', "sys1" + rake "-g", "sys1" assert_match %r{^SYS1}, @out end @@ -99,7 +108,7 @@ def test_system def test_system_excludes_rakelib_files_too rake_system_dir - rake '-g', "sys1", '-T', 'extra' + rake "-g", "sys1", "-T", "extra" refute_match %r{extra:extra}, @out end @@ -108,12 +117,14 @@ def test_by_default_rakelib_files_are_included rake_system_dir rakefile_extra - rake '-T', 'extra', '--trace' + rake "-T", "extra", "--trace" assert_match %r{extra:extra}, @out end def test_implicit_system + skip if jruby9? + rake_system_dir Dir.chdir @tempdir @@ -126,7 +137,7 @@ def test_no_system rake_system_dir rakefile_extra - rake '-G', "sys1" + rake "-G", "sys1" assert_match %r{^Don't know how to build task}, @err # emacs wart: ' end @@ -150,7 +161,7 @@ def test_nosearch_without_rakefile_finds_system def test_nosearch_without_rakefile_and_no_system_fails rakefile_nosearch - ENV['RAKE_SYSTEM'] = 'not_exist' + ENV["RAKE_SYSTEM"] = "not_exist" rake "--nosearch" @@ -238,7 +249,7 @@ def test_dry_run_bug rake - FileUtils.rm_f 'temp_one' + FileUtils.rm_f "temp_one" rake "--dry-run" @@ -251,7 +262,7 @@ def test_trace_bug rake - FileUtils.rm_f 'temp_one' + FileUtils.rm_f "temp_one" rake "--trace" @@ -263,20 +274,48 @@ def test_imports rake - assert File.exist?(File.join(@tempdir, 'dynamic_deps')), + assert File.exist?(File.join(@tempdir, "dynamic_deps")), "'dynamic_deps' file should exist" assert_match(/^FIRST$\s+^DYNAMIC$\s+^STATIC$\s+^OTHER$/, @out) end + def test_regenerate_imports + rakefile_regenerate_imports + + rake + + assert_match(/^INITIAL\s+^REGENERATED$/, @out) + end + def test_rules_chaining_to_file_task rakefile_chains rake - assert File.exist?(File.join(@tempdir, 'play.app')), + assert File.exist?(File.join(@tempdir, "play.app")), "'play.app' file should exist" end + def dryrun_tasks + @err.split("\n").select { |line| + line.match(/^\*\* Execute/) + }.map { |line| + line.gsub(/^\*\* Execute \(dry run\) /, "") + } + end + + def test_update_midway_through_chaining_to_file_task + rakefile_file_chains + + rake "-n" + assert_equal(%w{fileA fileB fileC default}, dryrun_tasks) + rake + sleep 1 # Ensure the timestamp is on a new second + FileUtils.touch("fileA") + rake "-n" + assert_equal(%w{fileB fileC default}, dryrun_tasks) + end + def test_file_creation_task rakefile_file_creation @@ -290,7 +329,7 @@ def test_file_creation_task def test_dash_f_with_no_arg_foils_rakefile_lookup rakefile_rakelib - rake '-I', 'rakelib', '-rtest1', '-f' + rake "-I", "rakelib", "-rtest1", "-f" assert_match(/^TEST1$/, @out) end @@ -298,7 +337,7 @@ def test_dash_f_with_no_arg_foils_rakefile_lookup def test_dot_rake_files_can_be_loaded_with_dash_r rakefile_rakelib - rake '-I', 'rakelib', '-rtest2', '-f' + rake "-I", "rakelib", "-rtest2", "-f" assert_empty @err assert_match(/^TEST2$/, @out) @@ -368,6 +407,28 @@ def test_file_task_dependencies_scoped_by_namespaces assert_match(/^PREPARE\nSCOPEDEP$/m, @out) end + def test_test_task_descriptions + rakefile_test_task + + rake "-T" + + assert_match(/custom test task description/, @out) + end + + def test_test_task_when_verbose_unless_verbose_passed_not_prompt_testopts + rakefile_test_task_verbose + rake "unit" + exp = /TESTOPTS="--verbose" to pass --verbose/ + 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 @@ -409,12 +470,14 @@ def test_correct_number_of_tasks_reported end def test_file_list_is_requirable_separately - ruby '-rrake/file_list', '-e', 'puts Rake::FileList["a"].size' + skip if jruby9? # https://github.com/jruby/jruby/issues/3655 + + ruby "-rrake/file_list", "-e", 'puts Rake::FileList["a"].size' assert_equal "1\n", @out end def can_detect_signals? - system "ruby -e 'Process.kill \"TERM\", $$'" + system RUBY, "-e", 'Process.kill "TERM", $$' status = $? if @verbose puts " SIG status = #{$?.inspect}" @@ -427,7 +490,7 @@ def can_detect_signals? end def test_signal_propagation_in_tests - if can_detect_signals? + if !jruby? && can_detect_signals? rakefile_test_signal rake assert_match(/ATEST/, @out) @@ -460,7 +523,7 @@ def test_stand_alone_filelist # predicate function can be used to skip tests or assertions as # needed. def uncertain_exit_status? - RUBY_VERSION < "1.9" || defined?(JRUBY_VERSION) + defined?(JRUBY_VERSION) end end diff --git a/test/test_rake_invocation_chain.rb b/test/test_rake_invocation_chain.rb index 0176339bd..bf918f758 100644 --- a/test/test_rake_invocation_chain.rb +++ b/test/test_rake_invocation_chain.rb @@ -1,6 +1,7 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakeInvocationChain < Rake::TestCase +class TestRakeInvocationChain < Rake::TestCase # :nodoc: include Rake def setup @@ -29,7 +30,7 @@ def test_make_on_invocation_chains def test_append_with_one_argument chain = @empty.append("A") - assert_equal 'TOP => A', chain.to_s # HACK + assert_equal "TOP => A", chain.to_s # HACK end def test_append_one_circular diff --git a/test/test_rake_late_time.rb b/test/test_rake_late_time.rb new file mode 100644 index 000000000..776b02d22 --- /dev/null +++ b/test/test_rake_late_time.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) + +class TestRakeLateTime < Rake::TestCase # :nodoc: + def test_late_time_comparisons + late = Rake::LATE + assert_equal late, late + assert late >= Time.now + assert late > Time.now + assert late != Time.now + assert Time.now < late + assert Time.now <= late + assert Time.now != late + end + + def test_to_s + assert_equal "", Rake::LATE.to_s + end +end diff --git a/test/test_rake_linked_list.rb b/test/test_rake_linked_list.rb index 10957fba6..656b50ac2 100644 --- a/test/test_rake_linked_list.rb +++ b/test/test_rake_linked_list.rb @@ -1,6 +1,7 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestLinkedList < Rake::TestCase +class TestLinkedList < Rake::TestCase # :nodoc: include Rake def test_empty_list @@ -57,13 +58,13 @@ def test_lists_are_structurally_equivalent refute_equal short, list end - def test_converstion_to_string + def test_conversion_to_string list = LinkedList.make(:one, :two, :three) assert_equal "LL(one, two, three)", list.to_s assert_equal "LL()", LinkedList.make().to_s end - def test_converstion_with_inspect + def test_conversion_with_inspect list = LinkedList.make(:one, :two, :three) assert_equal "LL(:one, :two, :three)", list.inspect assert_equal "LL()", LinkedList.make().inspect diff --git a/test/test_rake_makefile_loader.rb b/test/test_rake_makefile_loader.rb index 9e9265ad1..4f5270e0a 100644 --- a/test/test_rake_makefile_loader.rb +++ b/test/test_rake_makefile_loader.rb @@ -1,13 +1,14 @@ -require File.expand_path('../helper', __FILE__) -require 'rake/loaders/makefile' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "rake/loaders/makefile" -class TestRakeMakefileLoader < Rake::TestCase +class TestRakeMakefileLoader < Rake::TestCase # :nodoc: include Rake def test_parse Dir.chdir @tempdir - open 'sample.mf', 'w' do |io| + open "sample.mf", "w" do |io| io << <<-'SAMPLE_MF' # Comments a: a1 a2 a3 a4 @@ -28,19 +29,19 @@ def test_parse Task.clear loader = Rake::MakefileLoader.new - loader.load 'sample.mf' + loader.load "sample.mf" %w(a b c d).each do |t| assert Task.task_defined?(t), "#{t} should be a defined task" end - assert_equal %w(a1 a2 a3 a4 a5 a6 a7).sort, Task['a'].prerequisites.sort - assert_equal %w(b1 b2 b3 b4 b5 b6 b7).sort, Task['b'].prerequisites.sort - assert_equal %w(c1).sort, Task['c'].prerequisites.sort - assert_equal %w(d1 d2).sort, Task['d'].prerequisites.sort - assert_equal %w(e1 f1).sort, Task['e'].prerequisites.sort - assert_equal %w(e1 f1).sort, Task['f'].prerequisites.sort + assert_equal %w(a1 a2 a3 a4 a5 a6 a7).sort, Task["a"].prerequisites.sort + assert_equal %w(b1 b2 b3 b4 b5 b6 b7).sort, Task["b"].prerequisites.sort + assert_equal %w(c1).sort, Task["c"].prerequisites.sort + assert_equal %w(d1 d2).sort, Task["d"].prerequisites.sort + assert_equal %w(e1 f1).sort, Task["e"].prerequisites.sort + assert_equal %w(e1 f1).sort, Task["f"].prerequisites.sort assert_equal( ["g1", "g 2", "g 3", "g4"].sort, - Task['g 0'].prerequisites.sort) + Task["g 0"].prerequisites.sort) assert_equal 7, Task.tasks.size end end diff --git a/test/test_rake_multi_task.rb b/test/test_rake_multi_task.rb index fe10caf1d..641e65f4b 100644 --- a/test/test_rake_multi_task.rb +++ b/test/test_rake_multi_task.rb @@ -1,9 +1,9 @@ -require File.expand_path('../helper', __FILE__) -require 'thread' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "thread" -class TestRakeMultiTask < Rake::TestCase +class TestRakeMultiTask < Rake::TestCase # :nodoc: include Rake - include Rake::DSL def setup super @@ -13,6 +13,12 @@ def setup @mutex = Mutex.new end + def teardown + Rake.application.thread_pool.join + + super + end + def add_run(obj) @mutex.synchronize do @runs << obj @@ -22,7 +28,7 @@ def add_run(obj) def test_running_multitasks task :a do 3.times do |i| add_run("A#{i}"); sleep 0.01; end end task :b do 3.times do |i| add_run("B#{i}"); sleep 0.01; end end - multitask :both => [:a, :b] + multitask both: [:a, :b] Task[:both].invoke assert_equal 6, @runs.size assert @runs.index("A0") < @runs.index("A1") @@ -33,9 +39,9 @@ def test_running_multitasks def test_all_multitasks_wait_on_slow_prerequisites task :slow do 3.times do |i| add_run("S#{i}"); sleep 0.05 end end - task :a => [:slow] do 3.times do |i| add_run("A#{i}"); sleep 0.01 end end - task :b => [:slow] do 3.times do |i| add_run("B#{i}"); sleep 0.01 end end - multitask :both => [:a, :b] + task a: [:slow] do 3.times do |i| add_run("A#{i}"); sleep 0.01 end end + task b: [:slow] do 3.times do |i| add_run("B#{i}"); sleep 0.01 end end + multitask both: [:a, :b] Task[:both].invoke assert_equal 9, @runs.size assert @runs.index("S0") < @runs.index("S1") @@ -50,9 +56,51 @@ def test_all_multitasks_wait_on_slow_prerequisites def test_multitasks_with_parameters task :a, [:arg] do |t, args| add_run(args[:arg]) end - multitask :b, [:arg] => [:a] do |t, args| add_run(args[:arg] + 'mt') end + multitask :b, [:arg] => [:a] do |t, args| add_run(args[:arg] + "mt") end Task[:b].invoke "b" assert @runs[0] == "b" assert @runs[1] == "bmt" end + + def test_cross_thread_prerequisite_failures + failed = false + + multitask :fail_once do + fail_now = !failed + failed = true + raise "failing once" if fail_now + end + + task a: :fail_once + task b: :fail_once + + assert_raises RuntimeError do + Rake::Task[:a].invoke + end + + assert_raises RuntimeError do + Rake::Task[:b].invoke + end + end + + def test_task_not_executed_if_dependant_task_failed_concurrently + multitask default: [:one, :two] + + task :one do + raise + end + + task_two_was_executed = false + task two: :one do + task_two_was_executed = true + end + + begin + Rake::Task[:default].invoke + rescue RuntimeError + ensure + sleep 0.5 + refute task_two_was_executed + end + end end diff --git a/test/test_rake_name_space.rb b/test/test_rake_name_space.rb index 3ab977d01..a1a814cfd 100644 --- a/test/test_rake_name_space.rb +++ b/test/test_rake_name_space.rb @@ -1,8 +1,9 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakeNameSpace < Rake::TestCase +class TestRakeNameSpace < Rake::TestCase # :nodoc: - class TM + class TM # :nodoc: include Rake::TaskManager end @@ -37,7 +38,21 @@ def test_namespace_reports_tasks_it_owns end assert_equal ["n:nn:z", "n:x", "n:y"], - ns.tasks.map { |tsk| tsk.name } - assert_equal ["n:nn:z"], nns.tasks.map { |t| t.name } + ns.tasks.map(&:name) + assert_equal ["n:nn:z"], nns.tasks.map(&:name) end + + def test_scope + mgr = TM.new + + scope = Rake::LinkedList.new "b" + scope = scope.conj "a" + + ns = Rake::NameSpace.new mgr, scope + + assert_equal scope, ns.scope + + refute_same scope, ns.scope + end + end diff --git a/test/test_rake_package_task.rb b/test/test_rake_package_task.rb index 87cb57c10..25a1baa95 100644 --- a/test/test_rake_package_task.rb +++ b/test/test_rake_package_task.rb @@ -1,57 +1,60 @@ -require File.expand_path('../helper', __FILE__) -require 'rake/packagetask' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "rake/packagetask" -class TestRakePackageTask < Rake::TestCase +class TestRakePackageTask < Rake::TestCase # :nodoc: def test_initialize - touch 'install.rb' - touch 'a.c' - touch 'b.c' - mkdir 'CVS' - touch 'a.rb~' + touch "install.rb" + touch "a.c" + touch "b.c" + mkdir "CVS" + touch "a.rb~" pkg = Rake::PackageTask.new("pkgr", "1.2.3") { |p| p.package_files << "install.rb" - p.package_files.include '*.c' + p.package_files.include "*.c" p.package_files.exclude(/\bCVS\b/) p.package_files.exclude(/~$/) - p.package_dir = 'pkg' + p.package_dir = "pkg" p.need_tar = true p.need_tar_gz = true p.need_tar_bz2 = true + p.need_tar_xz = true p.need_zip = true } assert_equal "pkg", pkg.package_dir - assert_includes pkg.package_files, 'a.c' + assert_includes pkg.package_files, "a.c" - assert_equal 'pkgr', pkg.name - assert_equal '1.2.3', pkg.version + assert_equal "pkgr", pkg.name + assert_equal "1.2.3", pkg.version assert Rake::Task[:package] - assert Rake::Task['pkg/pkgr-1.2.3.tgz'] - assert Rake::Task['pkg/pkgr-1.2.3.tar.gz'] - assert Rake::Task['pkg/pkgr-1.2.3.tar.bz2'] - assert Rake::Task['pkg/pkgr-1.2.3.zip'] - assert Rake::Task['pkg/pkgr-1.2.3'] + assert Rake::Task["pkg/pkgr-1.2.3.tgz"] + assert Rake::Task["pkg/pkgr-1.2.3.tar.gz"] + assert Rake::Task["pkg/pkgr-1.2.3.tar.bz2"] + assert Rake::Task["pkg/pkgr-1.2.3.tar.xz"] + assert Rake::Task["pkg/pkgr-1.2.3.zip"] + assert Rake::Task["pkg/pkgr-1.2.3"] assert Rake::Task[:clobber_package] assert Rake::Task[:repackage] end def test_initialize_no_version e = assert_raises RuntimeError do - Rake::PackageTask.new 'pkgr' + Rake::PackageTask.new "pkgr" end - assert_equal 'Version required (or :noversion)', e.message + assert_equal "Version required (or :noversion)", e.message end def test_initialize_noversion - pkg = Rake::PackageTask.new 'pkgr', :noversion + pkg = Rake::PackageTask.new "pkgr", :noversion - assert_equal 'pkg', pkg.package_dir - assert_equal 'pkgr', pkg.name - assert_equal nil, pkg.version + assert_equal "pkg", pkg.package_dir + assert_equal "pkgr", pkg.name + assert_nil pkg.version end def test_clone @@ -64,16 +67,27 @@ def test_clone end def test_package_name - pkg = Rake::PackageTask.new 'a', '1' + pkg = Rake::PackageTask.new "a", "1" - assert_equal 'a-1', pkg.package_name + assert_equal "a-1", pkg.package_name end def test_package_name_noversion - pkg = Rake::PackageTask.new 'a', :noversion + pkg = Rake::PackageTask.new "a", :noversion - assert_equal 'a', pkg.package_name + assert_equal "a", pkg.package_name end -end + def test_without_parent_dir + pkg = Rake::PackageTask.new("foo", :noversion) + + assert_equal "pkg", pkg.working_dir + assert_equal "foo", pkg.target_dir + + pkg.without_parent_dir = true + assert_equal "pkg/foo", pkg.working_dir + assert_equal ".", pkg.target_dir + end + +end diff --git a/test/test_rake_path_map.rb b/test/test_rake_path_map.rb index b76a9491f..1551247ec 100644 --- a/test/test_rake_path_map.rb +++ b/test/test_rake_path_map.rb @@ -1,6 +1,7 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakePathMap < Rake::TestCase +class TestRakePathMap < Rake::TestCase # :nodoc: def test_returns_self_with_no_args assert_equal "abc.rb", "abc.rb".pathmap @@ -152,12 +153,12 @@ def test_complex_patterns "Your file extension is '.rb'", "dir/abc.rb".pathmap("Your file extension is '%x'")) assert_equal( - "bin/org/onstepback/proj/A.class", - "src/org/onstepback/proj/A.java".pathmap("%{src,bin}d/%n.class")) + "bin/org/onestepback/proj/A.class", + "src/org/onestepback/proj/A.java".pathmap("%{src,bin}d/%n.class")) assert_equal( - "src_work/bin/org/onstepback/proj/A.class", - "src_work/src/org/onstepback/proj/A.java" - .pathmap('%{\bsrc\b,bin}X.class')) + "src_work/bin/org/onestepback/proj/A.class", + "src_work/src/org/onestepback/proj/A.java". + pathmap('%{\bsrc\b,bin}X.class')) assert_equal( ".depends.bak", ".depends".pathmap("%X.bak")) diff --git a/test/test_rake_path_map_explode.rb b/test/test_rake_path_map_explode.rb index a79235ee7..877a8e0c9 100644 --- a/test/test_rake_path_map_explode.rb +++ b/test/test_rake_path_map_explode.rb @@ -1,6 +1,7 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakePathMapExplode < Rake::TestCase +class TestRakePathMapExplode < Rake::TestCase # :nodoc: def setup super @@ -14,21 +15,20 @@ def teardown end def test_explode - assert_equal ['a'], 'a'.pathmap_explode - assert_equal ['a', 'b'], 'a/b'.pathmap_explode - assert_equal ['a', 'b', 'c'], 'a/b/c'.pathmap_explode - assert_equal ['/', 'a'], '/a'.pathmap_explode - assert_equal ['/', 'a', 'b'], '/a/b'.pathmap_explode - assert_equal ['/', 'a', 'b', 'c'], '/a/b/c'.pathmap_explode + assert_equal ["a"], "a".pathmap_explode + assert_equal ["a", "b"], "a/b".pathmap_explode + assert_equal ["a", "b", "c"], "a/b/c".pathmap_explode + assert_equal ["/", "a"], "/a".pathmap_explode + assert_equal ["/", "a", "b"], "/a/b".pathmap_explode + assert_equal ["/", "a", "b", "c"], "/a/b/c".pathmap_explode if File::ALT_SEPARATOR - assert_equal ['c:.', 'a'], 'c:a'.pathmap_explode - assert_equal ['c:.', 'a', 'b'], 'c:a/b'.pathmap_explode - assert_equal ['c:.', 'a', 'b', 'c'], 'c:a/b/c'.pathmap_explode - assert_equal ['c:/', 'a'], 'c:/a'.pathmap_explode - assert_equal ['c:/', 'a', 'b'], 'c:/a/b'.pathmap_explode - assert_equal ['c:/', 'a', 'b', 'c'], 'c:/a/b/c'.pathmap_explode + assert_equal ["c:.", "a"], "c:a".pathmap_explode + assert_equal ["c:.", "a", "b"], "c:a/b".pathmap_explode + assert_equal ["c:.", "a", "b", "c"], "c:a/b/c".pathmap_explode + assert_equal ["c:/", "a"], "c:/a".pathmap_explode + assert_equal ["c:/", "a", "b"], "c:/a/b".pathmap_explode + assert_equal ["c:/", "a", "b", "c"], "c:/a/b/c".pathmap_explode end end end - diff --git a/test/test_rake_path_map_partial.rb b/test/test_rake_path_map_partial.rb index 566e681bb..e73ec56b6 100644 --- a/test/test_rake_path_map_partial.rb +++ b/test/test_rake_path_map_partial.rb @@ -1,8 +1,9 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakePathMapPartial < Rake::TestCase +class TestRakePathMapPartial < Rake::TestCase # :nodoc: def test_pathmap_partial - @path = "1/2/file" + @path = "1/2/file".dup def @path.call(n) pathmap_partial(n) end @@ -15,4 +16,3 @@ def @path.call(n) assert_equal("1/2", @path.call(-3)) end end - diff --git a/test/test_rake_pseudo_status.rb b/test/test_rake_pseudo_status.rb index 51b3fef34..008621f49 100644 --- a/test/test_rake_pseudo_status.rb +++ b/test/test_rake_pseudo_status.rb @@ -1,6 +1,7 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakePseudoStatus < Rake::TestCase +class TestRakePseudoStatus < Rake::TestCase # :nodoc: def test_with_zero_exit_status s = Rake::PseudoStatus.new assert_equal 0, s.exitstatus diff --git a/test/test_rake_rake_test_loader.rb b/test/test_rake_rake_test_loader.rb index 0485c4c8a..4423a9b1c 100644 --- a/test/test_rake_rake_test_loader.rb +++ b/test/test_rake_rake_test_loader.rb @@ -1,20 +1,61 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakeRakeTestLoader < Rake::TestCase +class TestRakeRakeTestLoader < Rake::TestCase # :nodoc: + + def setup + super + + @loader = File.join @rake_lib, "rake/rake_test_loader.rb" + end def test_pattern orig_loaded_features = $:.dup - FileUtils.touch 'foo.rb' - FileUtils.touch 'test_a.rb' - FileUtils.touch 'test_b.rb' + FileUtils.touch "foo.rb" + FileUtils.touch "test_a.rb" + FileUtils.touch "test_b.rb" ARGV.replace %w[foo.rb test_*.rb -v] - load File.join(@rake_lib, 'rake/rake_test_loader.rb') + load @loader assert_equal %w[-v], ARGV ensure $:.replace orig_loaded_features end + def test_load_error_from_require + out, err = capture_io do + ARGV.replace %w[no_such_test_file.rb] + + assert_raises SystemExit do + load @loader + end + end + + assert_empty out + + no_such_path = File.join @tempdir, "no_such_test_file" + + expected = + /\A\n + File\ does\ not\ exist:\ #{no_such_path}(\.rb)? # JRuby is different + \n\n\Z/x + + assert_match expected, err + end + + def test_load_error_raised_explicitly + File.write("error_test.rb", "raise LoadError, 'explicitly raised'") + out, err = capture_io do + ARGV.replace %w[error_test.rb] + + exc = assert_raises(LoadError) do + load @loader + end + assert_equal "explicitly raised", exc.message + end + assert_empty out + assert_empty err + end end diff --git a/test/test_rake_reduce_compat.rb b/test/test_rake_reduce_compat.rb index d29526654..17986dcde 100644 --- a/test/test_rake_reduce_compat.rb +++ b/test/test_rake_reduce_compat.rb @@ -1,7 +1,8 @@ -require File.expand_path('../helper', __FILE__) -require 'open3' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "open3" -class TestRakeReduceCompat < Rake::TestCase +class TestRakeReduceCompat < Rake::TestCase # :nodoc: include RubyRunner def invoke_normal(task_name) diff --git a/test/test_rake_require.rb b/test/test_rake_require.rb index d229edbc2..6309277da 100644 --- a/test/test_rake_require.rb +++ b/test/test_rake_require.rb @@ -1,13 +1,18 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakeRequire < Rake::TestCase +class TestRakeRequire < Rake::TestCase # :nodoc: + def setup + super + $LOAD_PATH.unshift "." if jruby17? + end def test_can_load_rake_library rakefile_rakelib app = Rake::Application.new assert app.instance_eval { - rake_require("test2", ['rakelib'], []) + rake_require("test2", ["rakelib"], []) } end @@ -15,7 +20,7 @@ def test_wont_reload_rake_library rakefile_rakelib app = Rake::Application.new - paths = ['rakelib'] + paths = ["rakelib"] loaded_files = [] app.rake_require("test2", paths, loaded_files) @@ -30,11 +35,10 @@ def test_throws_error_if_library_not_found app = Rake::Application.new ex = assert_raises(LoadError) { assert app.instance_eval { - rake_require("testx", ['rakelib'], []) + rake_require("testx", ["rakelib"], []) } } assert_match(/(can *not|can't)\s+find/i, ex.message) assert_match(/testx/, ex.message) end end - diff --git a/test/test_rake_rules.rb b/test/test_rake_rules.rb index 376b99889..bfb8e775f 100644 --- a/test/test_rake_rules.rb +++ b/test/test_rake_rules.rb @@ -1,7 +1,8 @@ -require File.expand_path('../helper', __FILE__) -require 'fileutils' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "fileutils" -class TestRakeRules < Rake::TestCase +class TestRakeRules < Rake::TestCase # :nodoc: include Rake SRCFILE = "abc.c" @@ -10,6 +11,7 @@ class TestRakeRules < Rake::TestCase OBJFILE = "abc.o" FOOFILE = "foo" DOTFOOFILE = ".foo" + MINFILE = "abc.min.o" def setup super @@ -22,8 +24,8 @@ def test_multiple_rules1 create_file(FTNFILE) delete_file(SRCFILE) delete_file(OBJFILE) - rule(/\.o$/ => ['.c']) do @runs << :C end - rule(/\.o$/ => ['.f']) do @runs << :F end + rule(/\.o$/ => [".c"]) do @runs << :C end + rule(/\.o$/ => [".f"]) do @runs << :F end t = Task[OBJFILE] t.invoke Task[OBJFILE].invoke @@ -34,15 +36,15 @@ def test_multiple_rules2 create_file(FTNFILE) delete_file(SRCFILE) delete_file(OBJFILE) - rule(/\.o$/ => ['.f']) do @runs << :F end - rule(/\.o$/ => ['.c']) do @runs << :C end + rule(/\.o$/ => [".f"]) do @runs << :F end + rule(/\.o$/ => [".c"]) do @runs << :C end Task[OBJFILE].invoke assert_equal [:F], @runs end def test_create_with_source create_file(SRCFILE) - rule(/\.o$/ => ['.c']) do |t| + rule(/\.o$/ => [".c"]) do |t| @runs << t.name assert_equal OBJFILE, t.name assert_equal SRCFILE, t.source @@ -53,7 +55,7 @@ def test_create_with_source def test_single_dependent create_file(SRCFILE) - rule(/\.o$/ => '.c') do |t| + rule(/\.o$/ => ".c") do |t| @runs << t.name end Task[OBJFILE].invoke @@ -62,7 +64,7 @@ def test_single_dependent def test_rule_can_be_created_by_string create_file(SRCFILE) - rule '.o' => ['.c'] do |t| + rule ".o" => [".c"] do |t| @runs << t.name end Task[OBJFILE].invoke @@ -71,7 +73,7 @@ def test_rule_can_be_created_by_string def test_rule_prereqs_can_be_created_by_string create_file(SRCFILE) - rule '.o' => '.c' do |t| + rule ".o" => ".c" do |t| @runs << t.name end Task[OBJFILE].invoke @@ -80,7 +82,7 @@ def test_rule_prereqs_can_be_created_by_string def test_plain_strings_as_dependents_refer_to_files create_file(SRCFILE) - rule '.o' => SRCFILE do |t| + rule ".o" => SRCFILE do |t| @runs << t.name end Task[OBJFILE].invoke @@ -89,8 +91,8 @@ def test_plain_strings_as_dependents_refer_to_files def test_file_names_beginning_with_dot_can_be_tricked_into_referring_to_file verbose(false) do - create_file('.foo') - rule '.o' => "./.foo" do |t| + create_file(".foo") + rule ".o" => "./.foo" do |t| @runs << t.name end Task[OBJFILE].invoke @@ -102,7 +104,7 @@ def test_file_names_beginning_with_dot_can_be_wrapped_in_lambda verbose(false) do create_file(".foo") - rule '.o' => lambda { ".foo" } do |t| + rule ".o" => lambda { ".foo" } do |t| @runs << "#{t.name} - #{t.source}" end Task[OBJFILE].invoke @@ -113,7 +115,7 @@ def test_file_names_beginning_with_dot_can_be_wrapped_in_lambda def test_file_names_containing_percent_can_be_wrapped_in_lambda verbose(false) do create_file("foo%x") - rule '.o' => lambda { "foo%x" } do |t| + rule ".o" => lambda { "foo%x" } do |t| @runs << "#{t.name} - #{t.source}" end Task[OBJFILE].invoke @@ -124,7 +126,7 @@ def test_file_names_containing_percent_can_be_wrapped_in_lambda def test_non_extension_rule_name_refers_to_file verbose(false) do create_file("abc.c") - rule "abc" => '.c' do |t| + rule "abc" => ".c" do |t| @runs << t.name end Task["abc"].invoke @@ -135,7 +137,7 @@ def test_non_extension_rule_name_refers_to_file def test_pathmap_automatically_applies_to_name verbose(false) do create_file("zzabc.c") - rule ".o" => 'zz%{x,a}n.c' do |t| + rule ".o" => "zz%{x,a}n.c" do |t| @runs << "#{t.name} - #{t.source}" end Task["xbc.o"].invoke @@ -146,7 +148,7 @@ def test_pathmap_automatically_applies_to_name def test_plain_strings_are_just_filenames verbose(false) do create_file("plainname") - rule ".o" => 'plainname' do |t| + rule ".o" => "plainname" do |t| @runs << "#{t.name} - #{t.source}" end Task["xbc.o"].invoke @@ -158,7 +160,7 @@ def test_rule_runs_when_explicit_task_has_no_actions create_file(SRCFILE) create_file(SRCFILE2) delete_file(OBJFILE) - rule '.o' => '.c' do |t| + rule ".o" => ".c" do |t| @runs << t.source end file OBJFILE => [SRCFILE2] @@ -168,16 +170,16 @@ def test_rule_runs_when_explicit_task_has_no_actions def test_close_matches_on_name_do_not_trigger_rule create_file("x.c") - rule '.o' => ['.c'] do |t| + rule ".o" => [".c"] do |t| @runs << t.name end - assert_raises(RuntimeError) { Task['x.obj'].invoke } - assert_raises(RuntimeError) { Task['x.xyo'].invoke } + assert_raises(RuntimeError) { Task["x.obj"].invoke } + assert_raises(RuntimeError) { Task["x.xyo"].invoke } end def test_rule_rebuilds_obj_when_source_is_newer create_timed_files(OBJFILE, SRCFILE) - rule(/\.o$/ => ['.c']) do + rule(/\.o$/ => [".c"]) do @runs << :RULE end Task[OBJFILE].invoke @@ -204,15 +206,15 @@ def test_rule_with_two_sources_but_one_missing_does_not_run end def test_rule_with_two_sources_builds_both_sources - task 'x.aa' - task 'x.bb' - rule '.a' => '.aa' do + task "x.aa" + task "x.bb" + rule ".a" => ".aa" do @runs << "A" end - rule '.b' => '.bb' do + rule ".b" => ".bb" do @runs << "B" end - rule ".c" => ['.a', '.b'] do + rule ".c" => [".a", ".b"] do @runs << "C" end Task["x.c"].invoke @@ -262,25 +264,25 @@ def test_rule_with_proc_dependent_will_trigger rule %r(classes/.*\.class) => [ proc { |fn| fn.pathmap("%{classes,src}d/%n.java") } ] do |task| - assert_equal task.name, 'classes/jw/X.class' - assert_equal task.source, 'src/jw/X.java' + assert_equal task.name, "classes/jw/X.class" + assert_equal task.source, "src/jw/X.java" @runs << :RULE end - Task['classes/jw/X.class'].invoke + Task["classes/jw/X.class"].invoke assert_equal [:RULE], @runs ensure - rm_r("src", :verbose=>false) rescue nil + rm_r("src", verbose: false) rescue nil end def test_proc_returning_lists_are_flattened_into_prereqs ran = false mkdir_p("flatten") create_file("flatten/a.txt") - task 'flatten/b.data' do |t| + task "flatten/b.data" do |t| ran = true - touch t.name, :verbose => false + touch t.name, verbose: false end - rule '.html' => + rule ".html" => proc { |fn| [ fn.ext("txt"), @@ -288,27 +290,27 @@ def test_proc_returning_lists_are_flattened_into_prereqs ] } do |task| end - Task['flatten/a.html'].invoke + Task["flatten/a.html"].invoke assert ran, "Should have triggered flattened dependency" ensure - rm_r("flatten", :verbose=>false) rescue nil + rm_r("flatten", verbose: false) rescue nil end def test_recursive_rules_will_work_as_long_as_they_terminate actions = [] create_file("abc.xml") - rule '.y' => '.xml' do actions << 'y' end - rule '.c' => '.y' do actions << 'c'end - rule '.o' => '.c' do actions << 'o'end - rule '.exe' => '.o' do actions << 'exe'end + rule ".y" => ".xml" do actions << "y" end + rule ".c" => ".y" do actions << "c"end + rule ".o" => ".c" do actions << "o"end + rule ".exe" => ".o" do actions << "exe"end Task["abc.exe"].invoke - assert_equal ['y', 'c', 'o', 'exe'], actions + assert_equal ["y", "c", "o", "exe"], actions end def test_recursive_rules_that_dont_terminate_will_overflow create_file("a.a") - prev = 'a' - ('b'..'z').each do |letter| + prev = "a" + ("b".."z").each do |letter| rule ".#{letter}" => ".#{prev}" do |t| puts "#{t.name}" end prev = letter end @@ -320,43 +322,91 @@ def test_recursive_rules_that_dont_terminate_will_overflow def test_rules_with_bad_dependents_will_fail rule "a" => [1] do |t| puts t.name end - assert_raises(RuntimeError) do Task['a'].invoke end + assert_raises(RuntimeError) do Task["a"].invoke end end def test_string_rule_with_args delete_file(OBJFILE) create_file(SRCFILE) - rule '.o', [:a] => SRCFILE do |t, args| - assert_equal 'arg', args.a + rule ".o", [:a] => SRCFILE do |t, args| + assert_equal "arg", args.a end - Task[OBJFILE].invoke('arg') + Task[OBJFILE].invoke("arg") end def test_regex_rule_with_args delete_file(OBJFILE) create_file(SRCFILE) rule(/.o$/, [:a] => SRCFILE) do |t, args| - assert_equal 'arg', args.a + assert_equal "arg", args.a + end + Task[OBJFILE].invoke("arg") + end + + # for https://github.com/ruby/rake/pull/182 + def test_single_dependent_with_nil_args + create_file(SRCFILE) + rule nil => ".cpp" do |t| p t.name end + rule(/\.o$/ => ".c") do |t| + @runs << t.name end - Task[OBJFILE].invoke('arg') + Task[OBJFILE].invoke + assert_equal [OBJFILE], @runs end def test_string_rule_with_args_and_lambda_prereq delete_file(OBJFILE) create_file(SRCFILE) - rule '.o', [:a] => [lambda{SRCFILE}]do |t, args| - assert_equal 'arg', args.a + rule ".o", [:a] => [lambda { SRCFILE }]do |t, args| + assert_equal "arg", args.a end - Task[OBJFILE].invoke('arg') + Task[OBJFILE].invoke("arg") end def test_regex_rule_with_args_and_lambda_prereq delete_file(OBJFILE) create_file(SRCFILE) - rule(/.o$/, [:a] => [lambda{SRCFILE}]) do |t, args| - assert_equal 'arg', args.a + rule(/.o$/, [:a] => [lambda { SRCFILE }]) do |t, args| + assert_equal "arg", args.a + end + Task[OBJFILE].invoke("arg") + end + + def test_rule_with_method_prereq + create_file(".foo") + obj = Object.new + def obj.find_prereq + ".foo" + end + rule ".o" => obj.method(:find_prereq) do |t| + @runs << "#{t.name} - #{t.source}" + end + Task[OBJFILE].invoke + assert_equal ["#{OBJFILE} - .foo"], @runs + end + + def test_rule_with_one_arg_method_prereq + create_file(SRCFILE) + obj = Object.new + def obj.find_prereq(task_name) + task_name.ext(".c") + end + rule ".o" => obj.method(:find_prereq) do |t| + @runs << "#{t.name} - #{t.source}" + end + Task[OBJFILE].invoke + assert_equal ["#{OBJFILE} - abc.c"], @runs + end + + def test_works_with_chained_extensions_in_rules + create_file(OBJFILE) + rule(".min.o" => [".o"]) do |t| + @runs << t.name + assert_equal OBJFILE, t.source + assert_equal MINFILE, t.name end - Task[OBJFILE].invoke('arg') + Task[MINFILE].invoke + assert_equal [MINFILE], @runs end end diff --git a/test/test_rake_scope.rb b/test/test_rake_scope.rb index ef06618ba..24ac03408 100644 --- a/test/test_rake_scope.rb +++ b/test/test_rake_scope.rb @@ -1,6 +1,7 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakeScope < Rake::TestCase +class TestRakeScope < Rake::TestCase # :nodoc: include Rake def test_path_against_empty_scope diff --git a/test/test_rake_task.rb b/test/test_rake_task.rb index 2ab995a6f..fa4099b07 100644 --- a/test/test_rake_task.rb +++ b/test/test_rake_task.rb @@ -1,7 +1,8 @@ -require File.expand_path('../helper', __FILE__) -require 'fileutils' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "fileutils" -class TestRakeTask < Rake::TestCase +class TestRakeTask < Rake::TestCase # :nodoc: include Rake def setup @@ -13,6 +14,7 @@ def setup def teardown Rake::TaskManager.record_task_metadata = false + Rake.application.thread_pool.join super end @@ -32,13 +34,13 @@ def test_create end def test_inspect - t = task(:foo => [:bar, :baz]) + t = task(foo: [:bar, :baz]) assert_equal " [bar, baz]>", t.inspect end def test_invoke runlist = [] - t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 } + t1 = task(t1: [:t2, :t3]) { |t| runlist << t.name; 3321 } task(:t2) { |t| runlist << t.name } task(:t3) { |t| runlist << t.name } assert_equal ["t2", "t3"], t1.prerequisites @@ -48,8 +50,8 @@ def test_invoke def test_invoke_with_circular_dependencies runlist = [] - t1 = task(:t1 => [:t2]) { |t| runlist << t.name; 3321 } - t2 = task(:t2 => [:t1]) { |t| runlist << t.name } + t1 = task(t1: [:t2]) { |t| runlist << t.name; 3321 } + t2 = task(t2: [:t1]) { |t| runlist << t.name } assert_equal ["t2"], t1.prerequisites assert_equal ["t1"], t2.prerequisites ex = assert_raises RuntimeError do @@ -60,10 +62,14 @@ def test_invoke_with_circular_dependencies end def test_dry_run_prevents_actions - Rake.application.options.dryrun = true runlist = [] t1 = task(:t1) { |t| runlist << t.name; 3321 } - _, err = capture_io { t1.invoke } + _, err = capture_io { + Rake.application.set_default_options # reset trace output IO + Rake.application.options.dryrun = true + + t1.invoke + } assert_match(/execute .*t1/i, err) assert_match(/dry run/i, err) refute_match(/invoke/i, err) @@ -73,9 +79,11 @@ def test_dry_run_prevents_actions end def test_tasks_can_be_traced - Rake.application.options.trace = true t1 = task(:t1) _, err = capture_io { + Rake.application.set_default_options # reset trace output IO + Rake.application.options.trace = true + t1.invoke } assert_match(/invoke t1/i, err) @@ -86,13 +94,20 @@ def test_tasks_can_be_traced def test_no_double_invoke runlist = [] - t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 } - task(:t2 => [:t3]) { |t| runlist << t.name } + t1 = task(t1: [:t2, :t3]) { |t| runlist << t.name; 3321 } + task(t2: [:t3]) { |t| runlist << t.name } task(:t3) { |t| runlist << t.name } t1.invoke assert_equal ["t3", "t2", "t1"], runlist end + def test_already_invoked + t1 = task(:t1) {} + assert_equal false, t1.already_invoked + t1.invoke + assert_equal true, t1.already_invoked + end + def test_can_double_invoke_with_reenable runlist = [] t1 = task(:t1) { |t| runlist << t.name } @@ -102,31 +117,59 @@ def test_can_double_invoke_with_reenable assert_equal ["t1", "t1"], runlist end + def test_can_triple_invoke_after_exception_with_reenable + raise_exception = true + invoked = 0 + + t1 = task(:t1) do |t| + invoked += 1 + next if !raise_exception + + raise_exception = false + raise 'Some error' + end + + assert_raises(RuntimeError) { t1.invoke } + assert_equal 1, invoked + + t1.reenable + + # actually invoke second time + t1.invoke + assert_equal 2, invoked + + # recognize already invoked and + # don't raise pre-reenable exception + t1.invoke + assert_equal 2, invoked + end + def test_clear desc "a task" - t = task("t" => "a") { } + t = task("t", ["b"] => "a") {} t.clear assert t.prerequisites.empty?, "prerequisites should be empty" assert t.actions.empty?, "actions should be empty" assert_nil t.comment, "comments should be empty" + assert_empty t.arg_names, "arg names should be empty" end def test_clear_prerequisites t = task("t" => ["a", "b"]) - assert_equal ['a', 'b'], t.prerequisites + assert_equal ["a", "b"], t.prerequisites t.clear_prerequisites assert_equal [], t.prerequisites end def test_clear_actions - t = task("t") { } + t = task("t") {} t.clear_actions assert t.actions.empty?, "actions should be empty" end def test_clear_comments desc "the original foo" - task :foo => [:x] do + task foo: [:x] do # Dummy action end @@ -140,11 +183,24 @@ def test_clear_comments assert_equal 1, task(:foo).actions.size end + def test_clear_args + task :foo, [:x] do + # Dummy action + end + + task(:foo).clear_args + + task :foo + + assert_empty task(:foo).arg_names + end + def test_find task :tfind assert_equal "tfind", Task[:tfind].name ex = assert_raises(RuntimeError) { Task[:leaves] } - assert_equal "Don't know how to build task 'leaves'", ex.message + assert_equal "Don't know how to build task 'leaves'" \ + " (See the list of available tasks with `rake --tasks`)", ex.message end def test_defined @@ -156,8 +212,8 @@ def test_defined def test_multi_invocations runs = [] p = proc do |t| runs << t.name end - task({ :t1 => [:t2, :t3] }, &p) - task({ :t2 => [:t3] }, &p) + task({ t1: [:t2, :t3] }, &p) + task({ t2: [:t3] }, &p) task(:t3, &p) Task[:t1].invoke assert_equal ["t1", "t2", "t3"], runs.sort @@ -165,8 +221,8 @@ def test_multi_invocations def test_task_list task :t2 - task :t1 => [:t2] - assert_equal ["t1", "t2"], Task.tasks.map { |t| t.name } + task t1: [:t2] + assert_equal ["t1", "t2"], Task.tasks.map(&:name) end def test_task_gives_name_on_to_s @@ -175,44 +231,45 @@ def test_task_gives_name_on_to_s end def test_symbols_can_be_prerequisites - task :a => :b + task a: :b assert_equal ["b"], Task[:a].prerequisites end def test_strings_can_be_prerequisites - task :a => "b" + task a: "b" assert_equal ["b"], Task[:a].prerequisites end def test_arrays_can_be_prerequisites - task :a => ["b", "c"] + task a: ["b", "c"] assert_equal ["b", "c"], Task[:a].prerequisites end def test_filelists_can_be_prerequisites - task :a => FileList.new.include("b", "c") + task a: FileList.new.include("b", "c") assert_equal ["b", "c"], Task[:a].prerequisites end - def test_prerequiste_tasks_returns_tasks_not_strings - a = task :a => ["b", "c"] + def test_prerequisite_tasks_returns_tasks_not_strings + a = task a: ["b", "c"] b = task :b c = task :c assert_equal [b, c], a.prerequisite_tasks end - def test_prerequiste_tasks_fails_if_prerequisites_are_undefined - a = task :a => ["b", "c"] + def test_prerequisite_tasks_fails_if_prerequisites_are_undefined + a = task a: ["b", "c"] task :b assert_raises(RuntimeError) do a.prerequisite_tasks end end - def test_prerequiste_tasks_honors_namespaces + def test_prerequisite_tasks_honors_namespaces + task :b a = b = nil namespace "X" do - a = task :a => ["b", "c"] + a = task a: ["b", "c"] b = task :b end c = task :c @@ -220,10 +277,39 @@ def test_prerequiste_tasks_honors_namespaces assert_equal [b, c], a.prerequisite_tasks end + def test_prerequisite_tasks_finds_tasks_with_same_name_outside_namespace + b1 = nil + namespace "a" do + b1 = task b: "b" + end + b2 = task :b + + assert_equal [b2], b1.prerequisite_tasks + end + + def test_prerequisite_tasks_in_nested_namespaces + m = task :m + a_c_m = a_b_m = a_m = nil + namespace "a" do + a_m = task :m + + namespace "b" do + a_b_m = task m: "m" + end + + namespace "c" do + a_c_m = task m: "a:m" + end + end + + assert_equal [m], a_b_m.prerequisite_tasks + assert_equal [a_m], a_c_m.prerequisite_tasks + end + def test_all_prerequisite_tasks_includes_all_prerequisites - a = task :a => "b" - b = task :b => ["c", "d"] - c = task :c => "e" + a = task a: "b" + b = task b: ["c", "d"] + c = task c: "e" d = task :d e = task :e @@ -231,30 +317,30 @@ def test_all_prerequisite_tasks_includes_all_prerequisites end def test_all_prerequisite_tasks_does_not_include_duplicates - a = task :a => ["b", "c"] - b = task :b => "c" + a = task a: ["b", "c"] + b = task b: "c" c = task :c assert_equal [b, c], a.all_prerequisite_tasks.sort_by { |t| t.name } end def test_all_prerequisite_tasks_includes_self_on_cyclic_dependencies - a = task :a => "b" - b = task :b => "a" + a = task a: "b" + b = task b: "a" assert_equal [a, b], a.all_prerequisite_tasks.sort_by { |t| t.name } end def test_timestamp_returns_now_if_all_prereqs_have_no_times - a = task :a => ["b", "c"] + a = task a: ["b", "c"] task :b task :c - assert_in_delta Time.now, a.timestamp, 0.1, 'computer too slow?' + assert_in_delta Time.now, a.timestamp, 0.1, "computer too slow?" end def test_timestamp_returns_latest_prereq_timestamp - a = task :a => ["b", "c"] + a = task a: ["b", "c"] b = task :b c = task :c @@ -262,7 +348,7 @@ def test_timestamp_returns_latest_prereq_timestamp def b.timestamp() Time.now + 10 end def c.timestamp() Time.now + 5 end - assert_in_delta now, a.timestamp, 0.1, 'computer too slow?' + assert_in_delta now, a.timestamp, 0.1, "computer too slow?" end def test_always_multitask @@ -270,7 +356,7 @@ def test_always_multitask result = [] t_a = task(:a) do |t| - sleep 0.02 + sleep 0.2 mx.synchronize { result << t.name } end @@ -278,27 +364,27 @@ def test_always_multitask mx.synchronize { result << t.name } end - t_c = task(:c => [:a, :b]) do |t| + t_c = task(c: [:a, :b]) do |t| mx.synchronize { result << t.name } end t_c.invoke # task should always run in order - assert_equal ['a', 'b', 'c'], result + assert_equal ["a", "b", "c"], result - [t_a, t_b, t_c].each { |t| t.reenable } + [t_a, t_b, t_c].each(&:reenable) result.clear Rake.application.options.always_multitask = true t_c.invoke # with multitask, task 'b' should grab the mutex first - assert_equal ['b', 'a', 'c'], result + assert_equal ["b", "a", "c"], result end def test_investigation_output - t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 } + t1 = task(t1: [:t2, :t3]) { |t| runlist << t.name; 3321 } task(:t2) task(:t3) out = t1.investigation @@ -314,12 +400,24 @@ def test_comment_setting assert_equal "A Comment", t.comment end - def test_comments_with_sentences + def test_comments_with_sentences_period desc "Comment 1. Comment 2." t = task(:t, :name, :rev) assert_equal "Comment 1", t.comment end + def test_comments_with_sentences_exclamation_mark + desc "An exclamation mark! Comment." + t = task(:t, :name, :rev) + assert_equal "An exclamation mark", t.comment + end + + def test_comments_with_many_periods + desc "This is a test...I think ... testing. Comment." + t = task(:t, :name, :rev) + assert_equal "This is a test...I think ... testing", t.comment + end + def test_comments_with_tabbed_sentences desc "Comment 1.\tComment 2." t = task(:t, :name, :rev) @@ -332,6 +430,17 @@ def test_comments_with_decimal_points assert_equal "Revision 1.2.3", t.comment end + def test_comments_do_not_set + t = task(:t, :name, :rev) + assert_nil t.comment + end + + def test_comments_is_nil + t = task(:t, :name, :rev) + t.comment = nil + assert_nil t.comment + end + def test_extended_comments desc %{ This is a comment. @@ -373,4 +482,25 @@ def test_interspersed_duplicate_comments task(:t) assert_equal "line one / line two", t.comment end + + def test_source_is_first_prerequisite + t = task t: ["preqA", "preqB"] + assert_equal "preqA", t.source + end + + def test_suggests_valid_rake_task_names + task :test + error = assert_raises(RuntimeError) { Task[:testt] } + + assert_match(/Don\'t know how to build task \'testt\'/, error.message) + + if defined?(::DidYouMean::SpellChecker) && defined?(::DidYouMean::Formatter) + assert_match(/Did you mean\? test/, error.message) + end + end + + def test_prereqs + t = task(a: %w[b c d e]) + assert_equal %w[b c d e], t.prereqs + end end diff --git a/test/test_rake_task_argument_parsing.rb b/test/test_rake_task_argument_parsing.rb index 9b99991de..ed12ea0b4 100644 --- a/test/test_rake_task_argument_parsing.rb +++ b/test/test_rake_task_argument_parsing.rb @@ -1,6 +1,7 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakeTaskArgumentParsing < Rake::TestCase +class TestRakeTaskArgumentParsing < Rake::TestCase # :nodoc: def setup super @@ -37,12 +38,34 @@ def test_can_handle_spaces_between_args assert_equal ["one", "two", "three", "four"], args end + def test_can_handle_spaces_between_all_args + name, args = @app.parse_task_string("name[ one , two ,\tthree , \tfour ]") + assert_equal "name", name + assert_equal ["one", "two", "three", "four"], args + end + def test_keeps_embedded_spaces name, args = @app.parse_task_string("name[a one ana, two]") assert_equal "name", name assert_equal ["a one ana", "two"], args end + def test_can_handle_commas_in_args + name, args = @app.parse_task_string("name[one, two, three_a\\, three_b, four]") + assert_equal "name", name + assert_equal ["one", "two", "three_a, three_b", "four"], args + end + + def test_treat_blank_arg_as_empty_string + name, args = @app.parse_task_string("name[one,]") + assert_equal "name", name + assert_equal ["one", ""], args + + name, args = @app.parse_task_string("name[one,,two]") + assert_equal "name", name + assert_equal ["one", "", "two"], args + end + def test_terminal_width_using_env app = Rake::Application.new app.terminal_columns = 1234 @@ -79,21 +102,19 @@ def @app.unix?() raise end end def test_no_rakeopt - ARGV << '--trace' app = Rake::Application.new - app.init + app.init %w[--trace] assert !app.options.silent end def test_rakeopt_with_blank_options - ARGV << '--trace' app = Rake::Application.new - app.init + app.init %w[--trace] assert !app.options.silent end def test_rakeopt_with_silent_options - ENV['RAKEOPT'] = '-s' + ENV["RAKEOPT"] = "-s" app = Rake::Application.new app.init diff --git a/test/test_rake_task_arguments.rb b/test/test_rake_task_arguments.rb index 061178e23..245a71661 100644 --- a/test/test_rake_task_arguments.rb +++ b/test/test_rake_task_arguments.rb @@ -1,10 +1,10 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -###################################################################### -class TestRakeTaskArguments < Rake::TestCase +class TestRakeTaskArguments < Rake::TestCase # :nodoc: def teardown - ENV.delete('rev') - ENV.delete('VER') + ENV.delete("rev") + ENV.delete("VER") super end @@ -16,13 +16,42 @@ def test_empty_arg_list_is_empty def test_multiple_values_in_args ta = Rake::TaskArguments.new([:a, :b, :c], [:one, :two, :three]) - assert_equal({:a => :one, :b => :two, :c => :three}, ta.to_hash) + assert_equal({ a: :one, b: :two, c: :three }, ta.to_hash) + end + + def test_blank_values_in_args + ta = Rake::TaskArguments.new([:a, :b, :c], ["", :two, ""]) + assert_equal({ b: :two }, ta.to_hash) + end + + def test_has_key + ta = Rake::TaskArguments.new([:a], [:one]) + assert(ta.has_key?(:a)) + assert(ta.key?(:a)) + refute(ta.has_key?(:b)) + refute(ta.key?(:b)) + end + + def test_fetch + ta = Rake::TaskArguments.new([:one], [1]) + assert_equal 1, ta.fetch(:one) + assert_equal 2, ta.fetch(:two) { 2 } + assert_raises(KeyError) { ta.fetch(:three) } end def test_to_s ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2, 3]) - assert_equal ta.to_hash.inspect, ta.to_s - assert_equal ta.to_hash.inspect, ta.inspect + expectation = "#" + assert_equal expectation, ta.to_s + assert_equal expectation, ta.inspect + end + + def test_to_hash + ta = Rake::TaskArguments.new([:one], [1]) + h = ta.to_hash + h[:one] = 0 + assert_equal 1, ta.fetch(:one) + assert_equal 0, h.fetch(:one) end def test_enumerable_behavior @@ -51,16 +80,16 @@ def test_extra_names_are_nil def test_args_do_not_reference_env_values ta = Rake::TaskArguments.new(["aa"], [1]) - ENV['rev'] = "1.2" - ENV['VER'] = "2.3" + ENV["rev"] = "1.2" + ENV["VER"] = "2.3" assert_nil ta.rev assert_nil ta.ver end def test_creating_new_argument_scopes - parent = Rake::TaskArguments.new(['p'], [1]) - child = parent.new_scope(['c', 'p']) - assert_equal({:p=>1}, child.to_hash) + parent = Rake::TaskArguments.new(["p"], [1]) + child = parent.new_scope(["c", "p"]) + assert_equal({ p: 1 }, child.to_hash) assert_equal 1, child.p assert_equal 1, child["p"] assert_equal 1, child[:p] @@ -68,21 +97,21 @@ def test_creating_new_argument_scopes end def test_child_hides_parent_arg_names - parent = Rake::TaskArguments.new(['aa'], [1]) - child = Rake::TaskArguments.new(['aa'], [2], parent) + parent = Rake::TaskArguments.new(["aa"], [1]) + child = Rake::TaskArguments.new(["aa"], [2], parent) assert_equal 2, child.aa end def test_default_arguments_values_can_be_merged ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"]) - ta.with_defaults({ :aa => 'default_val' }) - assert_equal 'default_val', ta[:aa] - assert_equal 'original_val', ta[:bb] + ta.with_defaults(aa: "default_val") + assert_equal "default_val", ta[:aa] + assert_equal "original_val", ta[:bb] end def test_default_arguments_that_dont_match_names_are_ignored ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"]) - ta.with_defaults({ "cc" => "default_val" }) + ta.with_defaults("cc" => "default_val") assert_nil ta[:cc] end @@ -91,8 +120,8 @@ def test_all_and_extra_arguments_without_named_arguments _, args = app.parse_task_string("task[1,two,more]") ta = Rake::TaskArguments.new([], args) assert_equal [], ta.names - assert_equal ['1', 'two', 'more'], ta.to_a - assert_equal ['1', 'two', 'more'], ta.extras + assert_equal ["1", "two", "more"], ta.to_a + assert_equal ["1", "two", "more"], ta.extras end def test_all_and_extra_arguments_with_named_arguments @@ -102,8 +131,8 @@ def test_all_and_extra_arguments_with_named_arguments assert_equal [:first, :second], ta.names assert_equal "1", ta[:first] assert_equal "two", ta[:second] - assert_equal ['1', 'two', 'more', 'still more'], ta.to_a - assert_equal ['more', 'still more'], ta.extras + assert_equal ["1", "two", "more", "still more"], ta.to_a + assert_equal ["more", "still more"], ta.extras end def test_extra_args_with_less_than_named_arguments @@ -113,8 +142,8 @@ def test_extra_args_with_less_than_named_arguments assert_equal [:first, :second, :third], ta.names assert_equal "1", ta[:first] assert_equal "two", ta[:second] - assert_equal nil, ta[:third] - assert_equal ['1', 'two'], ta.to_a + assert_nil ta[:third] + assert_equal ["1", "two"], ta.to_a assert_equal [], ta.extras end diff --git a/test/test_rake_task_lib.rb b/test/test_rake_task_lib.rb deleted file mode 100644 index 9f3f7e9da..000000000 --- a/test/test_rake_task_lib.rb +++ /dev/null @@ -1,9 +0,0 @@ -require File.expand_path('../helper', __FILE__) -require 'rake/tasklib' - -class TestRakeTaskLib < Rake::TestCase - def test_paste - tl = Rake::TaskLib.new - assert_equal :ab, tl.paste(:a, :b) - end -end diff --git a/test/test_rake_task_manager.rb b/test/test_rake_task_manager.rb index 5ec4c0e65..88937c604 100644 --- a/test/test_rake_task_manager.rb +++ b/test/test_rake_task_manager.rb @@ -1,6 +1,7 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakeTaskManager < Rake::TestCase +class TestRakeTaskManager < Rake::TestCase # :nodoc: def setup super @@ -21,10 +22,20 @@ def test_define_task def test_index e = assert_raises RuntimeError do - @tm['bad'] + @tm["bad"] end - assert_equal "Don't know how to build task 'bad'", e.message + assert_equal "Don't know how to build task 'bad' (See the list of available tasks with `rake --tasks`)", e.message + end + + def test_undefined_task_with_custom_application + Rake.application.init("myrake", nil) + + e = assert_raises RuntimeError do + @tm["bad"] + end + + assert_equal "Don't know how to build task 'bad' (See the list of available tasks with `myrake --tasks`)", e.message end def test_name_lookup @@ -37,7 +48,24 @@ def test_namespace_task_create t = @tm.define_task(Rake::Task, :t) assert_equal "x:t", t.name end - assert_equal ["x:t"], @tm.tasks.map { |t| t.name } + assert_equal ["x:t"], @tm.tasks.map(&:name) + end + + def test_define_namespaced_task + t = @tm.define_task(Rake::Task, "n:a:m:e:t") + assert_equal Rake::Scope.make("e", "m", "a", "n"), t.scope + assert_equal "n:a:m:e:t", t.name + assert_equal @tm, t.application + end + + def test_define_namespace_in_namespace + t = nil + @tm.in_namespace("n") do + t = @tm.define_task(Rake::Task, "a:m:e:t") + end + assert_equal Rake::Scope.make("e", "m", "a", "n"), t.scope + assert_equal "n:a:m:e:t", t.name + assert_equal @tm, t.application end def test_anonymous_namespace @@ -55,7 +83,7 @@ def test_create_filetask_in_namespace assert_equal "fn", t.name end - assert_equal ["fn"], @tm.tasks.map { |t| t.name } + assert_equal ["fn"], @tm.tasks.map(&:name) end def test_namespace_yields_same_namespace_as_returned @@ -67,7 +95,7 @@ def test_namespace_yields_same_namespace_as_returned end def test_name_lookup_with_implicit_file_tasks - FileUtils.touch 'README.rdoc' + FileUtils.touch "README.rdoc" t = @tm["README.rdoc"] @@ -89,6 +117,7 @@ def test_name_lookup_in_multiple_scopes @tm.in_namespace("a") do aa = @tm.define_task(Rake::Task, :aa) mid_z = @tm.define_task(Rake::Task, :z) + ns_d = @tm.define_task(Rake::Task, "n:t") @tm.in_namespace("b") do bb = @tm.define_task(Rake::Task, :bb) bot_z = @tm.define_task(Rake::Task, :z) @@ -116,13 +145,15 @@ def test_name_lookup_in_multiple_scopes assert_equal top_z, @tm["^z"] assert_equal top_z, @tm["^^z"] # Over the top assert_equal top_z, @tm["rake:z"] + assert_equal ns_d, @tm["n:t"] + assert_equal ns_d, @tm["a:n:t"] end assert_equal Rake::Scope.make, @tm.current_scope assert_equal Rake::Scope.make, xx.scope - assert_equal Rake::Scope.make('a'), aa.scope - assert_equal Rake::Scope.make('b', 'a'), bb.scope + assert_equal Rake::Scope.make("a"), aa.scope + assert_equal Rake::Scope.make("b", "a"), bb.scope end def test_lookup_with_explicit_scopes @@ -148,7 +179,7 @@ def test_correctly_scoped_prerequisites_are_invoked @tm.define_task(Rake::Task, :z) do values << "top z" end @tm.in_namespace("a") do @tm.define_task(Rake::Task, :z) do values << "next z" end - @tm.define_task(Rake::Task, :x => :z) + @tm.define_task(Rake::Task, x: :z) end @tm["a:x"].invoke diff --git a/test/test_rake_task_manager_argument_resolution.rb b/test/test_rake_task_manager_argument_resolution.rb index 43fa2ac44..21e28a951 100644 --- a/test/test_rake_task_manager_argument_resolution.rb +++ b/test/test_rake_task_manager_argument_resolution.rb @@ -1,15 +1,23 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakeTaskManagerArgumentResolution < Rake::TestCase +class TestRakeTaskManagerArgumentResolution < Rake::TestCase # :nodoc: def test_good_arg_patterns - assert_equal [:t, [], []], task(:t) - assert_equal [:t, [], [:x]], task(:t => :x) - assert_equal [:t, [], [:x, :y]], task(:t => [:x, :y]) + assert_equal [:t, [], [], nil], task(:t) + assert_equal [:t, [], [:x], nil], task(t: :x) + assert_equal [:t, [], [:x, :y], nil], task(t: [:x, :y]) - assert_equal [:t, [:a, :b], []], task(:t, [:a, :b]) - assert_equal [:t, [:a, :b], [:x]], task(:t, [:a, :b] => :x) - assert_equal [:t, [:a, :b], [:x, :y]], task(:t, [:a, :b] => [:x, :y]) + assert_equal [:t, [], [], [:m]], task(:t, order_only: [:m]) + assert_equal [:t, [], [:x, :y], [:m, :n]], task(t: [:x, :y], order_only: [:m, :n]) + + assert_equal [:t, [:a, :b], [], nil], task(:t, [:a, :b]) + assert_equal [:t, [:a, :b], [:x], nil], task(:t, [:a, :b] => :x) + assert_equal [:t, [:a, :b], [:x, :y], nil], task(:t, [:a, :b] => [:x, :y]) + + assert_equal [:t, [:a, :b], [], [:m]], task(:t, [:a, :b], order_only: [:m]) + assert_equal [:t, [:a, :b], [:x], [:m]], task(:t, [:a, :b] => :x, order_only: [:m]) + assert_equal [:t, [:a, :b], [:x, :y], [:m, :n]], task(:t, [:a, :b] => [:x, :y], order_only: [:m, :n]) end def task(*args) diff --git a/test/test_rake_task_with_arguments.rb b/test/test_rake_task_with_arguments.rb index 9d56ffbe8..36dfa2646 100644 --- a/test/test_rake_task_with_arguments.rb +++ b/test/test_rake_task_with_arguments.rb @@ -1,6 +1,7 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakeTaskWithArguments < Rake::TestCase +class TestRakeTaskWithArguments < Rake::TestCase # :nodoc: include Rake def setup @@ -12,6 +13,7 @@ def setup def teardown Rake::TaskManager.record_task_metadata = false + Rake.application.thread_pool.join super end @@ -27,7 +29,7 @@ def test_args_given end def test_name_and_needs - t = task(:t => [:pre]) + t = task(t: [:pre]) assert_equal "t", t.name assert_equal [], t.arg_names assert_equal ["pre"], t.prerequisites @@ -47,7 +49,7 @@ def test_arg_list_is_empty_if_no_args_given def test_tasks_can_access_arguments_as_hash t = task :t, :a, :b, :c do |tt, args| - assert_equal({:a => 1, :b => 2, :c => 3}, args.to_hash) + assert_equal({ a: 1, b: 2, c: 3 }, args.to_hash) assert_equal 1, args[:a] assert_equal 2, args[:b] assert_equal 3, args[:c] @@ -73,15 +75,43 @@ def test_actions_of_various_arity_are_ok_with_args t.enhance do |t2, args| notes << :d assert_equal t, t2 - assert_equal({:x => 1}, args.to_hash) + assert_equal({ x: 1 }, args.to_hash) end t.invoke(1) assert_equal [:a, :b, :c, :d], notes end + def test_actions_adore_keywords + # https://github.com/ruby/rake/pull/174#issuecomment-263460761 + skip if jruby9? + eval <<-RUBY, binding, __FILE__, __LINE__+1 + notes = [] + t = task :t, [:reqr, :ovrd, :dflt] # required, overridden-optional, default-optional + verify = lambda do |name, expecteds, actuals| + notes << name + assert_equal expecteds.length, actuals.length + expecteds.zip(actuals) { |e, a| assert_equal e, a, "(TEST \#{name})" } + end + + t.enhance { |dflt: 'd', **| verify.call :a, ['d'], [dflt] } + t.enhance { |ovrd: '-', **| verify.call :b, ['o'], [ovrd] } + t.enhance { |reqr: , **| verify.call :c, ['r'], [reqr] } + + t.enhance { |t2, dflt: 'd', **| verify.call :d, [t,'d'], [t2,dflt] } + t.enhance { |t2, ovrd: 'd', **| verify.call :e, [t,'o'], [t2,ovrd] } + t.enhance { |t2, reqr: , **| verify.call :f, [t,'r'], [t2,reqr] } + + t.enhance { |t2, dflt: 'd', reqr:, **| verify.call :g, [t,'d','r'], [t2,dflt,reqr] } + t.enhance { |t2, ovrd: '-', reqr:, **| verify.call :h, [t,'o','r'], [t2,ovrd,reqr] } + + t.invoke('r', 'o') + assert_equal [*:a..:h], notes + RUBY + end + def test_arguments_are_passed_to_block t = task(:t, :a, :b) { |tt, args| - assert_equal({ :a => 1, :b => 2 }, args.to_hash) + assert_equal({ a: 1, b: 2 }, args.to_hash) } t.invoke(1, 2) end @@ -110,7 +140,7 @@ def test_arguments_are_passed_to_all_blocks end def test_block_with_no_parameters_is_ok - t = task(:t) { } + t = task(:t) {} t.invoke(1, 2) end @@ -154,7 +184,7 @@ def test_args_not_passed_if_no_arg_names task(:pre, :rev) { |t, args| assert_equal({}, args.to_hash) } - t = task(:t => [:pre]) + t = task(t: [:pre]) t.invoke("bill", "1.2") end diff --git a/test/test_rake_test_task.rb b/test/test_rake_test_task.rb index 637accc29..2fd1c1526 100644 --- a/test/test_rake_test_task.rb +++ b/test/test_rake_test_task.rb @@ -1,42 +1,66 @@ -require File.expand_path('../helper', __FILE__) -require 'rake/testtask' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "rake/testtask" -class TestRakeTestTask < Rake::TestCase +class TestRakeTestTask < Rake::TestCase # :nodoc: include Rake def test_initialize tt = Rake::TestTask.new do |t| end refute_nil tt assert_equal :test, tt.name - assert_equal ['lib'], tt.libs - assert_equal 'test/test*.rb', tt.pattern + assert_equal ["lib"], tt.libs + assert_equal "test/test*.rb", tt.pattern assert_equal false, tt.verbose + assert_equal true, tt.warning + assert_equal [], tt.deps assert Task.task_defined?(:test) end + def test_initialize_deps + tt = Rake::TestTask.new(example: :bar) + refute_nil tt + assert_equal :bar, tt.deps + assert Task.task_defined?(:example) + end + + def test_initialize_multi_deps + tt = Rake::TestTask.new(example: [:foo, :bar]) + refute_nil tt + assert_equal [:foo, :bar], tt.deps + assert Task.task_defined?(:example) + end + def test_initialize_override - tt = Rake::TestTask.new(:example) do |t| - t.libs = ['src', 'ext'] - t.pattern = 'test/tc_*.rb' + tt = Rake::TestTask.new(example: :bar) do |t| + t.description = "Run example tests" + t.libs = ["src", "ext"] + t.pattern = "test/tc_*.rb" + t.warning = true t.verbose = true + t.deps = [:env] end refute_nil tt + assert_equal "Run example tests", tt.description assert_equal :example, tt.name - assert_equal ['src', 'ext'], tt.libs - assert_equal 'test/tc_*.rb', tt.pattern + assert_equal ["src", "ext"], tt.libs + assert_equal "test/tc_*.rb", tt.pattern + assert_equal true, tt.warning assert_equal true, tt.verbose + assert_equal [:env], tt.deps + assert_match(/-w/, tt.ruby_opts_string) assert Task.task_defined?(:example) end def test_file_list_env_test - ENV['TEST'] = 'testfile.rb' + ENV["TEST"] = "testfile.rb" tt = Rake::TestTask.new do |t| - t.pattern = '*' + t.pattern = "*" end assert_equal ["testfile.rb"], tt.file_list.to_a ensure - ENV.delete 'TEST' + ENV.delete "TEST" end def test_libs_equals @@ -46,74 +70,121 @@ def test_libs_equals path = %w[lib A B].join File::PATH_SEPARATOR - assert_equal "-I\"#{path}\"", test_task.ruby_opts_string + assert_equal "-w -I\"#{path}\"", test_task.ruby_opts_string end def test_libs_equals_empty test_task = Rake::TestTask.new do |t| - t.libs = [] + t.libs = [] + t.warning = false end - assert_equal '', test_task.ruby_opts_string + assert_equal "", test_task.ruby_opts_string end def test_pattern_equals + ["gl.rb", "ob.rb"].each do |f| + create_file(f) + end tt = Rake::TestTask.new do |t| - t.pattern = '*.rb' + t.pattern = "*.rb" end - assert_equal ['*.rb'], tt.file_list.to_a + assert_equal ["gl.rb", "ob.rb"], tt.file_list.to_a end def test_pattern_equals_test_files_equals + ["gl.rb", "ob.rb"].each do |f| + create_file(f) + end tt = Rake::TestTask.new do |t| - t.test_files = FileList['a.rb', 'b.rb'] - t.pattern = '*.rb' + t.test_files = FileList["a.rb", "b.rb"] + t.pattern = "*.rb" end - assert_equal ['a.rb', 'b.rb', '*.rb'], tt.file_list.to_a + assert_equal ["a.rb", "b.rb", "gl.rb", "ob.rb"], tt.file_list.to_a end def test_run_code_direct + globbed = ["test_gl.rb", "test_ob.rb"].map { |f| File.join("test", f) } + others = ["a.rb", "b.rb"].map { |f| File.join("test", f) } + (globbed + others).each do |f| + create_file(f) + end test_task = Rake::TestTask.new do |t| t.loader = :direct + # if t.pettern and t.test_files are nil, + # t.pettern is "test/test*.rb" end assert_equal '-e "ARGV.each{|f| require f}"', test_task.run_code + assert_equal globbed, test_task.file_list.to_a end def test_run_code_rake + spec = Gem::Specification.new "rake", 0 + spec.loaded_from = File.join Gem::Specification.dirs.last, "rake-0.gemspec" + rake, Gem.loaded_specs["rake"] = Gem.loaded_specs["rake"], spec + test_task = Rake::TestTask.new do |t| t.loader = :rake end - assert_match(/-I".*?" ".*?"/, test_task.run_code) + assert_match(/\A-I".*?" ".*?"\Z/, test_task.run_code) + ensure + Gem.loaded_specs["rake"] = rake end - def test_run_code_testrb_ruby_1_8_2 - test_task = Rake::TestTask.new do |t| - t.loader = :testrb + def test_test_files_equals + tt = Rake::TestTask.new do |t| + t.test_files = FileList["a.rb", "b.rb"] end - def test_task.ruby_version() '1.8.2' end - - assert_match(/^-S testrb +".*"$/, test_task.run_code) + assert_equal ["a.rb", "b.rb"], tt.file_list.to_a end - def test_run_code_testrb_ruby_1_8_6 - test_task = Rake::TestTask.new do |t| - t.loader = :testrb - end + def test_task_prerequisites + Rake::TestTask.new :parent + Rake::TestTask.new child: :parent + + task = Rake::Task[:child] + assert_includes task.prerequisites, "parent" + end - def test_task.ruby_version() '1.8.6' end + def test_task_prerequisites_multi + Rake::TestTask.new :parent + Rake::TestTask.new :parent2 + Rake::TestTask.new child: [:parent, :parent2] - assert_match(/^-S testrb +$/, test_task.run_code) + task = Rake::Task[:child] + assert_includes task.prerequisites, "parent" + assert_includes task.prerequisites, "parent2" end - def test_test_files_equals - tt = Rake::TestTask.new do |t| - t.test_files = FileList['a.rb', 'b.rb'] + def test_task_prerequisites_deps + Rake::TestTask.new :parent + + Rake::TestTask.new :child do |t| + t.deps = :parent end - assert_equal ["a.rb", 'b.rb'], tt.file_list.to_a + task = Rake::Task[:child] + assert_includes task.prerequisites, "parent" end + def test_task_order_only_prerequisites + t = task(a: 'b') { + :aaa + } | 'c' + b, c = task('b'), task('c') + assert_equal ['b'], t.prerequisites + assert_equal ['c'], t.order_only_prerequisites + assert_equal [b, c], t.prerequisite_tasks + end + + def test_task_order_only_prerequisites_key + t = task 'a' => 'b', order_only: ['c'] + b, c = task('b'), task('c') + assert_equal ['b'], t.prerequisites + assert_equal ['c'], t.order_only_prerequisites + assert_equal [b, c], t.prerequisite_tasks + end end diff --git a/test/test_rake_thread_pool.rb b/test/test_rake_thread_pool.rb index 93f32fb35..42f648854 100644 --- a/test/test_rake_thread_pool.rb +++ b/test/test_rake_thread_pool.rb @@ -1,8 +1,8 @@ -require File.expand_path('../helper', __FILE__) -require 'rake/thread_pool' -require 'test/unit/assertions' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "rake/thread_pool" -class TestRakeTestThreadPool < Rake::TestCase +class TestRakeTestThreadPool < Rake::TestCase # :nodoc: include Rake def test_pool_executes_in_current_thread_for_zero_threads @@ -26,13 +26,13 @@ def test_pool_executes_in_two_other_threads_for_pool_of_size_two sleep 0.1 Thread.current } - }.each { |f| - f.value - } + }.each(&:value) refute_equal threads[0], threads[1] refute_equal Thread.current, threads[0] refute_equal Thread.current, threads[1] + ensure + pool.join end def test_pool_creates_the_correct_number_of_threads @@ -95,6 +95,8 @@ def test_exceptions assert_raises(CustomError) do pool.future(2, &deep_exception_block).value end + ensure + pool.join end def test_pool_prevents_deadlock @@ -108,7 +110,7 @@ def test_pool_prevents_deadlock } } - common_dependency_b = pool.future { futures_a.each { |f| f.value } } + common_dependency_b = pool.future { futures_a.each(&:value) } futures_b = 10.times.map { pool.future { common_dependency_b.value @@ -116,7 +118,7 @@ def test_pool_prevents_deadlock } } - futures_b.each { |f| f.value } + futures_b.each(&:value) pool.join end diff --git a/test/test_rake_top_level_functions.rb b/test/test_rake_top_level_functions.rb index fee702dc1..f0dec1b76 100644 --- a/test/test_rake_top_level_functions.rb +++ b/test/test_rake_top_level_functions.rb @@ -1,6 +1,7 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakeTopLevelFunctions < Rake::TestCase +class TestRakeTopLevelFunctions < Rake::TestCase # :nodoc: def setup super @@ -26,19 +27,19 @@ def test_namespace namespace("xyz", &block) expected = [ - [[:in_namespace, 'xyz'], block] + [[:in_namespace, "xyz"], block] ] assert_equal expected, @app.called end def test_import - import('x', 'y', 'z') + import("x", "y", "z") expected = [ - [[:add_import, 'x'], nil], - [[:add_import, 'y'], nil], - [[:add_import, 'z'], nil], + [[:add_import, "x"], nil], + [[:add_import, "y"], nil], + [[:add_import, "z"], nil], ] assert_equal expected, @app.called diff --git a/test/test_rake_win32.rb b/test/test_rake_win32.rb index fc2746a0a..ed08ef09e 100644 --- a/test/test_rake_win32.rb +++ b/test/test_rake_win32.rb @@ -1,50 +1,51 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -class TestRakeWin32 < Rake::TestCase +class TestRakeWin32 < Rake::TestCase # :nodoc: - Win32 = Rake::Win32 + Win32 = Rake::Win32 # :nodoc: def test_win32_system_dir_uses_home_if_defined - ENV['HOME'] = 'C:\\HP' + ENV["HOME"] = 'C:\\HP' assert_equal "C:/HP/Rake", Win32.win32_system_dir end def test_win32_system_dir_uses_homedrive_homepath_when_no_home_defined - ENV['HOME'] = nil - ENV['HOMEDRIVE'] = 'C:' - ENV['HOMEPATH'] = '\\HP' + ENV["HOME"] = nil + ENV["HOMEDRIVE"] = "C:" + ENV["HOMEPATH"] = '\\HP' assert_equal "C:/HP/Rake", Win32.win32_system_dir end def test_win32_system_dir_uses_appdata_when_no_home_or_home_combo - ENV['APPDATA'] = "C:\\Documents and Settings\\HP\\Application Data" - ENV['HOME'] = nil - ENV['HOMEDRIVE'] = nil - ENV['HOMEPATH'] = nil + ENV["APPDATA"] = "C:\\Documents and Settings\\HP\\Application Data" + ENV["HOME"] = nil + ENV["HOMEDRIVE"] = nil + ENV["HOMEPATH"] = nil assert_equal "C:/Documents and Settings/HP/Application Data/Rake", Win32.win32_system_dir end def test_win32_system_dir_fallback_to_userprofile_otherwise - ENV['HOME'] = nil - ENV['HOMEDRIVE'] = nil - ENV['HOMEPATH'] = nil - ENV['APPDATA'] = nil - ENV['USERPROFILE'] = "C:\\Documents and Settings\\HP" + ENV["HOME"] = nil + ENV["HOMEDRIVE"] = nil + ENV["HOMEPATH"] = nil + ENV["APPDATA"] = nil + ENV["USERPROFILE"] = "C:\\Documents and Settings\\HP" assert_equal "C:/Documents and Settings/HP/Rake", Win32.win32_system_dir end def test_win32_system_dir_nil_of_no_env_vars - ENV['APPDATA'] = nil - ENV['HOME'] = nil - ENV['HOMEDRIVE'] = nil - ENV['HOMEPATH'] = nil - ENV['RAKE_SYSTEM'] = nil - ENV['USERPROFILE'] = nil + ENV["APPDATA"] = nil + ENV["HOME"] = nil + ENV["HOMEDRIVE"] = nil + ENV["HOMEPATH"] = nil + ENV["RAKE_SYSTEM"] = nil + ENV["USERPROFILE"] = nil assert_raises(Rake::Win32::Win32HomeError) do Win32.win32_system_dir @@ -54,17 +55,21 @@ def test_win32_system_dir_nil_of_no_env_vars def test_win32_backtrace_with_different_case ex = nil begin - raise 'test exception' + raise "test exception" rescue => ex end - ex.set_backtrace ['abc', 'rakefile'] + ex.set_backtrace ["abc", "rakefile"] rake = Rake::Application.new rake.options.trace = true - rake.instance_variable_set(:@rakefile, 'Rakefile') + rake.instance_variable_set(:@rakefile, "Rakefile") - _, err = capture_io { rake.display_error_message(ex) } + _, err = capture_io { + rake.set_default_options # reset trace output IO + + rake.display_error_message(ex) + } assert_match(/rakefile/, err) end diff --git a/test/test_thread_history_display.rb b/test/test_thread_history_display.rb index bb5879cff..026576446 100644 --- a/test/test_thread_history_display.rb +++ b/test/test_thread_history_display.rb @@ -1,8 +1,9 @@ -require File.expand_path('../helper', __FILE__) +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) -require 'rake/thread_history_display' +require "rake/thread_history_display" -class TestThreadHistoryDisplay < Rake::TestCase +class TestThreadHistoryDisplay < Rake::TestCase # :nodoc: def setup super @time = 1_000_000 @@ -18,7 +19,7 @@ def test_banner end def test_item_queued - @stats << event(:item_queued, :item_id => 123) + @stats << event(:item_queued, item_id: 123) out, _ = capture_io do @display.show end @@ -26,7 +27,7 @@ def test_item_queued end def test_item_dequeued - @stats << event(:item_dequeued, :item_id => 123) + @stats << event(:item_dequeued, item_id: 123) out, _ = capture_io do @display.show end @@ -34,8 +35,8 @@ def test_item_dequeued end def test_multiple_items - @stats << event(:item_queued, :item_id => 123) - @stats << event(:item_queued, :item_id => 124) + @stats << event(:item_queued, item_id: 123) + @stats << event(:item_queued, item_id: 124) out, _ = capture_io do @display.show end @@ -44,7 +45,7 @@ def test_multiple_items end def test_waiting - @stats << event(:waiting, :item_id => 123) + @stats << event(:waiting, item_id: 123) out, _ = capture_io do @display.show end @@ -52,7 +53,7 @@ def test_waiting end def test_continue - @stats << event(:continue, :item_id => 123) + @stats << event(:continue, item_id: 123) out, _ = capture_io do @display.show end @@ -62,8 +63,8 @@ def test_continue def test_thread_deleted @stats << event( :thread_deleted, - :deleted_thread => 123_456, - :thread_count => 12) + deleted_thread: 123_456, + thread_count: 12) out, _ = capture_io do @display.show end @@ -75,8 +76,8 @@ def test_thread_deleted def test_thread_created @stats << event( :thread_created, - :new_thread => 123_456, - :thread_count => 13) + new_thread: 123_456, + thread_count: 13) out, _ = capture_io do @display.show end @@ -89,10 +90,10 @@ def test_thread_created def event(type, data = {}) result = { - :event => type, - :time => @time / 1_000_000.0, - :data => data, - :thread => Thread.current.object_id + event: type, + time: @time / 1_000_000.0, + data: data, + thread: Thread.current.object_id } @time += 1 result diff --git a/test/test_trace_output.rb b/test/test_trace_output.rb index f9aead989..46403870f 100644 --- a/test/test_trace_output.rb +++ b/test/test_trace_output.rb @@ -1,14 +1,15 @@ -require File.expand_path('../helper', __FILE__) -require 'stringio' +# frozen_string_literal: true +require File.expand_path("../helper", __FILE__) +require "stringio" -class TestTraceOutput < Rake::TestCase +class TestTraceOutput < Rake::TestCase # :nodoc: include Rake::TraceOutput - class PrintSpy + class PrintSpy # :nodoc: attr_reader :result, :calls def initialize - @result = "" + @result = "".dup @calls = 0 end