[macruby-changes] [2551] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Mon Sep 14 10:15:14 PDT 2009
Revision: 2551
http://trac.macosforge.org/projects/ruby/changeset/2551
Author: eloy.de.enige at gmail.com
Date: 2009-09-14 10:15:13 -0700 (Mon, 14 Sep 2009)
Log Message:
-----------
Added Rake to the list of external libraries to test.
Modified Paths:
--------------
MacRuby/trunk/rakelib/test.rake
Added Paths:
-----------
MacRuby/trunk/test/libs/rake/
MacRuby/trunk/test/libs/rake/.gitignore
MacRuby/trunk/test/libs/rake/.togglerc
MacRuby/trunk/test/libs/rake/CHANGES
MacRuby/trunk/test/libs/rake/MIT-LICENSE
MacRuby/trunk/test/libs/rake/README.rdoc
MacRuby/trunk/test/libs/rake/Rakefile
MacRuby/trunk/test/libs/rake/TODO
MacRuby/trunk/test/libs/rake/bin/
MacRuby/trunk/test/libs/rake/bin/rake
MacRuby/trunk/test/libs/rake/doc/
MacRuby/trunk/test/libs/rake/doc/command_line_usage.rdoc
MacRuby/trunk/test/libs/rake/doc/example/
MacRuby/trunk/test/libs/rake/doc/example/.cvsignore
MacRuby/trunk/test/libs/rake/doc/example/Rakefile1
MacRuby/trunk/test/libs/rake/doc/example/Rakefile2
MacRuby/trunk/test/libs/rake/doc/example/a.c
MacRuby/trunk/test/libs/rake/doc/example/b.c
MacRuby/trunk/test/libs/rake/doc/example/main.c
MacRuby/trunk/test/libs/rake/doc/glossary.rdoc
MacRuby/trunk/test/libs/rake/doc/jamis.rb
MacRuby/trunk/test/libs/rake/doc/proto_rake.rdoc
MacRuby/trunk/test/libs/rake/doc/rake.1.gz
MacRuby/trunk/test/libs/rake/doc/rakefile.rdoc
MacRuby/trunk/test/libs/rake/doc/rational.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.4.14.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.4.15.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.5.0.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.5.3.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.5.4.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.6.0.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.0.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.1.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.2.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.3.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.0.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.2.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.3.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.4.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.5.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.6.rdoc
MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.7.rdoc
MacRuby/trunk/test/libs/rake/install.rb
MacRuby/trunk/test/libs/rake/lib/
MacRuby/trunk/test/libs/rake/lib/rake/
MacRuby/trunk/test/libs/rake/lib/rake/alt_system.rb
MacRuby/trunk/test/libs/rake/lib/rake/application.rb
MacRuby/trunk/test/libs/rake/lib/rake/classic_namespace.rb
MacRuby/trunk/test/libs/rake/lib/rake/clean.rb
MacRuby/trunk/test/libs/rake/lib/rake/cloneable.rb
MacRuby/trunk/test/libs/rake/lib/rake/contrib/
MacRuby/trunk/test/libs/rake/lib/rake/contrib/compositepublisher.rb
MacRuby/trunk/test/libs/rake/lib/rake/contrib/ftptools.rb
MacRuby/trunk/test/libs/rake/lib/rake/contrib/publisher.rb
MacRuby/trunk/test/libs/rake/lib/rake/contrib/rubyforgepublisher.rb
MacRuby/trunk/test/libs/rake/lib/rake/contrib/sshpublisher.rb
MacRuby/trunk/test/libs/rake/lib/rake/contrib/sys.rb
MacRuby/trunk/test/libs/rake/lib/rake/default_loader.rb
MacRuby/trunk/test/libs/rake/lib/rake/dsl.rb
MacRuby/trunk/test/libs/rake/lib/rake/early_time.rb
MacRuby/trunk/test/libs/rake/lib/rake/environment.rb
MacRuby/trunk/test/libs/rake/lib/rake/ext/
MacRuby/trunk/test/libs/rake/lib/rake/ext/module.rb
MacRuby/trunk/test/libs/rake/lib/rake/ext/string.rb
MacRuby/trunk/test/libs/rake/lib/rake/ext/time.rb
MacRuby/trunk/test/libs/rake/lib/rake/file_creation_task.rb
MacRuby/trunk/test/libs/rake/lib/rake/file_list.rb
MacRuby/trunk/test/libs/rake/lib/rake/file_task.rb
MacRuby/trunk/test/libs/rake/lib/rake/file_utils.rb
MacRuby/trunk/test/libs/rake/lib/rake/gempackagetask.rb
MacRuby/trunk/test/libs/rake/lib/rake/invocation_chain.rb
MacRuby/trunk/test/libs/rake/lib/rake/invocation_exception_mixin.rb
MacRuby/trunk/test/libs/rake/lib/rake/lib/
MacRuby/trunk/test/libs/rake/lib/rake/lib/project.rake
MacRuby/trunk/test/libs/rake/lib/rake/loaders/
MacRuby/trunk/test/libs/rake/lib/rake/loaders/makefile.rb
MacRuby/trunk/test/libs/rake/lib/rake/multi_task.rb
MacRuby/trunk/test/libs/rake/lib/rake/name_space.rb
MacRuby/trunk/test/libs/rake/lib/rake/packagetask.rb
MacRuby/trunk/test/libs/rake/lib/rake/psuedo_status.rb
MacRuby/trunk/test/libs/rake/lib/rake/rake_file_utils.rb
MacRuby/trunk/test/libs/rake/lib/rake/rake_module.rb
MacRuby/trunk/test/libs/rake/lib/rake/rake_test_loader.rb
MacRuby/trunk/test/libs/rake/lib/rake/rdoctask.rb
MacRuby/trunk/test/libs/rake/lib/rake/ruby182_test_unit_fix.rb
MacRuby/trunk/test/libs/rake/lib/rake/rule_recursion_overflow_error.rb
MacRuby/trunk/test/libs/rake/lib/rake/runtest.rb
MacRuby/trunk/test/libs/rake/lib/rake/task.rb
MacRuby/trunk/test/libs/rake/lib/rake/task_argument_error.rb
MacRuby/trunk/test/libs/rake/lib/rake/task_arguments.rb
MacRuby/trunk/test/libs/rake/lib/rake/task_manager.rb
MacRuby/trunk/test/libs/rake/lib/rake/tasklib.rb
MacRuby/trunk/test/libs/rake/lib/rake/testtask.rb
MacRuby/trunk/test/libs/rake/lib/rake/win32.rb
MacRuby/trunk/test/libs/rake/lib/rake.rb
MacRuby/trunk/test/libs/rake/rake.blurb
MacRuby/trunk/test/libs/rake/rake.gemspec
MacRuby/trunk/test/libs/rake/rakelib/
MacRuby/trunk/test/libs/rake/rakelib/extra.rake
MacRuby/trunk/test/libs/rake/rakelib/publish.rake
MacRuby/trunk/test/libs/rake/rakelib/rbx.rake
MacRuby/trunk/test/libs/rake/rakelib/ruby19.rake
MacRuby/trunk/test/libs/rake/rakelib/tags.rake
MacRuby/trunk/test/libs/rake/test/
MacRuby/trunk/test/libs/rake/test/capture_stdout.rb
MacRuby/trunk/test/libs/rake/test/check_expansion.rb
MacRuby/trunk/test/libs/rake/test/check_no_expansion.rb
MacRuby/trunk/test/libs/rake/test/contrib/
MacRuby/trunk/test/libs/rake/test/contrib/test_sys.rb
MacRuby/trunk/test/libs/rake/test/data/
MacRuby/trunk/test/libs/rake/test/data/chains/
MacRuby/trunk/test/libs/rake/test/data/chains/.cvsignore
MacRuby/trunk/test/libs/rake/test/data/chains/Rakefile
MacRuby/trunk/test/libs/rake/test/data/comments/
MacRuby/trunk/test/libs/rake/test/data/comments/Rakefile
MacRuby/trunk/test/libs/rake/test/data/default/
MacRuby/trunk/test/libs/rake/test/data/default/Rakefile
MacRuby/trunk/test/libs/rake/test/data/dryrun/
MacRuby/trunk/test/libs/rake/test/data/dryrun/.cvsignore
MacRuby/trunk/test/libs/rake/test/data/dryrun/Rakefile
MacRuby/trunk/test/libs/rake/test/data/file_creation_task/
MacRuby/trunk/test/libs/rake/test/data/file_creation_task/.cvsignore
MacRuby/trunk/test/libs/rake/test/data/file_creation_task/.gitignore
MacRuby/trunk/test/libs/rake/test/data/file_creation_task/Rakefile
MacRuby/trunk/test/libs/rake/test/data/imports/
MacRuby/trunk/test/libs/rake/test/data/imports/.cvsignore
MacRuby/trunk/test/libs/rake/test/data/imports/Rakefile
MacRuby/trunk/test/libs/rake/test/data/imports/deps.mf
MacRuby/trunk/test/libs/rake/test/data/multidesc/
MacRuby/trunk/test/libs/rake/test/data/multidesc/Rakefile
MacRuby/trunk/test/libs/rake/test/data/namespace/
MacRuby/trunk/test/libs/rake/test/data/namespace/.gitignore
MacRuby/trunk/test/libs/rake/test/data/namespace/Rakefile
MacRuby/trunk/test/libs/rake/test/data/nosearch/
MacRuby/trunk/test/libs/rake/test/data/nosearch/dummy
MacRuby/trunk/test/libs/rake/test/data/rakelib/
MacRuby/trunk/test/libs/rake/test/data/rakelib/test1.rb
MacRuby/trunk/test/libs/rake/test/data/rakelib/test2.rake
MacRuby/trunk/test/libs/rake/test/data/rbext/
MacRuby/trunk/test/libs/rake/test/data/rbext/rakefile.rb
MacRuby/trunk/test/libs/rake/test/data/sample.mf
MacRuby/trunk/test/libs/rake/test/data/statusreturn/
MacRuby/trunk/test/libs/rake/test/data/statusreturn/Rakefile
MacRuby/trunk/test/libs/rake/test/data/sys/
MacRuby/trunk/test/libs/rake/test/data/sys/sys1.rake
MacRuby/trunk/test/libs/rake/test/data/unittest/
MacRuby/trunk/test/libs/rake/test/data/unittest/Rakefile
MacRuby/trunk/test/libs/rake/test/data/unittest/subdir/
MacRuby/trunk/test/libs/rake/test/data/unittest/subdir/README
MacRuby/trunk/test/libs/rake/test/data/verbose/
MacRuby/trunk/test/libs/rake/test/data/verbose/Rakefile
MacRuby/trunk/test/libs/rake/test/filecreation.rb
MacRuby/trunk/test/libs/rake/test/functional/
MacRuby/trunk/test/libs/rake/test/functional/functional_test.rb
MacRuby/trunk/test/libs/rake/test/functional/session_based_tests.rb
MacRuby/trunk/test/libs/rake/test/in_environment.rb
MacRuby/trunk/test/libs/rake/test/lib/
MacRuby/trunk/test/libs/rake/test/lib/application_test.rb
MacRuby/trunk/test/libs/rake/test/lib/clean_test.rb
MacRuby/trunk/test/libs/rake/test/lib/definitions_test.rb
MacRuby/trunk/test/libs/rake/test/lib/dsl_test.rb
MacRuby/trunk/test/libs/rake/test/lib/earlytime_test.rb
MacRuby/trunk/test/libs/rake/test/lib/environment_test.rb
MacRuby/trunk/test/libs/rake/test/lib/extension_test.rb
MacRuby/trunk/test/libs/rake/test/lib/file_creation_task_test.rb
MacRuby/trunk/test/libs/rake/test/lib/file_task_test.rb
MacRuby/trunk/test/libs/rake/test/lib/filelist_test.rb
MacRuby/trunk/test/libs/rake/test/lib/fileutils_test.rb
MacRuby/trunk/test/libs/rake/test/lib/ftp_test.rb
MacRuby/trunk/test/libs/rake/test/lib/invocation_chain_test.rb
MacRuby/trunk/test/libs/rake/test/lib/makefile_loader_test.rb
MacRuby/trunk/test/libs/rake/test/lib/multitask_test.rb
MacRuby/trunk/test/libs/rake/test/lib/namespace_test.rb
MacRuby/trunk/test/libs/rake/test/lib/package_task_test.rb
MacRuby/trunk/test/libs/rake/test/lib/pathmap_test.rb
MacRuby/trunk/test/libs/rake/test/lib/pseudo_status_test.rb
MacRuby/trunk/test/libs/rake/test/lib/rake_test.rb
MacRuby/trunk/test/libs/rake/test/lib/rdoc_task_test.rb
MacRuby/trunk/test/libs/rake/test/lib/require_test.rb
MacRuby/trunk/test/libs/rake/test/lib/rules_test.rb
MacRuby/trunk/test/libs/rake/test/lib/task_arguments_test.rb
MacRuby/trunk/test/libs/rake/test/lib/task_manager_test.rb
MacRuby/trunk/test/libs/rake/test/lib/task_test.rb
MacRuby/trunk/test/libs/rake/test/lib/tasklib_test.rb
MacRuby/trunk/test/libs/rake/test/lib/test_task_test.rb
MacRuby/trunk/test/libs/rake/test/lib/testtask_test.rb
MacRuby/trunk/test/libs/rake/test/lib/top_level_functions_test.rb
MacRuby/trunk/test/libs/rake/test/lib/win32_test.rb
MacRuby/trunk/test/libs/rake/test/rake_test_setup.rb
MacRuby/trunk/test/libs/rake/test/reqfile.rb
MacRuby/trunk/test/libs/rake/test/reqfile2.rb
MacRuby/trunk/test/libs/rake/test/reqfile3.rake
MacRuby/trunk/test/libs/rake/test/shellcommand.rb
MacRuby/trunk/test/libs/rake/test/test_helper.rb
Modified: MacRuby/trunk/rakelib/test.rake
===================================================================
--- MacRuby/trunk/rakelib/test.rake 2009-09-14 16:45:55 UTC (rev 2550)
+++ MacRuby/trunk/rakelib/test.rake 2009-09-14 17:15:13 UTC (rev 2551)
@@ -23,6 +23,10 @@
"http://test-unit.rubyforge.org/svn/trunk",
"-I lib test/run-test.rb"
],
+ 'rake' => [
+ "git://github.com/jimweirich/rake.git",
+ "-I lib ./bin/rake --trace"
+ ],
'bacon' => [
"git://github.com/chneukirchen/bacon.git",
"./bin/bacon -I lib --quiet ./test/*"
Added: MacRuby/trunk/test/libs/rake/.gitignore
===================================================================
--- MacRuby/trunk/test/libs/rake/.gitignore (rev 0)
+++ MacRuby/trunk/test/libs/rake/.gitignore 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,13 @@
+*.bak
+*.patch
+*.rbc
+.#*
+.idea
+TAGS
+coverage
+html
+pkg
+r19.diff
+temp_*
+testdata
+x
Added: MacRuby/trunk/test/libs/rake/.togglerc
===================================================================
--- MacRuby/trunk/test/libs/rake/.togglerc (rev 0)
+++ MacRuby/trunk/test/libs/rake/.togglerc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,7 @@
+(add-to-list
+ 'toggle-mapping-styles
+ '(rake . (
+ ("test/lib/\\1_test.rb" . "lib/rake/\\1.rb")
+ ) ))
+
+(buffer-toggle-style 'rake)
Added: MacRuby/trunk/test/libs/rake/CHANGES
===================================================================
--- MacRuby/trunk/test/libs/rake/CHANGES (rev 0)
+++ MacRuby/trunk/test/libs/rake/CHANGES 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,477 @@
+= Rake Changelog
+
+== Pre-Version 0.9.x
+
+* 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.
+
+* Allow single line comments immediately prior to a task to be used in
+ place of +desc+.
+
+* 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\xFChle)
+
+* 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.
Added: MacRuby/trunk/test/libs/rake/MIT-LICENSE
===================================================================
--- MacRuby/trunk/test/libs/rake/MIT-LICENSE (rev 0)
+++ MacRuby/trunk/test/libs/rake/MIT-LICENSE 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,21 @@
+Copyright (c) 2003, 2004 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.
+
Added: MacRuby/trunk/test/libs/rake/README.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/README.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/README.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,194 @@
+= RAKE -- Ruby Make
+
+Supporting Rake version: 0.8.7.
+
+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.
+
+* Flexible FileLists that act like arrays but know about manipulating
+ file names and paths.
+
+* A library of prepackaged tasks to make building rakefiles easier. For example,
+ tasks for building tarballs, gems and RDoc output are provided.
+
+* Supports parallel execution of tasks.
+
+
+== Installation
+
+=== Gem Installation
+
+Download and install rake with the following.
+
+ gem install rake
+
+=== Normal Installation
+
+You can download the source tarball of the latest version of Rake from
+
+* http://rubyforge.org/project/showfiles.php?group_id=50
+
+Extract the tarball and run
+
+ % ruby install.rb
+
+from its distribution directory.
+
+== Usage
+
+=== Simple Example
+
+First, you must write a "Rakefile" file which contains the build rules. Here's
+a simple example:
+
+ task :default => [:test]
+
+ task :test do
+ ruby "test/unittest.rb"
+ end
+
+This Rakefile has two tasks:
+
+* 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.
+
+Running the "rake" command without any options will cause it to run the
+"default" task in the Rakefile:
+
+ % ls
+ Rakefile test/
+ % rake
+ (in /home/some_user/Projects/rake)
+ ruby test/unittest.rb
+ ....unit test output here...
+
+Type "rake --help" for all available options.
+
+
+=== More Information
+
+* For details on Rake's command-line invocation, read
+ doc/command_line_usage.rdoc[http://rake.rubyforge.org/files/doc/command_line_usage_rdoc.html]
+* For details on writing Rakefiles, see
+ doc/rakefile.rdoc[http://rake.rubyforge.org/files/doc/rakefile_rdoc.html].
+* For the original announcement of Rake, see
+ doc/rational.rdoc[http://rake.rubyforge.org/files/doc/rational_rdoc.html].
+* For a glossary of terms, see
+ doc/glossary.rdoc[http://rake.rubyforge.org/files/doc/glossary_rdoc.html].
+
+== 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 '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
+
+Bugs, features requests and other issues can be logged at
+
+* http://onestepback.org/redmine/projects/show/rake
+
+You will need an account to before you can post issues. Register at
+http://onestepback.org/redmine/account/register. Or you can send me
+an email (at jim dot weirich at gmail dot com)
+
+== Online Resources
+
+=== Rake References
+
+* Rake Documentation Home: http://docs.rubyrake.org
+* Rake Project Page: http://rubyforge.org/projects/rake
+* Rake API Documents: http://rake.rubyforge.org
+* Rake Source Code Repo: http://github.com/jimweirich/rake
+* Rake Git Repo Clone URL: git://github.com/jimweirich/rake.git
+
+=== Presentations and Articles about Rake
+
+* Jim Weirich's 2003 RubyConf presentation: http://onestepback.org/articles/buildingwithrake/
+* Martin Fowler's article on Rake: http://martinfowler.com/articles/rake.html
+
+== Other Make Reinvisionings ...
+
+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
+ 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://make.rubyforge.org -- Rant, another Ruby make tool.
+
+== Credits
+
+[<b>Ryan Dlugosz</b>] For the initial conversation that sparked Rake.
+
+[<b>nobu.nokada at softhome.net</b>] For the initial patch for rule support.
+
+[<b>Tilman Sauerbeck <tilman at code-monkey.de></b>] For the recursive rule patch.
+
+== License
+
+Rake is available under an MIT-style license.
+
+:include: MIT-LICENSE
+
+== Support
+
+The Rake homepage is http://rake.rubyforge.org. You can find the Rake
+RubyForge page at http://rubyforge.org/projects/rake.
+
+Feel free to submit commits or feature requests. If you send a patch,
+remember to update the corresponding unit tests. If 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 <jim.weirich at gmail.com>
+Requires:: Ruby 1.8.0 or later
+License:: Copyright 2003-2008 by Jim Weirich.
+ Released under an MIT-style license. See the 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.
Added: MacRuby/trunk/test/libs/rake/Rakefile
===================================================================
--- MacRuby/trunk/test/libs/rake/Rakefile (rev 0)
+++ MacRuby/trunk/test/libs/rake/Rakefile 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,421 @@
+# Rakefile for rake -*- ruby -*-
+
+# Copyright 2003, 2004, 2005 by Jim Weirich (jim at weirichhouse.org)
+# All rights reserved.
+
+# This file may be distributed under an MIT style license. See
+# MIT-LICENSE for details.
+
+begin
+ require 'rubygems'
+ require 'rake/gempackagetask'
+rescue Exception
+ nil
+end
+require 'rake/clean'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+CLEAN.include('**/*.o', '*.dot', '**/*.rbc')
+CLOBBER.include('doc/example/main', 'testdata')
+CLOBBER.include('test/data/**/temp_*')
+CLOBBER.include('test/data/chains/play.*')
+CLOBBER.include('test/data/file_creation_task/build')
+CLOBBER.include('test/data/file_creation_task/src')
+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-9.]+)$/
+ 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:all"
+
+# Test Tasks ---------------------------------------------------------
+
+# Common Abbreviations ...
+
+task :ta => "test:all"
+task :tf => "test:functional"
+task :tu => "test:units"
+task :tc => "test:contribs"
+task :test => "test:units"
+
+namespace :test do
+ Rake::TestTask.new(:all) do |t|
+ t.test_files = FileList[
+ 'test/lib/*_test.rb',
+ 'test/contrib/*_test.rb',
+ 'test/functional/*_test.rb'
+ ]
+ t.warning = true
+ t.verbose = false
+ end
+
+ Rake::TestTask.new(:units) do |t|
+ t.test_files = FileList['test/lib/*_test.rb']
+ t.warning = true
+ t.verbose = false
+ end
+
+ Rake::TestTask.new(:functional) do |t|
+ t.test_files = FileList['test/functional/*_test.rb']
+ t.warning = true
+ t.verbose = false
+ end
+
+ Rake::TestTask.new(:contribs) do |t|
+ t.test_files = FileList['test/contrib/test*.rb']
+ t.warning = true
+ t.verbose = false
+ end
+end
+
+begin
+ require 'rcov/rcovtask'
+
+ Rcov::RcovTask.new do |t|
+ t.libs << "test"
+ dot_rakes =
+ t.rcov_opts = [
+ '-xRakefile', '-xrakefile', '-xpublish.rf',
+ '-xlib/rake/contrib', '-x/Library',
+ '--text-report',
+ '--sort coverage'
+ ] + FileList['rakelib/*.rake'].pathmap("-x%p")
+ t.test_files = FileList[
+ 'test/lib/*_test.rb',
+ 'test/contrib/*_test.rb',
+ 'test/functional/*_test.rb'
+ ]
+ t.output_dir = 'coverage'
+ t.verbose = true
+ end
+rescue LoadError
+ puts "RCov is not available"
+end
+
+directory 'testdata'
+["test:all", :test_units, :test_contribs, :test_functional].each do |t|
+ task t => ['testdata']
+end
+
+# CVS Tasks ----------------------------------------------------------
+
+# Install rake using the standard install.rb script.
+
+desc "Install the application"
+task :install do
+ ruby "install.rb"
+end
+
+# Create a task to build the RDOC documentation tree.
+
+begin
+ require 'darkfish-rdoc'
+ DARKFISH_ENABLED = true
+rescue LoadError => ex
+ DARKFISH_ENABLED = false
+end
+
+BASE_RDOC_OPTIONS = [
+ '--line-numbers', '--inline-source',
+ '--main' , 'README.rdoc',
+ '--title', 'Rake -- Ruby Make'
+]
+
+rd = Rake::RDocTask.new("rdoc") do |rdoc|
+ rdoc.rdoc_dir = 'html'
+ rdoc.template = 'doc/jamis.rb'
+ rdoc.title = "Rake -- Ruby Make"
+ rdoc.options = BASE_RDOC_OPTIONS.dup
+ rdoc.options << '-SHN' << '-f' << 'darkfish' if DARKFISH_ENABLED
+
+ 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
+
+# ====================================================================
+# Create a task that will package the Rake software into distributable
+# tar, zip and gem files.
+
+PKG_FILES = FileList[
+ 'install.rb',
+ '[A-Z]*',
+ 'bin/**/*',
+ 'lib/**/*.rb',
+ 'test/**/*.rb',
+ 'test/**/*.rf',
+ 'test/**/*.mf',
+ 'test/**/Rakefile',
+ 'test/**/subdir',
+ '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|
+
+ #### Basic information.
+
+ s.name = 'rake'
+ s.version = $package_version
+ s.summary = "Ruby based make-like utility."
+ s.description = <<-EOF
+ Rake is a Make-like program implemented in Ruby. Tasks
+ and dependencies are specified in standard Ruby syntax.
+ EOF
+
+ #### Dependencies and requirements.
+
+ #s.add_dependency('log4r', '> 1.0.4')
+ #s.requirements << ""
+
+ #### Which files are to be included in this gem? Everything! (Except CVS directories.)
+
+ s.files = PKG_FILES.to_a
+
+ #### C code extensions.
+
+ #s.extensions << "ext/rmagic/extconf.rb"
+
+ #### Load-time details: library and application (you will need one or both).
+
+ s.require_path = 'lib' # Use these for libraries.
+
+ s.bindir = "bin" # Use these for applications.
+ s.executables = ["rake"]
+ s.default_executable = "rake"
+
+ #### Documentation and testing.
+
+ s.has_rdoc = true
+ s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
+ s.rdoc_options = BASE_RDOC_OPTIONS
+
+ #### Author and project details.
+
+ s.author = "Jim Weirich"
+ s.email = "jim at weirichhouse.org"
+ s.homepage = "http://rake.rubyforge.org"
+ s.rubyforge_project = "rake"
+# if ENV['CERT_DIR']
+# s.signing_key = File.join(ENV['CERT_DIR'], 'gem-private_key.pem')
+# s.cert_chain = [File.join(ENV['CERT_DIR'], 'gem-public_cert.pem')]
+# end
+ end
+
+ package_task = Rake::GemPackageTask.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]
+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,
+ :needs => [
+ :prerelease,
+ :clobber,
+ "test:all",
+ :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,
+ :needs => [: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,
+ :needs => [: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
+
+desc "Install the jamis RDoc template"
+task :install_jamis_template do
+ require 'rbconfig'
+ dest_dir = File.join(Config::CONFIG['rubylibdir'], "rdoc/generators/template/html")
+ fail "Unabled to write to #{dest_dir}" unless File.writable?(dest_dir)
+ install "doc/jamis.rb", dest_dir, :verbose => true
+end
+
+# Require experimental XForge/Metaproject support.
+
+load 'xforge.rf' if File.exist?('xforge.rf')
+
+desc "Where is the current directory. This task displays\nthe current rake directory"
+task :where_am_i do
+ puts Rake.original_dir
+end
+
+task :failure => :really_fail
+task :really_fail do
+ fail "oops"
+end
Added: MacRuby/trunk/test/libs/rake/TODO
===================================================================
--- MacRuby/trunk/test/libs/rake/TODO (rev 0)
+++ MacRuby/trunk/test/libs/rake/TODO 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,20 @@
+= Rake Project -- To Do List
+
+Send suggestions for this list to mailto:jim at weirichhouse.org or on
+the rake-devel at 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 absense 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)
Added: MacRuby/trunk/test/libs/rake/bin/rake
===================================================================
--- MacRuby/trunk/test/libs/rake/bin/rake (rev 0)
+++ MacRuby/trunk/test/libs/rake/bin/rake 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,31 @@
+#!/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.
+#++
+
+begin
+ require 'rake'
+rescue LoadError
+ require 'rubygems'
+ require 'rake'
+end
+Rake.application.run
Property changes on: MacRuby/trunk/test/libs/rake/bin/rake
___________________________________________________________________
Added: svn:executable
+ *
Added: MacRuby/trunk/test/libs/rake/doc/command_line_usage.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/command_line_usage.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/command_line_usage.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,102 @@
+= Rake Command Line Usage
+
+Rake is invoked from the command line using:
+
+ % rake [<em>options</em> ...] [<em>VAR</em>=<em>VALUE</em>] [<em>targets</em> ...]
+
+Options are:
+
+[<tt><em>name</em>=<em>value</em></tt>]
+ Set the environment variable <em>name</em> to <em>value</em>
+ during the execution of the <b>rake</b> command. You can access
+ the value by using ENV['<em>name</em>'].
+
+[<tt>--classic-namespace</tt> (-n)]
+ Import the Task, FileTask, and FileCreateTask into the top-level
+ scope to be compatible with older versions of Rake. Alternatively
+ you can include the line <code>require
+ 'rake/classic_namespace'</code> in your Rakefile to get the
+ classic behavior.
+
+[<tt>--describe</tt> _pattern_ (-D)]
+ Describe the tasks (matching optional PATTERN), then exit.
+
+[<tt>--dry-run</tt> (-n)]
+ Do a dry run. Print the tasks invoked and executed, but do not
+ actually execute any of the actions.
+
+[<tt>--execute</tt> _code_ (-e)]
+ Execute some Ruby code and exit.
+
+[<tt>--execute-print</tt> _code_ (-p)]
+ Execute some Ruby code, print the result, and exit.
+
+[<tt>--execute-continue</tt> _code_ (-p)]
+ Execute some Ruby code, then continue with normal task processing.
+
+[<tt>--help</tt> (-H)]
+ Display some help text and exit.
+
+[<tt>--libdir</tt> _directory_ (-I)]
+ Add _directory_ to the list of directories searched for require.
+
+[<tt>--nosearch</tt> (-N)]
+ Do not search for a Rakefile in parent directories.
+
+[<tt>--prereqs</tt> (-P)]
+ Display a list of all tasks and their immediate prerequisites.
+
+[<tt>--quiet</tt> (-q)]
+ Do not echo commands from FileUtils.
+
+[<tt>--rakefile</tt> _filename_ (-f)]
+ Use _filename_ as the name of the rakefile. The default rakefile
+ names are +rakefile+ and +Rakefile+ (with +rakefile+ taking
+ precedence). If the rakefile is not found in the current
+ directory, +rake+ will search parent directories for a match. The
+ directory where the Rakefile is found will become the current
+ directory for the actions executed in the Rakefile.
+
+[<tt>--rakelibdir</tt> _rakelibdir_ (-R)]
+ Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')
+
+[<tt>--require</tt> _name_ (-r)]
+ Require _name_ before executing the Rakefile.
+
+[<tt>--rules</tt>]
+ Trace the rules resolution.
+
+[<tt>--silent (-s)</tt>]
+ Like --quiet, but also suppresses the 'in directory' announcement.
+
+[<tt>--system</tt> (-g)]
+ Use the system wide (global) rakefiles. The project Rakefile is
+ ignored. By default, the system wide rakefiles are used only if no
+ project Rakefile is found. On Unix-like system, the system wide
+ rake files are located in $HOME/.rake. On a windows system they
+ are stored in $APPDATA/Rake.
+
+[<tt>--no-system</tt> (-G)]
+ Use the project level Rakefile, ignoring the system-wide (global)
+ rakefiles.
+
+[<tt>--tasks</tt> (-T)]
+ Display a list of the major tasks and their comments. Comments
+ are defined using the "desc" command.
+
+[<tt>--trace</tt> (-t)]
+ Turn on invoke/execute tracing. Also enable full backtrace on
+ errors.
+
+[<tt>--usage</tt> (-h)]
+ Display a usage message and exit.
+
+[<tt>--verbose</tt> (-v)]
+ Echo the Sys commands to standard output.
+
+[<tt>--version</tt> (-V)]
+ Display the program version and exit.
+
+In addition, any command line option of the form
+<em>VAR</em>=<em>VALUE</em> will be added to the environment hash
+<tt>ENV</tt> and may be tested in the Rakefile.
Added: MacRuby/trunk/test/libs/rake/doc/example/.cvsignore
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/example/.cvsignore (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/example/.cvsignore 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,2 @@
+*.o
+main
Added: MacRuby/trunk/test/libs/rake/doc/example/Rakefile1
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/example/Rakefile1 (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/example/Rakefile1 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,38 @@
+# Example Rakefile -*- ruby -*-
+
+task :default => [:main]
+
+file "a.o" => ["a.c"] do |t|
+ src = t.name.sub(/\.o$/, '.c')
+ sh "gcc #{src} -c -o #{t.name}"
+end
+
+file "b.o" => ["b.c"] do |t|
+ src = t.name.sub(/\.o$/, '.c')
+ sh "gcc #{src} -c -o #{t.name}"
+end
+
+file "main.o" => ["main.c"] do |t|
+ src = t.name.sub(/\.o$/, '.c')
+ sh "gcc #{src} -c -o #{t.name}"
+end
+
+OBJFILES = ["a.o", "b.o", "main.o"]
+task :obj => OBJFILES
+
+file "main" => OBJFILES do |t|
+ sh "gcc -o #{t.name} main.o a.o b.o"
+end
+
+task :clean do
+ rm_f FileList['*.o']
+ Dir['*~'].each { |fn| rm_f fn }
+end
+
+task :clobber => [:clean] do
+ rm_f "main"
+end
+
+task :run => ["main"] do
+ sh "./main"
+end
Added: MacRuby/trunk/test/libs/rake/doc/example/Rakefile2
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/example/Rakefile2 (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/example/Rakefile2 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,35 @@
+# Example Rakefile -*- ruby -*-
+# Using the power of Ruby
+
+task :default => [:main]
+
+def ext(fn, newext)
+ fn.sub(/\.[^.]+$/, newext)
+end
+
+SRCFILES = Dir['*.c']
+OBJFILES = SRCFILES.collect { |fn| ext(fn,".o") }
+
+OBJFILES.each do |objfile|
+ srcfile = ext(objfile, ".c")
+ file objfile => [srcfile] do |t|
+ sh "gcc #{srcfile} -c -o #{t.name}"
+ end
+end
+
+file "main" => OBJFILES do |t|
+ sh "gcc -o #{t.name} main.o a.o b.o"
+end
+
+task :clean do
+ rm_f FileList['*.o']
+ Dir['*~'].each { |fn| rm_f fn }
+end
+
+task :clobber => [:clean] do
+ rm_f "main"
+end
+
+task :run => ["main"] do
+ sh "./main"
+end
Added: MacRuby/trunk/test/libs/rake/doc/example/a.c
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/example/a.c (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/example/a.c 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+void a()
+{
+ printf ("In function a\n");
+}
Added: MacRuby/trunk/test/libs/rake/doc/example/b.c
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/example/b.c (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/example/b.c 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+void b()
+{
+ printf ("In function b\n");
+}
Added: MacRuby/trunk/test/libs/rake/doc/example/main.c
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/example/main.c (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/example/main.c 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+extern void a();
+extern void b();
+
+int main ()
+{
+ a();
+ b();
+ return 0;
+}
Added: MacRuby/trunk/test/libs/rake/doc/glossary.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/glossary.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/glossary.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,51 @@
+= Glossary
+
+[<b>action</b>]
+ 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.
+
+[<b>execute</b>]
+ When a task is executed, all of its actions are performed, in
+ the order they were defined. Note that unlike
+ <tt>invoke</tt>, <tt>execute</tt> always executes the actions
+ (without invoking or executing the prerequisites).
+
+[<b>file task</b> (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.
+
+[<b>invoke</b>]
+ 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
+ <tt>needed?</tt>. 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.
+
+[<b>prerequisites</b>]
+ Every task has a set (possiblity empty) of prerequisites. A
+ prerequisite P to Task T is itself a task that must be invoked
+ before Task T.
+
+[<b>rule</b>]
+ A rule is a recipe for synthesizing a task when no task is
+ explicitly defined. Rules generally synthesize file tasks.
+
+[<b>task</b> (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.
+
Added: MacRuby/trunk/test/libs/rake/doc/jamis.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/jamis.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/jamis.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,591 @@
+module RDoc
+module Page
+
+FONTS = "\"Bitstream Vera Sans\", Verdana, Arial, Helvetica, sans-serif"
+
+STYLE = <<CSS
+a {
+ color: #00F;
+ text-decoration: none;
+}
+
+a:hover {
+ color: #77F;
+ text-decoration: underline;
+}
+
+body, td, p {
+ font-family: %fonts%;
+ background: #FFF;
+ color: #000;
+ margin: 0px;
+ font-size: small;
+}
+
+#content {
+ margin: 2em;
+}
+
+#description p {
+ margin-bottom: 0.5em;
+}
+
+.sectiontitle {
+ margin-top: 1em;
+ margin-bottom: 1em;
+ padding: 0.5em;
+ padding-left: 2em;
+ background: #005;
+ color: #FFF;
+ font-weight: bold;
+ border: 1px dotted black;
+}
+
+.attr-rw {
+ padding-left: 1em;
+ padding-right: 1em;
+ text-align: center;
+ color: #055;
+}
+
+.attr-name {
+ font-weight: bold;
+}
+
+.attr-desc {
+}
+
+.attr-value {
+ font-family: monospace;
+}
+
+.file-title-prefix {
+ font-size: large;
+}
+
+.file-title {
+ font-size: large;
+ font-weight: bold;
+ background: #005;
+ color: #FFF;
+}
+
+.banner {
+ background: #005;
+ color: #FFF;
+ border: 1px solid black;
+ padding: 1em;
+}
+
+.banner td {
+ background: transparent;
+ color: #FFF;
+}
+
+h1 a, h2 a, .sectiontitle a, .banner a {
+ color: #FF0;
+}
+
+h1 a:hover, h2 a:hover, .sectiontitle a:hover, .banner a:hover {
+ color: #FF7;
+}
+
+.dyn-source {
+ display: none;
+ background: #FFE;
+ color: #000;
+ border: 1px dotted black;
+ margin: 0.5em 2em 0.5em 2em;
+ padding: 0.5em;
+}
+
+.dyn-source .cmt {
+ color: #00F;
+ font-style: italic;
+}
+
+.dyn-source .kw {
+ color: #070;
+ font-weight: bold;
+}
+
+.method {
+ margin-left: 1em;
+ margin-right: 1em;
+ margin-bottom: 1em;
+}
+
+.description pre {
+ padding: 0.5em;
+ border: 1px dotted black;
+ background: #FFE;
+}
+
+.method .title {
+ font-family: monospace;
+ font-size: large;
+ border-bottom: 1px dashed black;
+ margin-bottom: 0.3em;
+ padding-bottom: 0.1em;
+}
+
+.method .description, .method .sourcecode {
+ margin-left: 1em;
+}
+
+.description p, .sourcecode p {
+ margin-bottom: 0.5em;
+}
+
+.method .sourcecode p.source-link {
+ text-indent: 0em;
+ margin-top: 0.5em;
+}
+
+.method .aka {
+ margin-top: 0.3em;
+ margin-left: 1em;
+ font-style: italic;
+ text-indent: 2em;
+}
+
+h1 {
+ padding: 1em;
+ border: 1px solid black;
+ font-size: x-large;
+ font-weight: bold;
+ color: #FFF;
+ background: #007;
+}
+
+h2 {
+ padding: 0.5em 1em 0.5em 1em;
+ border: 1px solid black;
+ font-size: large;
+ font-weight: bold;
+ color: #FFF;
+ background: #009;
+}
+
+h3, h4, h5, h6 {
+ padding: 0.2em 1em 0.2em 1em;
+ border: 1px dashed black;
+ color: #000;
+ background: #AAF;
+}
+
+.sourcecode > pre {
+ padding: 0.5em;
+ border: 1px dotted black;
+ background: #FFE;
+}
+
+CSS
+
+XHTML_PREAMBLE = %{<?xml version="1.0" encoding="%charset%"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+}
+
+HEADER = XHTML_PREAMBLE + <<ENDHEADER
+<html>
+ <head>
+ <title>%title%</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=%charset%" />
+ <link rel="stylesheet" href="%style_url%" type="text/css" media="screen" />
+
+ <script language="JavaScript" type="text/javascript">
+ // <![CDATA[
+
+ function toggleSource( id )
+ {
+ var elem
+ var link
+
+ if( document.getElementById )
+ {
+ elem = document.getElementById( id )
+ link = document.getElementById( "l_" + id )
+ }
+ else if ( document.all )
+ {
+ elem = eval( "document.all." + id )
+ link = eval( "document.all.l_" + id )
+ }
+ else
+ return false;
+
+ if( elem.style.display == "block" )
+ {
+ elem.style.display = "none"
+ link.innerHTML = "show source"
+ }
+ else
+ {
+ elem.style.display = "block"
+ link.innerHTML = "hide source"
+ }
+ }
+
+ function openCode( url )
+ {
+ window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
+ }
+ // ]]>
+ </script>
+ </head>
+
+ <body>
+ENDHEADER
+
+FILE_PAGE = <<HTML
+<table border='0' cellpadding='0' cellspacing='0' width="100%" class='banner'>
+ <tr><td>
+ <table width="100%" border='0' cellpadding='0' cellspacing='0'><tr>
+ <td class="file-title" colspan="2"><span class="file-title-prefix">File</span><br />%short_name%</td>
+ <td align="right">
+ <table border='0' cellspacing="0" cellpadding="2">
+ <tr>
+ <td>Path:</td>
+ <td>%full_path%
+IF:cvsurl
+ (<a href="%cvsurl%">CVS</a>)
+ENDIF:cvsurl
+ </td>
+ </tr>
+ <tr>
+ <td>Modified:</td>
+ <td>%dtm_modified%</td>
+ </tr>
+ </table>
+ </td></tr>
+ </table>
+ </td></tr>
+</table><br>
+HTML
+
+###################################################################
+
+CLASS_PAGE = <<HTML
+<table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
+ <td class="file-title"><span class="file-title-prefix">%classmod%</span><br />%full_name%</td>
+ <td align="right">
+ <table cellspacing=0 cellpadding=2>
+ <tr valign="top">
+ <td>In:</td>
+ <td>
+START:infiles
+HREF:full_path_url:full_path:
+IF:cvsurl
+ (<a href="%cvsurl%">CVS</a>)
+ENDIF:cvsurl
+END:infiles
+ </td>
+ </tr>
+IF:parent
+ <tr>
+ <td>Parent:</td>
+ <td>
+IF:par_url
+ <a href="%par_url%">
+ENDIF:par_url
+%parent%
+IF:par_url
+ </a>
+ENDIF:par_url
+ </td>
+ </tr>
+ENDIF:parent
+ </table>
+ </td>
+ </tr>
+ </table>
+HTML
+
+###################################################################
+
+METHOD_LIST = <<HTML
+ <div id="content">
+IF:diagram
+ <table cellpadding='0' cellspacing='0' border='0' width="100%"><tr><td align="center">
+ %diagram%
+ </td></tr></table>
+ENDIF:diagram
+
+IF:description
+ <div class="description">%description%</div>
+ENDIF:description
+
+IF:requires
+ <div class="sectiontitle">Required Files</div>
+ <ul>
+START:requires
+ <li>HREF:aref:name:</li>
+END:requires
+ </ul>
+ENDIF:requires
+
+IF:toc
+ <div class="sectiontitle">Contents</div>
+ <ul>
+START:toc
+ <li><a href="#%href%">%secname%</a></li>
+END:toc
+ </ul>
+ENDIF:toc
+
+IF:methods
+ <div class="sectiontitle">Methods</div>
+ <ul>
+START:methods
+ <li>HREF:aref:name:</li>
+END:methods
+ </ul>
+ENDIF:methods
+
+IF:includes
+<div class="sectiontitle">Included Modules</div>
+<ul>
+START:includes
+ <li>HREF:aref:name:</li>
+END:includes
+</ul>
+ENDIF:includes
+
+START:sections
+IF:sectitle
+<div class="sectiontitle"><a nem="%secsequence%">%sectitle%</a></div>
+IF:seccomment
+<div class="description">
+%seccomment%
+</div>
+ENDIF:seccomment
+ENDIF:sectitle
+
+IF:classlist
+ <div class="sectiontitle">Classes and Modules</div>
+ %classlist%
+ENDIF:classlist
+
+IF:constants
+ <div class="sectiontitle">Constants</div>
+ <table border='0' cellpadding='5'>
+START:constants
+ <tr valign='top'>
+ <td class="attr-name">%name%</td>
+ <td>=</td>
+ <td class="attr-value">%value%</td>
+ </tr>
+IF:desc
+ <tr valign='top'>
+ <td> </td>
+ <td colspan="2" class="attr-desc">%desc%</td>
+ </tr>
+ENDIF:desc
+END:constants
+ </table>
+ENDIF:constants
+
+IF:attributes
+ <div class="sectiontitle">Attributes</div>
+ <table border='0' cellpadding='5'>
+START:attributes
+ <tr valign='top'>
+ <td class='attr-rw'>
+IF:rw
+[%rw%]
+ENDIF:rw
+ </td>
+ <td class='attr-name'>%name%</td>
+ <td class='attr-desc'>%a_desc%</td>
+ </tr>
+END:attributes
+ </table>
+ENDIF:attributes
+
+IF:method_list
+START:method_list
+IF:methods
+<div class="sectiontitle">%type% %category% methods</div>
+START:methods
+<div class="method">
+ <div class="title">
+IF:callseq
+ <a name="%aref%"></a><b>%callseq%</b>
+ENDIF:callseq
+IFNOT:callseq
+ <a name="%aref%"></a><b>%name%</b>%params%
+ENDIF:callseq
+IF:codeurl
+[ <a href="javascript:openCode('%codeurl%')">source</a> ]
+ENDIF:codeurl
+ </div>
+IF:m_desc
+ <div class="description">
+ %m_desc%
+ </div>
+ENDIF:m_desc
+IF:aka
+<div class="aka">
+ This method is also aliased as
+START:aka
+ <a href="%aref%">%name%</a>
+END:aka
+</div>
+ENDIF:aka
+IF:sourcecode
+<div class="sourcecode">
+ <p class="source-link">[ <a href="javascript:toggleSource('%aref%_source')" id="l_%aref%_source">show source</a> ]</p>
+ <div id="%aref%_source" class="dyn-source">
+<pre>
+%sourcecode%
+</pre>
+ </div>
+</div>
+ENDIF:sourcecode
+</div>
+END:methods
+ENDIF:methods
+END:method_list
+ENDIF:method_list
+END:sections
+</div>
+HTML
+
+FOOTER = <<ENDFOOTER
+ </body>
+</html>
+ENDFOOTER
+
+BODY = HEADER + <<ENDBODY
+ !INCLUDE! <!-- banner header -->
+
+ <div id="bodyContent">
+ #{METHOD_LIST}
+ </div>
+
+ #{FOOTER}
+ENDBODY
+
+########################## Source code ##########################
+
+SRC_PAGE = XHTML_PREAMBLE + <<HTML
+<html>
+<head><title>%title%</title>
+<meta http-equiv="Content-Type" content="text/html; charset=%charset%">
+<style>
+.ruby-comment { color: green; font-style: italic }
+.ruby-constant { color: #4433aa; font-weight: bold; }
+.ruby-identifier { color: #222222; }
+.ruby-ivar { color: #2233dd; }
+.ruby-keyword { color: #3333FF; font-weight: bold }
+.ruby-node { color: #777777; }
+.ruby-operator { color: #111111; }
+.ruby-regexp { color: #662222; }
+.ruby-value { color: #662222; font-style: italic }
+ .kw { color: #3333FF; font-weight: bold }
+ .cmt { color: green; font-style: italic }
+ .str { color: #662222; font-style: italic }
+ .re { color: #662222; }
+</style>
+</head>
+<body bgcolor="white">
+<pre>%code%</pre>
+</body>
+</html>
+HTML
+
+########################## Index ################################
+
+FR_INDEX_BODY = <<HTML
+!INCLUDE!
+HTML
+
+FILE_INDEX = XHTML_PREAMBLE + <<HTML
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=%charset%">
+<style>
+<!--
+ body {
+ background-color: #EEE;
+ font-family: #{FONTS};
+ color: #000;
+ margin: 0px;
+ }
+ .banner {
+ background: #005;
+ color: #FFF;
+ padding: 0.2em;
+ font-size: small;
+ font-weight: bold;
+ text-align: center;
+ }
+ .entries {
+ margin: 0.25em 1em 0 1em;
+ font-size: x-small;
+ }
+ a {
+ color: #00F;
+ text-decoration: none;
+ white-space: nowrap;
+ }
+ a:hover {
+ color: #77F;
+ text-decoration: underline;
+ }
+-->
+</style>
+<base target="docwin">
+</head>
+<body>
+<div class="banner">%list_title%</div>
+<div class="entries">
+START:entries
+<a href="%href%">%name%</a><br>
+END:entries
+</div>
+</body></html>
+HTML
+
+CLASS_INDEX = FILE_INDEX
+METHOD_INDEX = FILE_INDEX
+
+INDEX = XHTML_PREAMBLE + <<HTML
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>%title%</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=%charset%">
+</head>
+
+<frameset cols="20%,*">
+ <frameset rows="15%,35%,50%">
+ <frame src="fr_file_index.html" title="Files" name="Files" />
+ <frame src="fr_class_index.html" name="Classes" />
+ <frame src="fr_method_index.html" name="Methods" />
+ </frameset>
+IF:inline_source
+ <frame src="%initial_page%" name="docwin">
+ENDIF:inline_source
+IFNOT:inline_source
+ <frameset rows="80%,20%">
+ <frame src="%initial_page%" name="docwin">
+ <frame src="blank.html" name="source">
+ </frameset>
+ENDIF:inline_source
+ <noframes>
+ <body bgcolor="white">
+ Click <a href="html/index.html">here</a> for a non-frames
+ version of this page.
+ </body>
+ </noframes>
+</frameset>
+
+</html>
+HTML
+
+end
+end
+
+
Added: MacRuby/trunk/test/libs/rake/doc/proto_rake.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/proto_rake.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/proto_rake.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,127 @@
+= Original Prototype Rake
+
+This is the original 100 line prototype rake program.
+
+---
+ #!/usr/bin/env ruby
+
+ require 'ftools'
+
+ class Task
+ TASKS = Hash.new
+
+ attr_reader :prerequisites
+
+ def initialize(task_name)
+ @name = task_name
+ @prerequisites = []
+ @actions = []
+ end
+
+ def enhance(deps=nil, &block)
+ @prerequisites |= deps if deps
+ @actions << block if block_given?
+ self
+ end
+
+ def name
+ @name.to_s
+ end
+
+ def invoke
+ @prerequisites.each { |n| Task[n].invoke }
+ execute if needed?
+ end
+
+ def execute
+ return if @triggered
+ @triggered = true
+ @actions.collect { |act| result = act.call(self) }.last
+ end
+
+ def needed?
+ true
+ end
+
+ def timestamp
+ Time.now
+ end
+
+ class << self
+ def [](task_name)
+ TASKS[intern(task_name)] or fail "Don't know how to rake #{task_name}"
+ end
+
+ def define_task(args, &block)
+ case args
+ when Hash
+ fail "Too Many Target Names: #{args.keys.join(' ')}" if args.size > 1
+ fail "No Task Name Given" if args.size < 1
+ task_name = args.keys[0]
+ deps = args[task_name]
+ else
+ task_name = args
+ deps = []
+ end
+ deps = deps.collect {|d| intern(d) }
+ get(task_name).enhance(deps, &block)
+ end
+
+ def get(task_name)
+ name = intern(task_name)
+ TASKS[name] ||= self.new(name)
+ end
+
+ def intern(task_name)
+ (Symbol === task_name) ? task_name : task_name.intern
+ end
+ end
+ end
+
+ class FileTask < Task
+ def needed?
+ return true unless File.exist?(name)
+ latest_prereq = @prerequisites.collect{|n| Task[n].timestamp}.max
+ return false if latest_prereq.nil?
+ timestamp < latest_prereq
+ end
+
+ def timestamp
+ File.new(name.to_s).mtime
+ end
+ end
+
+ def task(args, &block)
+ Task.define_task(args, &block)
+ end
+
+ def file(args, &block)
+ FileTask.define_task(args, &block)
+ end
+
+ def sys(cmd)
+ puts cmd
+ system(cmd) or fail "Command Failed: [#{cmd}]"
+ end
+
+ def rake
+ begin
+ here = Dir.pwd
+ while ! File.exist?("Rakefile")
+ Dir.chdir("..")
+ fail "No Rakefile found" if Dir.pwd == here
+ here = Dir.pwd
+ end
+ puts "(in #{Dir.pwd})"
+ load "./Rakefile"
+ ARGV.push("default") if ARGV.size == 0
+ ARGV.each { |task_name| Task[task_name].invoke }
+ rescue Exception => ex
+ puts "rake aborted ... #{ex.message}"
+ puts ex.backtrace.find {|str| str =~ /Rakefile/ } || ""
+ end
+ end
+
+ if __FILE__ == $0 then
+ rake
+ end
Added: MacRuby/trunk/test/libs/rake/doc/rake.1.gz
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/rake.1.gz (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/rake.1.gz 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,13 @@
+\x8B\x8F\xE0Brake.1 \x9DV\xDBn\xDBF}\xE7W\xF2\xA9\x95\xE8\xB8@\x91\xC2H\xDC8\xB1\xAB\xF5E\x90\xE46A݇%947\xA6v\x99\xBDXa\xBF\xBEg\x97\xA4,y(j\xB6\xBC3{f\xE6̙Y\xA7w/\xE8?}]p;\xA1\xD9\xD5ه\xD5 M\x98\x922\xBA,ç$\xC4Gi\xAC\xA3F\xB1a\xC7fB\xD7gW\xB3 \xD9J\xFB\xBA\xA0\x8CI\xD45墱\xD1{ŹVž\xFBj\xF6a=\xBF\xB9q<\xFDeB\xD1\xE2\xE3\xF6\x88\xAC\xCF,\xE7Nj\xB4\xAB\xD8<X&\xC6\xD0[.N\xC82\xE3\xA6\xBD
O\xE2\xEF\xE3q\x92\xAE/hy\xF6\xFB\x8C\x8E\xE9\xC5GΌ\xA6\xA5\xE3\xD7\xFA\xE9ի\x9F_D\xCCE\xCD\xC2\xA5\xF8\xE2Q\x8B\xAB\xA4\xA5B8D\xAFX\xF1#\xC2~\x94V\xAA{\xD8"~#\xEE9
+W\xBB\xA2\xF4\x86)\x92\xB2\xB9\xD1vB\xA5wJ6\xACr>\x89N\xA9\xAABiEV3Um\x83 bWZZ\xB5\x83\x8E\xBF\xEB!
+\xAA;\x8F\x9AKG!_Y\xB6;[\xD6\xD9\xFAcr\x9A2\xF0\xD5\xF9
+\xF0n\xE4}吥\xB9\x97\xCA\xF6i\x95\x87i\x95\xB2\xAEQkg.\xE5AJϬ\x99\xAC\xC0c\xE3&\xA6̰x\xE8
lCo\xD4鞃\xFA\xF1\x98xӸ6\xBAv9\xB6zR\xA7\xB6\xE1\\x962\xDFQ\xF9\xD4\xD1$]]Du%F<0\xDDM\xC9\xCAM\x83\x942/!\x9C\xC6\xE8{\x88"
\xCAZ\x98P\xFC~\xF1\xD6\xEA\xF3\xF5\xCDb5_%\xE9{2\xF1p9\xA7\xBFH7\x81YK'\xA8$:\x9E\xCFV\x96\xF3EP\xE4\xE0K\x95\xB0\xB1\xEF\xA5**(Y8o؞$\xC9\xB4\x84HaK\xA3\xE0\xFE\xD2c\x81K\xBA\xA4\xAB\xC18\x8E:\xCDuH\xD8q\xDDR\x81s\xC5xI\x88\xACCw\x84)h鳖l\xAB\x9C\xF8\x96]k\xFAtuI
:\xEA\xE1B\xBA\xEE\xF8\xAB\x97\xE6\xA1\xDD\xC1\x88x)xm\xB5\x81\xC2E\xA6\xBD\xA3\x91\xB9t\x9F\x9C\xC8D\xB2\x8D\xC8\xF9\xD7q\xC8\xFDֆ ʅ\xA2\x8EwHF\xD8K[ \xD54\xFAE +
\xDBt(\xF3\xD84\xDA8Kƃ\xFBF8L\xA1\x8A\xE9\xD94Y\xF9S\xE8\x8B̥\xEB\xE0\x9E\xEE"\x9B:Hp\xCB\xE1'J\x99\xBB
\x93\xF59#3\xEF\xC0I\xDF\xBA\xD1_0\xFDs|\x872\xC1\xA7B\xC6\xF5\xC5`\x8D5\xDC0D\xEEp;WhR\xDAQ\xAC\xEC'@D"B\x91\x8B\xF1\xE0\xEF0\xECP\x82u\xBC \xA7\x8BE\xE7\x9A?\x91\x8F4a#\x85k\xDD5\xAAuq"b\xB6A w\xE5\xFB7[\xC4+\xE3\xF4\xAE\\x84\x91\x8Bw\xE5\xFC\xB9\x81-6"\xA8DbaCD\xF6\xA4z\xD4\xD3\xD0r\x89Ł\x95\xC8P\xE6\x83\x88\xC95a>B at i\xD4\xEBM\x94*t\xBD^$\xD3iaک\xF1jy\x8F\xA6j\x9C\x9Ck\xB4
F
+Ɛn\x90\xE3ܻ g\xB7+\x8A\xEEP*\xAE\x9B\x83'`4\xBD \x8A\xB4M
+\xE2~\x8CN\xB6\xB6ۄ\xF1b-\xB3B\x9A\xB7\x97\xF3\xF7\xE7\xF3\xE5pq>N\xE6*\xAF=J\xEB
+RE\xB6,\x93WA at U\xBF/c\x97
+\@Y\xBBt\x94\xEE=\xF7ӹ\x8EE\x85\xE6\xEE`\xB0k! \xE4N Nh4\xE8 \xD8\xE9\xDA>\xAFo\xB1_\xF7c:Љ
+]\xE4$\xD8\x98\xC3\xF6`\xC8\xB29 \xEB\xEB.\xBBZ\xDF,u#2::\xD0\xF8
\x8A\xE9S|\xFBq~9P\xCAq\x82\xF9\xA4xԯ sPJ\xCF\xD9۫\x9B\xF3\xDB\xFE\xE2hj\xC6ɲW|\x9EqD\xFB\xD4\xF1C
\x8B\xCF\xCA
Ta\xC7ɥĨ\xF4EN\xB0g\xB1Gj\xAB\xE3
+\x80-wY\xBDDG\xE2ۗ`MiUo 9\xE8\xF8<\xB0\xFE\x9F\x9C;\xC6\xE3 ̍\x93\xB57*\xCCr\x98\xA4>\xEA\xCA.\xDCQ\xF4d\xF7\x82y\xFCG\x92\x89\xFC!\xE2\xA0>\xF4\xE8\xB4z\xCA\xD0\xEF+
s\x9CA\x96ϝ\xC1\xD7S\xBB\xBF\xD3ma\xE9_\xBB\xF1
N|)\x9E\xE1\xFC\xF1\x9C\x96\xE1]\xEB}\xC3j
+/\xDAlFg\x97\xAB\x9B\xE4\xB3\xF6q\x85\xE25)v\xEF˰\xFEr\x9A\xFFM\x8A\xE9;\xF2\xD6
\xD9
+\xE3r\xFB\x91\x9Eȳ\xDB\xF5\xC5Ͳ{Z\xB7\x90\xDB\xD6Hlv\xAC\xE6\x96~\x93\x{24E5458}\xB37_\xE4\xE6ݶ\xFBk\xC4r\xAA\xCD\xFD)\xC5u\xB9\x8Bo\xB5u\x84\xC8u\xD3Na\xC3Jw\xEB5,\xF4\xD2\xE8\xCDN\xCB)\x86XBI\xBA\xD2a\xE8-\x82\xE1\xAFw\xF215\xFA4\xC6\xF96\xF3\xCA\xF9\xE1a\xA0QPe\xBF\x9A\x91N@\xE2\xD3a\xC1\xF2\xBF\xDF\xC8H\xF4\xE4
+
\ No newline at end of file
Added: MacRuby/trunk/test/libs/rake/doc/rakefile.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/rakefile.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/rakefile.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,566 @@
+= Rakefile Format (as of version 0.8.7)
+
+First of all, there is no special format for a Rakefile. A Rakefile
+contains executable Ruby code. Anything legal in a ruby script is
+allowed in a Rakefile.
+
+Now that we understand there is no special syntax in a Rakefile, there
+are some conventions that are used in a Rakefile that are a little
+unusual in a typical Ruby program. Since a Rakefile is tailored to
+specifying tasks and actions, the idioms used in a Rakefile are
+designed to support that.
+
+So, what goes into a Rakefile?
+
+== Tasks
+
+Tasks are the main unit of work in a Rakefile. Tasks have a name
+(usually given as a symbol or a string), a list of prerequisites (more
+symbols or strings) and a list of actions (given as a block).
+
+=== Simple Tasks
+
+A task is declared by using the +task+ method. +task+ takes a single
+parameter that is the name of the task.
+
+ task :name
+
+=== Tasks with Prerequisites
+
+Any prerequisites are given as a list (inclosed in square brackets)
+following the name and an arrow (=>).
+
+ task :name => [:prereq1, :prereq2]
+
+<b>NOTE:</b> 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 ...
+
+ hash = Hash.new
+ hash[:name] = [:prereq1, :prereq2]
+ task(hash)
+
+=== 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 paramter..
+
+ task :name => [:prereq1, :prereq2] do |t|
+ # actions (may reference t)
+ end
+
+=== Multiple Definitions
+
+A task may be specified more than once. Each specification adds its
+prerequisites and actions to the existing definition. This allows one
+part of a rakefile to specify the actions and a different rakefile
+(perhaps separately generated) to specify the dependencies.
+
+For example, the following is equivalent to the single task
+specification given above.
+
+ task :name
+ task :name => [:prereq1]
+ task :name => [:prereq2]
+ task :name do |t|
+ # actions
+ end
+
+== File Tasks
+
+Some tasks are designed to create a file from one or more other files.
+Tasks that generate these files may be skipped if the file already
+exists. File tasks are used to specify file creation tasks.
+
+File tasks are declared using the +file+ method (instead of the +task+
+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 name <tt>a.o</tt> and <tt>b.o</tt>. The tasks
+for creating <tt>a.o</tt> and <tt>b.o</tt> are not shown.
+
+ file "prog" => ["a.o", "b.o"] do |t|
+ sh "cc -o #{t.name} #{t.prerequisites.join(' ')}"
+ end
+
+== Directory Tasks
+
+It is common to need to create directories upon demand. The
++directory+ convenience method is a short-hand for creating a FileTask
+that creates the directory. For example, the following declaration
+...
+
+ directory "testdata/examples/doc"
+
+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
+
+The +directory+ method does not accept prerequisites or actions, but
+both prerequisites and actions can be added later. For example ...
+
+ directory "testdata"
+ file "testdata" => ["otherdata"]
+ file "testdata" do
+ cp Dir["standard_data/*.data"], "testdata"
+ end
+
+== Tasks with Parallel Prerequisites
+
+Rake allows parallel execution of prerequisites using the following syntax:
+
+ multitask :copy_files => [:copy_src, :copy_doc, :copy_bin] do
+ puts "All Copies Complete"
+ end
+
+In this example, +copy_files+ is a normal rake task. Its actions are
+executed whereever all of its prerequisites are done. The big
+difference is that the prerequisites (+copy_src+, +copy_bin+ and
++copy_doc+) are executed in parallel. Each of the prerequisites are
+run in their own Ruby thread, possibly allowing faster overall runtime.
+
+=== Secondary Prerequisites
+
+If any of the primary prerequites of a multitask have common secondary
+prerequisites, all of the primary/parallel prerequisites will wait
+until the common prerequisites have been run.
+
+For example, if the <tt>copy_<em>xxx</em></tt> tasks have the
+following prerequisites:
+
+ 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+,
+and +copy_doc+ are all run in parallel. Note that +prep_for_copy+ is
+run only once, even though it is referenced in multiple threads.
+
+=== Thread Safety
+
+The Rake internal data structures are thread-safe with respect
+to the multitask parallel execution, so there is no need for the user
+to do extra synchronization for Rake's benefit. However, if there are
+user data structures shared between the parallel prerequisites, the
+user must do whatever is necessary to prevent race conditions.
+
+== Tasks with Arguments
+
+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 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 rake release
+
+will work. Environment variable names must either match the task
+parameter exactly, or match an all uppcase version of the task
+parameter.
+
+=== 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 in an array (: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
+picked up from matching environment variables. If there are no
+matching environment variables, they are given the nil value.
+
+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
+where we specify default values for the first and last names:
+
+ task :name, [:first_name, :last_name] do |t, args|
+ args.with_defaults(:first_name => "John", :last_name => "Dough")
+ puts "First name is #{args.first_name}"
+ puts "Last name is #{args.last_name}"
+ end
+
+=== Tasks that Expect Parameters and Have Prerequisites
+
+Tasks that use parameters have a slightly different format for
+prerequisites. Use the arrow notation to indicate the prerequisites
+for tasks with arguments. For example:
+
+ task :name, [:first_name, :last_name] => [:pre_name] do |t, args|
+ args.with_defaults(:first_name => "John", :last_name => "Dough")
+ puts "First name is #{args.first_name}"
+ puts "Last name is #{args.last_name}"
+ end
+
+=== Deprecated Task Parameters Format
+
+There is an older format for declaring task parameters that omitted
+the task argument array and used the :needs keyword to introduce the
+dependencies. That format is still supported for compatibility, but
+is not recommended for use. The older format may be dropped in future
+versions of rake.
+
+== Accessing Task Programatically
+
+Sometimes it is useful to manipulate tasks programatically in a
+Rakefile. To find a task object, use the <tt>:[]</tt> operator on the
+<tt>Rake::Task</tt>.
+
+=== Programmatic Task Example
+
+For example, the following Rakefile defines two tasks. The :doit task
+simply prints a simple "DONE" message. The :dont class will lookup
+the doit class and remove (clear) all of its prerequisites and
+actions.
+
+ task :doit do
+ puts "DONE"
+ end
+
+ task :dont do
+ Rake::Task[:doit].clear
+ end
+
+Running this example:
+
+ $ rake doit
+ (in /Users/jim/working/git/rake/x)
+ DONE
+ $ rake dont doit
+ (in /Users/jim/working/git/rake/x)
+ $
+
+The ability to programmatically manipulate tasks gives rake very
+powerful meta-programming capabilities w.r.t. task execution, but
+should be used with cation.
+
+== Rules
+
+When a file is named as a prerequisite, but does not have a file task
+defined for it, Rake will attempt to synthesize a task by looking at a
+list of rules supplied in the Rakefile.
+
+Suppose we were trying to invoke task "mycode.o", but no task is
+defined for it. But the rakefile has a rule that look like this ...
+
+ rule '.o' => ['.c'] do |t|
+ sh "cc #{t.source} -c -o #{t.name}"
+ end
+
+This rule will synthesize any task that ends in ".o". It has a
+prerequisite a source file with an extension of ".c" must exist. If
+Rake is able to find a file named "mycode.c", it will automatically
+create a task that builds "mycode.o" from "mycode.c".
+
+If the file "mycode.c" does not exist, rake will attempt
+to recursively synthesize a rule for it.
+
+When a task is synthesized from a rule, the +source+ attribute of the
+task is set to the matching source file. This allows us to write
+rules with actions that reference the source file.
+
+=== Advanced Rules
+
+Any regular expression may be used as the rule pattern. Additionally,
+a proc may be used to calculate the name of the source file. This
+allows for complex patterns and sources.
+
+The following rule is equivalent to the example above.
+
+ rule( /\.o$/ => [
+ proc {|task_name| task_name.sub(/\.[^.]+$/, '.c') }
+ ]) do |t|
+ sh "cc #{t.source} -c -o #{t.name}"
+ end
+
+<b>NOTE:</b> 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 ...
+
+ rule '.java' => [
+ proc { |tn| tn.sub(/\.class$/, '.java').sub(/^classes\//, 'src/') }
+ ] do |t|
+ java_compile(t.source, t.name)
+ end
+
+<b>NOTE:</b> +java_compile+ is a hypothetical method that invokes the
+java compiler.
+
+== Importing Dependencies
+
+Any ruby file (including other rakefiles) can be included with a
+standard Ruby +require+ command. The rules and declarations in the
+required file are just added to the definitions already accumulated.
+
+Because the files are loaded _before_ the rake targets are evaluated,
+the loaded files must be "ready to go" when the rake command is
+invoked. This make generated dependency files difficult to use. By
+the time rake gets around to updating the dependencies file, it is too
+late to load it.
+
+The +import+ command addresses this by specifying a file to be loaded
+_after_ the main rakefile is loaded, but _before_ any targets on the
+command line are specified. In addition, if the file name matches an
+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:
+
+ require 'rake/loaders/makefile'
+
+ file ".depends.mf" => [SRC_LIST] do |t|
+ sh "makedepend -f- -- #{CFLAGS} -- #{t.prerequisites} > #{t.name}"
+ end
+
+ import ".depends.mf"
+
+If ".depends" does not exist, or is out of date w.r.t. the source
+files, a new ".depends" file is generated using +makedepend+ before
+loading.
+
+== Comments
+
+Standard Ruby comments (beginning with "#") can be used anywhere it is
+legal in Ruby source code, including comments for tasks and rules.
+A single-line comment immediately before a task (with no blank line
+between it and the task) will be used as that task's description, and
+the task and description will appear in the list displayed
+using the "-T" switch.
+
+=== Example:
+
+ # Create a distribution package
+ task :package => [ ... ] do ... end
+
+You can also use the +desc+ command before a task to set the
+description for the task. In this case, intervening blank lines
+are allowed
+
+=== Example:
+
+ desc 'Create a distribution package'
+
+ task :package => [ ... ] do ... end
+
+The +desc+ comment takes priority over the comment for of description.
+
+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
+comments or +desc+ to describe your major tasks, you have a
+semi-automatic way of generating a summary of your Rake file.
+
+ traken$ rake -T
+ (in /home/.../rake)
+ rake clean # Remove any temporary products.
+ rake clobber # Remove any generated file.
+ rake clobber_rdoc # Remove rdoc products
+ rake contrib_test # Run tests for contrib_test
+ rake default # Default Task
+ rake install # Install the application
+ rake lines # Count lines in the main rake file
+ rake rdoc # Build the rdoc HTML Files
+ rake rerdoc # Force a rebuild of the RDOC files
+ rake test # Run tests
+ rake testall # Run all test targets
+
+Only tasks with descriptions will be displayed with the "-T" switch.
+Use "-P" (or "--prereqs") to get a list of all tasks and their
+prerequisites.
+
+== Namespaces
+
+As projects grow (and along with it, the number of tasks), it is
+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 interfer with
+each other.
+
+For example:
+
+ namespace "main"
+ task :build do
+ # Build the main program
+ end
+ end
+
+ namespace "samples" do
+ task :build do
+ # Build the sample programs
+ end
+ end
+
+ task :build => ["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
+
+Note that the name given in the +task+ command is always the unadorned
+task name without any namespace prefixes. The +task+ command always
+defines a task in the current namespace.
+
+=== FileTasks
+
+File task names are not scoped by the namespace command. Since the
+name of a file task is the name of an actual file in the file system,
+it makes little sense to include file task names in name space.
+Directory tasks (created by the +directory+ command) are a type of
+file task and are also not affected by namespaces.
+
+=== Name Resolution
+
+When looking up a task name, rake will start with the current
+namespace and attempt to find the name there. If it fails to find a
+name in the current namespace, it will search the parent namespaces
+until a match is found (or an error occurs if there is no match).
+
+The "rake" namespace is a special implicit namespace that refers to
+the toplevel names.
+
+If a task name begins with a "^" character, the name resolution will
+start in the parent namespace. Multiple "^" characters are allowed.
+
+Here is an example file with multiple :run tasks and how various names
+resolve in different locations.
+
+ task :run
+
+ namespace "one" do
+ task :run
+
+ namespace "two" do
+ task :run
+
+ # :run => "one:two:run"
+ # "two:run" => "one:two:run"
+ # "one:two:run" => "one:two:run"
+ # "one:run" => "one:run"
+ # "^run" => "one:run"
+ # "^^run" => "rake:run" (the top level task)
+ # "rake:run" => "rake:run" (the top level task)
+ end
+
+ # :run => "one:run"
+ # "two:run" => "one:two:run"
+ # "^run" => "rake:run"
+ end
+
+ # :run => "rake:run"
+ # "one:run" => "one:run"
+ # "one:two:run" => "one:two:run"
+
+== FileLists
+
+FileLists are the way Rake manages lists of files. You can treat a
+FileList as an array of strings for the most part, but FileLists
+support some additional operations.
+
+=== Creating a FileList
+
+Creating a file list is easy. Just give it the list of file names:
+
+ fl = FileList['file1.rb', file2.rb']
+
+Or give it a glob pattern:
+
+ fl = FileList['*.rb']
+
+== Odds and Ends
+
+=== do/end verses { }
+
+Blocks may be specified with either a +do+/+end+ pair, or with curly
+braces in Ruby. We _strongly_ recommend using +do+/+end+ to specify the
+actions for tasks and rules. Because the rakefile idiom tends to
+leave off parenthesis on the task/file/rule methods, unusual
+ambiguities can arise when using curly braces.
+
+For example, suppose that the method +object_files+ returns a list of
+object files in a project. Now we use +object_files+ as the
+prerequistes in a rule specified with actions in curly braces.
+
+ # DON'T DO THIS!
+ file "prog" => object_files {
+ # Actions are expected here (but it doesn't work)!
+ }
+
+Because curly braces have a higher precedence than +do+/+end+, the
+block is associated with the +object_files+ method rather than the
++file+ method.
+
+This is the proper way to specify the task ...
+
+ # THIS IS FINE
+ file "prog" => object_files do
+ # Actions go here
+ end
+
+----
+
+== See
+
+* README.rdoc -- Main documentation for Rake.
Added: MacRuby/trunk/test/libs/rake/doc/rational.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/rational.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/rational.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,151 @@
+= Why rake?
+
+Ok, let me state from the beginning that I never intended to write this
+code. I'm not convinced it is useful, and I'm not convinced anyone
+would even be interested in it. All I can say is that Why's onion truck
+must by been passing through the Ohio valley.
+
+What am I talking about? ... A Ruby version of Make.
+
+See, I can sense you cringing already, and I agree. The world certainly
+doesn't need yet another reworking of the "make" program. I mean, we
+already have "ant". Isn't that enough?
+
+It started yesterday. I was helping a coworker fix a problem in one of
+the Makefiles we use in our project. Not a particularly tough problem,
+but during the course of the conversation I began lamenting some of the
+shortcomings of make. In particular, in one of my makefiles I wanted to
+determine the name of a file dynamically and had to resort to some
+simple scripting (in Ruby) to make it work. "Wouldn't it be nice if you
+could just use Ruby inside a Makefile" I said.
+
+My coworker (a recent convert to Ruby) agreed, but wondered what it
+would look like. So I sketched the following on the whiteboard...
+
+ "What if you could specify the make tasks in Ruby, like this ..."
+
+ task "build" do
+ java_compile(...args, etc ...)
+ end
+
+ "The task function would register "build" as a target to be made,
+ and the block would be the action executed whenever the build
+ system determined that it was time to do the build target."
+
+We agreed that would be cool, but writing make from scratch would be WAY
+too much work. And that was the end of that!
+
+... Except I couldn't get the thought out of my head. What exactly
+would be needed to make the about syntax work as a make file? Hmmm, you
+would need to register the tasks, you need some way of specifying
+dependencies between tasks, and some way of kicking off the process.
+Hey! What if we did ... and fifteen minutes later I had a working
+prototype of Ruby make, complete with dependencies and actions.
+
+I showed the code to my coworker and we had a good laugh. It was just
+about a page worth of code that reproduced an amazing amount of the
+functionality of make. We were both truely stunned with the power of
+Ruby.
+
+But it didn't do everything make did. In particular, it didn't have
+timestamp based file dependencies (where a file is rebuilt if any of its
+prerequisite files have a later timestamp). Obviously THAT would be a
+pain to add and so Ruby Make would remain an interesting experiment.
+
+... Except as I walked back to my desk, I started thinking about what
+file based dependecies would really need. Rats! I was hooked again,
+and by adding a new class and two new methods, file/timestamp
+dependencies were implemented.
+
+Ok, now I was really hooked. Last night (during CSI!) I massaged the
+code and cleaned it up a bit. The result is a bare-bones replacement
+for make in exactly 100 lines of code.
+
+For the curious, you can see it at ...
+* doc/proto_rake.rdoc
+
+Oh, about the name. When I wrote the example Ruby Make task on my
+whiteboard, my coworker exclaimed "Oh! I have the perfect name: Rake ...
+Get it? Ruby-Make. Rake!" He said he envisioned the tasks as leaves
+and Rake would clean them up ... or something like that. Anyways, the
+name stuck.
+
+Some quick examples ...
+
+A simple task to delete backup files ...
+
+ task :clean do
+ Dir['*~'].each {|fn| rm fn rescue nil}
+ end
+
+Note that task names are symbols (they are slightly easier to type
+than quoted strings ... but you may use quoted string if you would
+rather). Rake makes the methods of the FileUtils module directly
+available, so we take advantage of the <tt>rm</tt> command. Also note
+the use of "rescue nil" to trap and ignore errors in the <tt>rm</tt>
+command.
+
+To run it, just type "rake clean". Rake will automatically find a
+Rakefile in the current directory (or above!) and will invoke the
+targets named on the command line. If there are no targets explicitly
+named, rake will invoke the task "default".
+
+Here's another task with dependencies ...
+
+ task :clobber => [:clean] do
+ rm_r "tempdir"
+ end
+
+Task :clobber depends upon task :clean, so :clean will be run before
+:clobber is executed.
+
+Files are specified by using the "file" command. It is similar to the
+task command, except that the task name represents a file, and the task
+will be run only if the file doesn't exist, or if its modification time
+is earlier than any of its prerequisites.
+
+Here is a file based dependency that will compile "hello.cc" to
+"hello.o".
+
+ file "hello.cc"
+ file "hello.o" => ["hello.cc"] do |t|
+ srcfile = t.name.sub(/\.o$/, ".cc")
+ sh %{g++ #{srcfile} -c -o #{t.name}}
+ end
+
+I normally specify file tasks with string (rather than symbols). Some
+file names can't be represented by symbols. Plus it makes the
+distinction between them more clear to the casual reader.
+
+Currently writing a task for each and every file in the project would be
+tedious at best. I envision a set of libraries to make this job
+easier. For instance, perhaps something like this ...
+
+ require 'rake/ctools'
+ Dir['*.c'].each do |fn|
+ c_source_file(fn)
+ end
+
+where "c_source_file" will create all the tasks need to compile all the
+C source files in a directory. Any number of useful libraries could be
+created for rake.
+
+That's it. There's no documentation (other than whats in this
+message). Does this sound interesting to anyone? If so, I'll continue
+to clean it up and write it up and publish it on RAA. Otherwise, I'll
+leave it as an interesting excerise and a tribute to the power of Ruby.
+
+Why /might/ rake be interesting to Ruby programmers. I don't know,
+perhaps ...
+
+* No weird make syntax (only weird Ruby syntax :-)
+* No need to edit or read XML (a la ant)
+* Platform independent build scripts.
+* Will run anywhere Ruby exists, so no need to have "make" installed.
+ If you stay away from the "sys" command and use things like
+ 'ftools', you can have a perfectly platform independent
+ build script. Also rake is only 100 lines of code, so it can
+ easily be packaged along with the rest of your code.
+
+So ... Sorry for the long rambling message. Like I said, I never
+intended to write this code at all.
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.4.14.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.4.14.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.4.14.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,23 @@
+= 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
+
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.4.15.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.4.15.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.4.15.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,35 @@
+= 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
+
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.5.0.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.5.0.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.5.0.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,53 @@
+= 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
+
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.5.3.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.5.3.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.5.3.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,78 @@
+= 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
+
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.5.4.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.5.4.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.5.4.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,46 @@
+= 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
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.6.0.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.6.0.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.6.0.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,141 @@
+= 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 <tt>source</tt> method now returns the name of the first
+ prerequisite listed in the rule. <tt>sources</tt> 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 <tt>investigation</tt> 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 <tt>ruby</tt> 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 <tt>sh</tt> 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 <code>require 'rake/classic_namespace'</code> to the
+ Rakefile to get the old behavior.
+
+ <tt>rake</tt> 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 <tt>file</tt> 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
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.0.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.0.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.0.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,119 @@
+= 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
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.1.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.1.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.1.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,59 @@
+= 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
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.2.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.2.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.2.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,121 @@
+= 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
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.3.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.3.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.3.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,47 @@
+= 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
Property changes on: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.7.3.rdoc
___________________________________________________________________
Added: svn:executable
+ *
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.0.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.0.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.0.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,114 @@
+= 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
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.2.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.2.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.2.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,165 @@
+= 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\xFChle)
+
+* 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\xFChle
+* Ittay Dror
+* Bheeshmar Redheendran (for spending an afternoon with me debugging
+ windows issues)
+
+-- Jim Weirich
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.3.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.3.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.3.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,112 @@
+= 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\xFChle
+* Ittay Dror
+* Bheeshmar Redheendran (for spending an afternoon with me debugging
+ windows issues)
+
+-- Jim Weirich
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.4.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.4.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.4.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,147 @@
+= 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
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.5.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.5.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.5.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,53 @@
+= 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
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.6.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.6.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.6.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,55 @@
+= 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
Added: MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.7.rdoc
===================================================================
--- MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.7.rdoc (rev 0)
+++ MacRuby/trunk/test/libs/rake/doc/release_notes/rake-0.8.7.rdoc 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,55 @@
+= 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
Added: MacRuby/trunk/test/libs/rake/install.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/install.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/install.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,88 @@
+require 'rbconfig'
+require 'find'
+require 'ftools'
+
+include Config
+
+$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 to their stuff
+#
+
+def installBIN(from, opfile)
+
+ tmp_dir = nil
+ for t in [".", "/tmp", "c:/temp", $bindir]
+ stat = File.stat(t) rescue next
+ if stat.directory? and stat.writable?
+ tmp_dir = t
+ break
+ end
+ end
+
+ fail "Cannot find a temporary directory" unless tmp_dir
+ tmp_file = File.join(tmp_dir, "_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
+ File::install(tmp_file, File.join($bindir, opfile), 0755, true)
+ File::unlink(tmp_file)
+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
+
+bindir = CONFIG["bindir"]
+if (destdir = ENV['DESTDIR'])
+ $bindir = destdir + $bindir
+ $sitedir = destdir + $sitedir
+
+ File::makedirs($bindir)
+ File::makedirs($sitedir)
+end
+
+rake_dest = File.join($sitedir, "rake")
+File::makedirs(rake_dest, true)
+File::chmod(0755, rake_dest)
+
+# The library files
+
+files = Dir.chdir('lib') { Dir['**/*.rb'] }
+
+for fn in files
+ fn_dir = File.dirname(fn)
+ target_dir = File.join($sitedir, fn_dir)
+ if ! File.exist?(target_dir)
+ File.makedirs(target_dir)
+ end
+ File::install(File.join('lib', fn), File.join($sitedir, fn), 0644, true)
+end
+
+# and the executable
+
+installBIN("bin/rake", "rake")
Added: MacRuby/trunk/test/libs/rake/lib/rake/alt_system.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/alt_system.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/alt_system.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,108 @@
+#
+# 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 = Config::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)!
+
+ class << self
+ def define_module_function(name, &block)
+ define_method(name, &block)
+ module_function(name)
+ end
+ end
+
+ if WINDOWS and 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|
+ if File.exist?(test = "#{file}.#{ext}")
+ return test
+ end
+ }
+ 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
Added: MacRuby/trunk/test/libs/rake/lib/rake/application.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/application.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/application.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,579 @@
+require 'shellwords'
+require 'optparse'
+
+require 'rake/task_manager'
+require 'rake/win32'
+
+module Rake
+
+ ######################################################################
+ # Rake main application object. When invoking +rake+ from the
+ # command line, a Rake::Application object is created and run.
+ #
+ class Application
+ include TaskManager
+
+ # The name of the application (typically 'rake')
+ attr_reader :name
+
+ # The original directory where rake was invoked.
+ attr_reader :original_dir
+
+ # Name of the actual rakefile used.
+ attr_reader :rakefile
+
+ # List of the top level task names (task names from the command line).
+ attr_reader :top_level_tasks
+
+ DEFAULT_RAKEFILES = ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb'].freeze
+
+ # Initialize a Rake::Application object.
+ def initialize
+ super
+ @name = 'rake'
+ @rakefiles = DEFAULT_RAKEFILES.dup
+ @rakefile = nil
+ @pending_imports = []
+ @imported = []
+ @loaders = {}
+ @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)
+ @tty_output = STDOUT.tty?
+ end
+
+ # Run the Rake application. The run method performs the following
+ # three steps:
+ #
+ # * Initialize the command line options (+init+).
+ # * Define the tasks (+load_rakefile+).
+ # * Run the top level tasks (+run_tasks+).
+ #
+ # If you wish to build a custom rake command, you should call
+ # +init+ on your application. The define any tasks. Finally,
+ # call +top_level+ to run your top level tasks.
+ def run
+ standard_exception_handling do
+ init
+ load_rakefile
+ top_level
+ end
+ end
+
+ # Initialize the command line parameters and app name.
+ def init(app_name='rake')
+ standard_exception_handling do
+ @name = app_name
+ handle_options
+ collect_tasks
+ end
+ end
+
+ # Find the rakefile and then load it and any pending imports.
+ def load_rakefile
+ standard_exception_handling do
+ raw_load_rakefile
+ end
+ end
+
+ # Run the top level tasks of a Rake application.
+ def top_level
+ standard_exception_handling do
+ if options.show_tasks
+ display_tasks_and_comments
+ elsif options.show_prereqs
+ display_prerequisites
+ else
+ top_level_tasks.each { |task_name| invoke_task(task_name) }
+ end
+ end
+ end
+
+ # Add a loader to handle imported files ending in the extension
+ # +ext+.
+ def add_loader(ext, loader)
+ ext = ".#{ext}" unless ext =~ /^\./
+ @loaders[ext] = loader
+ end
+
+ # Application options from the command line
+ def options
+ @options ||= OpenStruct.new
+ end
+
+ # private ----------------------------------------------------------------
+
+ def invoke_task(task_string)
+ 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]
+ end
+
+ # Provide standard execption handling for the given block.
+ def standard_exception_handling
+ begin
+ yield
+ rescue SystemExit => ex
+ # Exit silently with current status
+ raise
+ rescue OptionParser::InvalidOption => ex
+ $stderr.puts ex.message
+ exit(false)
+ rescue Exception => ex
+ # Exit with error message
+ display_error_message(ex)
+ exit(false)
+ end
+ end
+
+ # Display the error message that caused the exception.
+ def display_error_message(ex)
+ $stderr.puts "#{name} aborted!"
+ $stderr.puts ex.message
+ if options.trace
+ $stderr.puts ex.backtrace.join("\n")
+ else
+ $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
+ end
+ $stderr.puts "Tasks: #{ex.chain}" if has_chain?(ex)
+ $stderr.puts "(See full trace by running task with --trace)" unless options.trace
+ end
+
+ # Does the exception have a task invocation chain?
+ def has_chain?(exception)
+ 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
+ @rakefiles.each do |fn|
+ if File.exist?(fn)
+ others = Dir.glob(fn, File::FNM_CASEFOLD)
+ return others.size == 1 ? others.first : fn
+ elsif fn == ''
+ return fn
+ end
+ end
+ return nil
+ end
+
+ # True if we are outputting to TTY, false otherwise
+ def tty_output?
+ @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?
+ tty_output? || ENV['RAKE_COLUMNS']
+ end
+
+ # Display the tasks and comments.
+ def display_tasks_and_comments
+ displayable_tasks = tasks.select { |t|
+ t.comment && t.name =~ options.show_task_pattern
+ }
+ case options.show_tasks
+ when :tasks
+ width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10
+ max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil
+ displayable_tasks.each do |t|
+ printf "#{name} %-#{width}s # %s\n",
+ t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
+ end
+ when :describe
+ displayable_tasks.each do |t|
+ puts "#{name} #{t.name_with_args}"
+ t.full_comment.split("\n").each do |line|
+ puts " #{line}"
+ end
+ puts
+ end
+ when :lines
+ displayable_tasks.each do |t|
+ t.locations.each do |loc|
+ printf "#{name} %-30s %s\n",t.name_with_args, loc
+ end
+ end
+ else
+ fail "Unknown show task mode: '#{options.show_tasks}'"
+ end
+ end
+
+ def terminal_width
+ if ENV['RAKE_COLUMNS']
+ result = ENV['RAKE_COLUMNS'].to_i
+ else
+ result = unix? ? dynamic_width : 80
+ end
+ (result < 10) ? 80 : result
+ rescue
+ 80
+ end
+
+ # Calculate the dynamic width of the
+ def dynamic_width
+ @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
+ end
+
+ def dynamic_width_stty
+ %x{stty size 2>/dev/null}.split[1].to_i
+ end
+
+ def dynamic_width_tput
+ %x{tput cols 2>/dev/null}.to_i
+ end
+
+ def unix?
+ Config::CONFIG['host_os'] =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
+ end
+
+ def windows?
+ Win32.windows?
+ end
+
+ def truncate(string, width)
+ if string.length <= width
+ string
+ else
+ ( string[0, width-3] || "" ) + "..."
+ end
+ end
+
+ # Display the tasks and prerequisites
+ def display_prerequisites
+ tasks.each do |t|
+ puts "#{name} #{t.name}"
+ t.prerequisites.each { |pre| puts " #{pre}" }
+ end
+ end
+
+ # A list of all the standard options used in rake, suitable for
+ # passing to OptionParser.
+ def standard_rake_options
+ [
+ ['--classic-namespace', '-C', "Put Task and FileTask in the top level namespace",
+ lambda { |value|
+ require 'rake/classic_namespace'
+ options.classic_namespace = true
+ }
+ ],
+ ['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
+ lambda { |value|
+ options.show_tasks = :describe
+ options.show_task_pattern = Regexp.new(value || '')
+ TaskManager.record_task_metadata = true
+ }
+ ],
+ ['--dry-run', '-n', "Do a dry run without executing actions.",
+ lambda { |value|
+ verbose(true)
+ nowrite(true)
+ options.dryrun = true
+ options.trace = true
+ }
+ ],
+ ['--execute', '-e CODE', "Execute some Ruby code and exit.",
+ lambda { |value|
+ eval(value)
+ exit
+ }
+ ],
+ ['--execute-print', '-p CODE', "Execute some Ruby code, print the result, then exit.",
+ lambda { |value|
+ puts eval(value)
+ exit
+ }
+ ],
+ ['--execute-continue', '-E CODE',
+ "Execute some Ruby code, then continue with normal task processing.",
+ lambda { |value| eval(value) }
+ ],
+ ['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.",
+ lambda { |value| $:.push(value) }
+ ],
+ ['--prereqs', '-P', "Display the tasks and dependencies, then exit.",
+ lambda { |value| options.show_prereqs = true }
+ ],
+ ['--quiet', '-q', "Do not log messages to standard output.",
+ lambda { |value| verbose(false) }
+ ],
+ ['--rakefile', '-f [FILE]', "Use FILE as the rakefile.",
+ lambda { |value|
+ value ||= ''
+ @rakefiles.clear
+ @rakefiles << value
+ }
+ ],
+ ['--rakelibdir', '--rakelib', '-R RAKELIBDIR',
+ "Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')",
+ lambda { |value| options.rakelib = value.split(':') }
+ ],
+ ['--require', '-r MODULE', "Require MODULE before executing rakefile.",
+ lambda { |value|
+ begin
+ require value
+ rescue LoadError => ex
+ begin
+ rake_require value
+ rescue LoadError => ex2
+ raise ex
+ end
+ end
+ }
+ ],
+ ['--rules', "Trace the rules resolution.",
+ lambda { |value| options.trace_rules = true }
+ ],
+ ['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.",
+ lambda { |value| options.nosearch = true }
+ ],
+ ['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.",
+ lambda { |value|
+ verbose(false)
+ options.silent = true
+ }
+ ],
+ ['--system', '-g',
+ "Using system wide (global) rakefiles (usually '~/.rake/*.rake').",
+ lambda { |value| options.load_system = true }
+ ],
+ ['--no-system', '--nosystem', '-G',
+ "Use standard project Rakefile search paths, ignore system wide rakefiles.",
+ lambda { |value| options.ignore_system = true }
+ ],
+ ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.",
+ lambda { |value|
+ options.show_tasks = :tasks
+ options.show_task_pattern = Regexp.new(value || '')
+ Rake::TaskManager.record_task_metadata = true
+ }
+ ],
+ ['--no-top-level-dsl', '-X', "Do no put Rake DSL commands in the top level scope.",
+ lambda { |value|
+ options.top_level_dsl = ! value
+ }
+ ],
+ ['--top-level-dsl', "Put Rake DSL commands in the top level scope (default).",
+ lambda { |value|
+ options.top_level_dsl = value
+ }
+ ],
+ ['--trace', '-t', "Turn on invoke/execute tracing, enable full backtrace.",
+ lambda { |value|
+ options.trace = true
+ verbose(true)
+ }
+ ],
+ ['--verbose', '-v', "Log message to standard output.",
+ lambda { |value| verbose(true) }
+ ],
+ ['--version', '-V', "Display the program version.",
+ lambda { |value|
+ puts "rake, version #{RAKEVERSION}"
+ exit
+ }
+ ],
+ ['--where', '-W [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
+ lambda { |value|
+ options.show_tasks = :lines
+ options.show_task_pattern = Regexp.new(value || '')
+ Rake::TaskManager.record_task_metadata = true
+ }
+ ],
+ ]
+ end
+
+ # Read and handle the command line options.
+ def handle_options
+ options.rakelib = ['rakelib']
+ options.top_level_dsl = true
+
+ OptionParser.new do |opts|
+ opts.banner = "rake [-f rakefile] {options} targets..."
+ opts.separator ""
+ opts.separator "Options are ..."
+
+ opts.on_tail("-h", "--help", "-H", "Display this help message.") do
+ puts opts
+ exit
+ end
+
+ standard_rake_options.each { |args| opts.on(*args) }
+ opts.environment('RAKEOPT')
+ end.parse!
+
+ Rake::DSL.include_in_top_scope if options.top_level_dsl
+
+ # If class namespaces are requested, set the global options
+ # according to the values in the options structure.
+ if options.classic_namespace
+ $show_tasks = options.show_tasks
+ $show_prereqs = options.show_prereqs
+ $trace = options.trace
+ $dryrun = options.dryrun
+ $silent = options.silent
+ end
+ 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=$")
+ return false if loaded.include?(file_name)
+ paths.each do |path|
+ fn = file_name + ".rake"
+ full_path = File.join(path, fn)
+ if File.exist?(full_path)
+ Rake::Environment.load_rakefile(full_path)
+ loaded << fn
+ return true
+ end
+ end
+ fail LoadError, "Can't find #{file_name}"
+ end
+
+ def find_rakefile_location
+ here = Dir.pwd
+ while ! (fn = have_rakefile)
+ Dir.chdir("..")
+ if Dir.pwd == here || options.nosearch
+ return nil
+ end
+ here = Dir.pwd
+ end
+ [fn, here]
+ ensure
+ Dir.chdir(Rake.original_dir)
+ end
+
+ def raw_load_rakefile # :nodoc:
+ rakefile, location = find_rakefile_location
+ if (! options.ignore_system) &&
+ (options.load_system || rakefile.nil?) &&
+ system_dir && File.directory?(system_dir)
+ puts "(in #{Dir.pwd})" unless options.silent
+ glob("#{system_dir}/*.rake") do |name|
+ add_import name
+ end
+ else
+ fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})" if
+ rakefile.nil?
+ @rakefile = rakefile
+ Dir.chdir(location)
+ puts "(in #{Dir.pwd})" unless options.silent
+ $rakefile = @rakefile if options.classic_namespace
+ Rake::Environment.load_rakefile(File.expand_path(@rakefile)) if @rakefile && @rakefile != ''
+ options.rakelib.each do |rlib|
+ glob("#{rlib}/*.rake") do |name|
+ add_import name
+ end
+ end
+ end
+ load_imports
+ end
+
+ def glob(path, &block)
+ Dir[path.gsub("\\", '/')].each(&block)
+ end
+ private :glob
+
+ # The directory path containing the system wide rakefiles.
+ def system_dir
+ @system_dir ||=
+ begin
+ if ENV['RAKE_SYSTEM']
+ ENV['RAKE_SYSTEM']
+ else
+ standard_system_dir
+ end
+ end
+ end
+
+ # The standard directory containing system wide rake files.
+ if Win32.windows?
+ def standard_system_dir #:nodoc:
+ Win32.win32_system_dir
+ end
+ else
+ def standard_system_dir #:nodoc:
+ File.join(File.expand_path('~'), '.rake')
+ end
+ end
+ private :standard_system_dir
+
+ # 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
+ @top_level_tasks = []
+ ARGV.each do |arg|
+ if arg =~ /^(\w+)=(.*)$/
+ ENV[$1] = $2
+ else
+ @top_level_tasks << arg unless arg =~ /^-/
+ end
+ end
+ @top_level_tasks.push("default") if @top_level_tasks.size == 0
+ end
+
+ # Add a file to the list of files to be imported.
+ def add_import(fn)
+ @pending_imports << fn
+ end
+
+ # Load the pending list of imported files.
+ def load_imports
+ while fn = @pending_imports.shift
+ next if @imported.member?(fn)
+ if fn_task = lookup(fn)
+ fn_task.invoke
+ end
+ ext = File.extname(fn)
+ loader = @loaders[ext] || @default_loader
+ loader.load(fn)
+ @imported << fn
+ end
+ end
+
+ # Warn about deprecated use of top level constant names.
+ def const_warning(const_name)
+ @const_warning ||= false
+ if ! @const_warning
+ $stderr.puts %{WARNING: Deprecated reference to top-level constant '#{const_name}' } +
+ %{found at: #{rakefile_location}} # '
+ $stderr.puts %{ Use --classic-namespace on rake command}
+ $stderr.puts %{ or 'require "rake/classic_namespace"' in Rakefile}
+ end
+ @const_warning = true
+ end
+
+ def rakefile_location
+ begin
+ fail
+ rescue RuntimeError => ex
+ ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
+ end
+ end
+ end
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/classic_namespace.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/classic_namespace.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/classic_namespace.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,9 @@
+# The following classes used to be in the top level namespace.
+# Loading this file enables compatibility with older Rakefile that
+# referenced Task from the top level.
+
+puts "WARNING: Classic namespaces are deprecated and will be removed from future versions of Rake."
+Task = Rake::Task
+FileTask = Rake::FileTask
+FileCreationTask = Rake::FileCreationTask
+RakeApp = Rake::Application
Added: MacRuby/trunk/test/libs/rake/lib/rake/clean.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/clean.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/clean.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,35 @@
+#!/usr/bin/env ruby
+
+# The 'rake/clean' file defines two file lists (CLEAN and CLOBBER) and
+# two rake tasks (:clean and :clobber).
+#
+# [:clean] Clean up the project by deleting scratch files and backup
+# files. Add files to the CLEAN file list 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 file list.
+# The intent of this task is to return a project to its
+# pristine, just unpacked state.
+
+require 'rake'
+
+Rake::DSL.environment do
+ CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"]
+ CLEAN.clear_exclude.exclude { |fn|
+ fn.pathmap("%f") == 'core' && File.directory?(fn)
+ }
+
+ desc "Remove any temporary products."
+ task :clean do
+ CLEAN.each { |fn| rm_r fn rescue nil }
+ end
+
+ CLOBBER = Rake::FileList.new
+
+ desc "Remove any generated file."
+ task :clobber => [:clean] do
+ CLOBBER.each { |fn| rm_r fn rescue nil }
+ end
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/cloneable.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/cloneable.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/cloneable.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,25 @@
+module Rake
+ # ##########################################################################
+ # Mixin for creating easily cloned objects.
+ #
+ module Cloneable
+ # Clone an object by making a new object and setting all the instance
+ # variables to the same values.
+ def dup
+ sibling = self.class.new
+ instance_variables.each do |ivar|
+ value = self.instance_variable_get(ivar)
+ new_value = value.clone rescue value
+ sibling.instance_variable_set(ivar, new_value)
+ end
+ sibling.taint if tainted?
+ sibling
+ end
+
+ def clone
+ sibling = dup
+ sibling.freeze if frozen?
+ sibling
+ end
+ end
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/contrib/compositepublisher.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/contrib/compositepublisher.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/contrib/compositepublisher.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+
+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
+
+
Added: MacRuby/trunk/test/libs/rake/lib/rake/contrib/ftptools.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/contrib/ftptools.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/contrib/ftptools.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,153 @@
+#!/usr/bin/env ruby
+
+# = Tools for FTP uploading.
+#
+# This file is still under development and is not released for general
+# use.
+
+require 'date'
+require 'net/ftp'
+
+module Rake # :nodoc:
+
+ ####################################################################
+ # <b>Note:</b> <em> Not released for general use.</em>
+ 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, line, @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
+ h, m = d3.split(':')
+ result = Time.parse("#{d1} #{d2} #{now.year} #{d3}")
+ if result > now
+ result = Time.parse("#{d1} #{d2} #{now.year-1} #{d3}")
+ end
+ else
+ result = Time.parse("#{d1} #{d2} #{d3}")
+ end
+ result
+# elements = ParseDate.parsedate("#{d1} #{d2} #{d3}")
+# if elements[0].nil?
+# today = self.class.date.today
+# if elements[1] > today.month
+# elements[0] = today.year - 1
+# else
+# elements[0] = today.year
+# end
+# end
+# elements = elements.collect { |el| el.nil? ? 0 : el }
+# Time.mktime(*elements[0,7])
+ 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 targetting 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
+ 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)
+ Dir[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)
+ puts "Uploading #{file}" if @verbose
+ dir = File.dirname(file)
+ makedirs(dir)
+ @ftp.putbinaryfile(file, file) unless File.directory?(file)
+ end
+ end
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/contrib/publisher.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/contrib/publisher.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/contrib/publisher.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,75 @@
+#!/usr/bin/env ruby
+
+# Copyright 2003, 2004, 2005, 2006, 2007, 2008 by Jim Weirich (jim at weirichhouse.org)
+# All rights reserved.
+
+# Permission is granted for use, copying, modification, distribution,
+# and distribution of modified versions of this work as long as the
+# above copyright notice is included.
+
+# 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)
+
+# 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
Added: MacRuby/trunk/test/libs/rake/lib/rake/contrib/rubyforgepublisher.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/contrib/rubyforgepublisher.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/contrib/rubyforgepublisher.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+
+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
Added: MacRuby/trunk/test/libs/rake/lib/rake/contrib/sshpublisher.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/contrib/sshpublisher.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/contrib/sshpublisher.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,47 @@
+#!/usr/bin/env ruby
+
+require 'rake/contrib/compositepublisher'
+
+module Rake
+
+ # 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
+ 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
+ # 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
Added: MacRuby/trunk/test/libs/rake/lib/rake/contrib/sys.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/contrib/sys.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/contrib/sys.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,209 @@
+#!/usr/bin/env ruby
+
+#--
+# Copyright 2003, 2004, 2005, 2006, 2007, 2008 by Jim Weirich (jim at weirichhouse.org)
+#
+# 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.
+#++
+#
+begin
+ require 'ftools'
+rescue LoadError
+end
+require 'rbconfig'
+
+######################################################################
+# Sys provides a number of file manipulation tools for the convenience
+# of writing Rakefiles. All commands in this module will announce
+# their activity on standard output if the $verbose flag is set
+# ($verbose = true is the default). You can control this by globally
+# setting $verbose or by using the +verbose+ and +quiet+ methods.
+#
+# Sys has been deprecated in favor of the FileUtils module available
+# in Ruby 1.8.
+#
+module Sys
+ RUBY = Config::CONFIG['ruby_install_name']
+
+ # Install all the files matching +wildcard+ into the +dest_dir+
+ # directory. The permission mode is set to +mode+.
+ def install(wildcard, dest_dir, mode)
+ Dir[wildcard].each do |fn|
+ File.install(fn, dest_dir, mode, $verbose)
+ end
+ end
+
+ # Run the system command +cmd+.
+ def run(cmd)
+ log cmd
+ system(cmd) or fail "Command Failed: [#{cmd}]"
+ end
+
+ # Run a Ruby interpreter with the given arguments.
+ def ruby(*args)
+ run "#{RUBY} #{args.join(' ')}"
+ end
+
+ # Copy a single file from +file_name+ to +dest_file+.
+ def copy(file_name, dest_file)
+ log "Copying file #{file_name} to #{dest_file}"
+ File.copy(file_name, dest_file)
+ end
+
+ # Copy all files matching +wildcard+ into the directory +dest_dir+.
+ def copy_files(wildcard, dest_dir)
+ for_matching_files(wildcard, dest_dir) { |from, to| copy(from, to) }
+ end
+
+ # Link +file_name+ to +dest_file+.
+ def link(file_name, dest_file)
+ log "Linking file #{file_name} to #{dest_file}"
+ File.link(file_name, dest_file)
+ end
+
+ # Link all files matching +wildcard+ into the directory +dest_dir+.
+ def link_files(wildcard, dest_dir)
+ for_matching_files(wildcard, dest_dir) { |from, to| link(from, to) }
+ end
+
+ # Symlink +file_name+ to +dest_file+.
+ def symlink(file_name, dest_file)
+ log "Symlinking file #{file_name} to #{dest_file}"
+ File.symlink(file_name, dest_file)
+ end
+
+ # Symlink all files matching +wildcard+ into the directory +dest_dir+.
+ def symlink_files(wildcard, dest_dir)
+ for_matching_files(wildcard, dest_dir) { |from, to| link(from, to) }
+ end
+
+ # Remove all files matching +wildcard+. If a matching file is a
+ # directory, it must be empty to be removed. used +delete_all+ to
+ # recursively delete directories.
+ def delete(*wildcards)
+ wildcards.each do |wildcard|
+ Dir[wildcard].each do |fn|
+ if File.directory?(fn)
+ log "Deleting directory #{fn}"
+ Dir.delete(fn)
+ else
+ log "Deleting file #{fn}"
+ File.delete(fn)
+ end
+ end
+ end
+ end
+
+ # Recursively delete all files and directories matching +wildcard+.
+ def delete_all(*wildcards)
+ wildcards.each do |wildcard|
+ Dir[wildcard].each do |fn|
+ next if ! File.exist?(fn)
+ if File.directory?(fn)
+ Dir["#{fn}/*"].each do |subfn|
+ next if subfn=='.' || subfn=='..'
+ delete_all(subfn)
+ end
+ log "Deleting directory #{fn}"
+ Dir.delete(fn)
+ else
+ log "Deleting file #{fn}"
+ File.delete(fn)
+ end
+ end
+ end
+ end
+
+ # Make the directories given in +dirs+.
+ def makedirs(*dirs)
+ dirs.each do |fn|
+ log "Making directory #{fn}"
+ File.makedirs(fn)
+ end
+ end
+
+ # Make +dir+ the current working directory for the duration of
+ # executing the given block.
+ def indir(dir)
+ olddir = Dir.pwd
+ Dir.chdir(dir)
+ yield
+ ensure
+ Dir.chdir(olddir)
+ end
+
+ # Split a file path into individual directory names.
+ #
+ # For example:
+ # split_all("a/b/c") => ['a', 'b', 'c']
+ def split_all(path)
+ head, tail = File.split(path)
+ return [tail] if head == '.' || tail == '/'
+ return [head, tail] if head == '/'
+ return split_all(head) + [tail]
+ end
+
+ # Write a message to standard out if $verbose is enabled.
+ def log(msg)
+ print " " if $trace && $verbose
+ puts msg if $verbose
+ end
+
+ # Perform a block with $verbose disabled.
+ def quiet(&block)
+ with_verbose(false, &block)
+ end
+
+ # Perform a block with $verbose enabled.
+ def verbose(&block)
+ with_verbose(true, &block)
+ end
+
+ # Perform a block with each file matching a set of wildcards.
+ def for_files(*wildcards)
+ wildcards.each do |wildcard|
+ Dir[wildcard].each do |fn|
+ yield(fn)
+ end
+ end
+ end
+
+ extend(self)
+
+ private # ----------------------------------------------------------
+
+ def for_matching_files(wildcard, dest_dir)
+ Dir[wildcard].each do |fn|
+ dest_file = File.join(dest_dir, fn)
+ parent = File.dirname(dest_file)
+ makedirs(parent) if ! File.directory?(parent)
+ yield(fn, dest_file)
+ end
+ end
+
+ def with_verbose(v)
+ oldverbose = $verbose
+ $verbose = v
+ yield
+ ensure
+ $verbose = oldverbose
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/default_loader.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/default_loader.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/default_loader.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,10 @@
+module Rake
+
+ # Default Rakefile loader used by +import+.
+ class DefaultLoader
+ def load(fn)
+ Rake::Environment.load_rakefile(File.expand_path(fn))
+ end
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/dsl.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/dsl.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/dsl.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,136 @@
+# Rake DSL functions.
+
+module Rake
+ module DSL
+ # Declare a basic task.
+ #
+ # Example:
+ # task :clobber => [:clean] do
+ # rm_rf "html"
+ # end
+ #
+ def task(*args, &block)
+ Rake::Task.define_task(*args, &block)
+ end
+
+
+ # Declare a file task.
+ #
+ # Example:
+ # file "config.cfg" => ["config.template"] do
+ # open("config.cfg", "w") do |outfile|
+ # open("config.template") do |infile|
+ # while line = infile.gets
+ # outfile.puts line
+ # end
+ # end
+ # end
+ # end
+ #
+ def file(*args, &block)
+ Rake::FileTask.define_task(*args, &block)
+ end
+
+ # Declare a file creation task.
+ # (Mainly used for the directory command).
+ def file_create(args, &block)
+ Rake::FileCreationTask.define_task(args, &block)
+ end
+
+ # Declare a set of files tasks to create the given directories on
+ # demand.
+ #
+ # Example:
+ # directory "testdata/doc"
+ #
+ def directory(dir)
+ Rake.each_dir_parent(dir) do |d|
+ file_create d do |t|
+ mkdir_p t.name if ! File.exist?(t.name)
+ end
+ end
+ end
+
+ # Declare a task that performs its prerequisites in
+ # parallel. Multitasks does *not* guarantee that its prerequisites
+ # will execute in any given order (which is obvious when you think
+ # about it)
+ #
+ # Example:
+ # multitask :deploy => [:deploy_gem, :deploy_rdoc]
+ #
+ def multitask(args, &block)
+ Rake::MultiTask.define_task(args, &block)
+ end
+
+ # Create a new rake namespace and use it for evaluating the given
+ # block. Returns a NameSpace object that can be used to lookup
+ # tasks defined in the namespace.
+ #
+ # E.g.
+ #
+ # ns = namespace "nested" do
+ # task :run
+ # end
+ # task_run = ns[:run] # find :run in the given namespace.
+ #
+ def namespace(name=nil, &block)
+ 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?
+ raise ArgumentError, "Expected a String or Symbol for a namespace name"
+ end
+ Rake.application.in_namespace(name, &block)
+ end
+
+ # Declare a rule for auto-tasks.
+ #
+ # Example:
+ # rule '.o' => '.c' do |t|
+ # sh %{cc -o #{t.name} #{t.source}}
+ # end
+ #
+ def rule(*args, &block)
+ Rake::Task.create_rule(*args, &block)
+ end
+
+ # Describe the next rake task.
+ #
+ # Example:
+ # desc "Run the Unit Tests"
+ # task :test => [:build]
+ # runtests
+ # end
+ #
+ def desc(description)
+ Rake.application.last_description = description
+ end
+
+ # Import the partial Rakefiles +fn+. Imported files are loaded
+ # _after_ the current file is completely loaded. This allows the
+ # import statement to appear anywhere in the importing file, and yet
+ # allowing the imported files to depend on objects defined in the
+ # importing file.
+ #
+ # A common use of the import statement is to include files
+ # containing dependency declarations.
+ #
+ # See also the --rakelibdir command line option.
+ #
+ # Example:
+ # import ".depend", "my_rules"
+ #
+ def import(*fns)
+ fns.each do |fn|
+ Rake.application.add_import(fn)
+ end
+ end
+
+ # Include the Rake DSL commands in the top level Ruby scope.
+ def self.include_in_top_scope
+ Object.send(:include, Rake::DSL)
+ end
+ end
+
+end
+
Added: MacRuby/trunk/test/libs/rake/lib/rake/early_time.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/early_time.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/early_time.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,18 @@
+module Rake
+
+ # EarlyTime is a fake timestamp that occurs _before_ any other time value.
+ class EarlyTime
+ include Comparable
+ include Singleton
+
+ def <=>(other)
+ -1
+ end
+
+ def to_s
+ "<EARLY TIME>"
+ end
+ end
+
+ EARLY = EarlyTime.instance
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/environment.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/environment.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/environment.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,40 @@
+require 'rake/dsl'
+
+module Rake
+
+ # Rakefile are evaluated in the Rake::Environment module space. Top
+ # level rake functions (e.g. :task, :file) are available in this
+ # environment.
+ module Environment
+ extend Rake::DSL
+
+ class << self
+ # Load a rakefile from the given path. The Rakefile is loaded
+ # in an environment that includes the Rake DSL methods.
+ def load_rakefile(rakefile_path)
+ rakefile = open(rakefile_path) { |f| f.read }
+ load_string(rakefile, rakefile_path)
+ end
+
+ # Load a string of code in the Rake DSL environment. If the
+ # string comes from a file, include the file path so that proper
+ # line numbers references may be retained.
+ def load_string(code, file_name=nil)
+ module_eval(code, file_name || "(eval)")
+ end
+
+ # Run a block of code in the Rake DSL environment.
+ def run(&block)
+ module_eval(&block)
+ end
+ end
+ end
+
+ # Run the code block in an environment including the Rake DSL
+ # commands.
+ def DSL.environment(&block)
+ Rake::Environment.run(&block)
+ end
+end
+
+
Added: MacRuby/trunk/test/libs/rake/lib/rake/ext/module.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/ext/module.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/ext/module.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,60 @@
+require 'rake/task'
+require 'rake/file_task'
+require 'rake/file_creation_task'
+require 'rake/application'
+require 'rake/task_manager'
+
+######################################################################
+# Rake extensions to Module.
+#
+class Module
+ # 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.
+ #
+ # Usage:
+ #
+ # class String
+ # rake_extension("xyz") do
+ # def xyz
+ # ...
+ # end
+ # end
+ # end
+ #
+ def rake_extension(method)
+ if method_defined?(method)
+ $stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists"
+ else
+ yield
+ end
+ end
+
+ # Rename the original handler to make it available.
+ alias :rake_original_const_missing :const_missing
+
+ # Check for deprecated uses of top level (i.e. in Object) uses of
+ # Rake class names. If someone tries to reference the constant
+ # name, display a warning and return the proper object. Using the
+ # --classic-namespace command line option will define these
+ # constants in Object and avoid this handler.
+ def const_missing(const_name)
+ case const_name
+ when :Task
+ Rake.application.const_warning(const_name)
+ Rake::Task
+ when :FileTask
+ Rake.application.const_warning(const_name)
+ Rake::FileTask
+ when :FileCreationTask
+ Rake.application.const_warning(const_name)
+ Rake::FileCreationTask
+ when :RakeApp
+ Rake.application.const_warning(const_name)
+ Rake::Application
+ else
+ rake_original_const_missing(const_name)
+ end
+ end
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/ext/string.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/ext/string.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/ext/string.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,165 @@
+######################################################################
+# Rake extension methods for String.
+#
+class String
+ rake_extension("ext") do
+ # Replace the file extension with +newext+. If there is no extension on
+ # the string, append the new extension to the end. If the new extension
+ # 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
+ if newext != ''
+ newext = (newext =~ /^\./) ? newext : ("." + newext)
+ end
+ self.chomp(File.extname(self)) << newext
+ end
+ end
+
+ rake_extension("pathmap") do
+ # Explode a path into individual components. Used by +pathmap+.
+ def pathmap_explode
+ head, tail = File.split(self)
+ return [self] if head == self
+ return [tail] if head == '.' || tail == '/'
+ return [head, tail] if head == '/'
+ return head.pathmap_explode + [tail]
+ end
+ protected :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.
+ def pathmap_partial(n)
+ dirs = File.dirname(self).pathmap_explode
+ partial_dirs =
+ if n > 0
+ dirs[0...n]
+ elsif n < 0
+ dirs.reverse[0...-n].reverse
+ else
+ "."
+ end
+ File.join(partial_dirs)
+ end
+ protected :pathmap_partial
+
+ # Preform the pathmap replacement operations on the given path. The
+ # patterns take the form 'pat1,rep1;pat2,rep2...'.
+ def pathmap_replace(patterns, &block)
+ result = self
+ patterns.split(';').each do |pair|
+ pattern, replacement = pair.split(',')
+ pattern = Regexp.new(pattern)
+ if replacement == '*' && block_given?
+ result = result.sub(pattern, &block)
+ elsif replacement
+ result = result.sub(pattern, replacement)
+ else
+ result = result.sub(pattern, '')
+ end
+ end
+ result
+ end
+ protected :pathmap_replace
+
+ # Map the path according to the given specification. The specification
+ # controls the details of the mapping. The following special patterns are
+ # recognized:
+ #
+ # * <b>%p</b> -- The complete path.
+ # * <b>%f</b> -- The base file name of the path, with its file extension,
+ # but without any directories.
+ # * <b>%n</b> -- The file name of the path without its file extension.
+ # * <b>%d</b> -- The directory list of the path.
+ # * <b>%x</b> -- The file extension of the path. An empty string if there
+ # is no extension.
+ # * <b>%X</b> -- Everything *but* the file extension.
+ # * <b>%s</b> -- The alternate file separater if defined, otherwise use
+ # the standard file separator.
+ # * <b>%%</b> -- 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 substititions on a
+ # particular part of the path. The pattern and replacement are speparated
+ # 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"). Muliple 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
+ # excluded from both the pattern and replacement text (let's keep parsing
+ # reasonable).
+ #
+ # For example:
+ #
+ # "src/org/onestepback/proj/A.java".pathmap("%{^src,bin}X.class")
+ #
+ # returns:
+ #
+ # "bin/org/onestepback/proj/A.class"
+ #
+ # If the replacement text is '*', then a block may be provided to perform
+ # some arbitrary calculation for the replacement.
+ #
+ # For example:
+ #
+ # "/path/to/file.TXT".pathmap("%X%{.*,*}x") { |ext|
+ # ext.downcase
+ # }
+ #
+ # Returns:
+ #
+ # "/path/to/file.txt"
+ #
+ def pathmap(spec=nil, &block)
+ return self if spec.nil?
+ result = ''
+ spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag|
+ case frag
+ when '%f'
+ result << File.basename(self)
+ when '%n'
+ result << File.basename(self).ext
+ when '%d'
+ result << File.dirname(self)
+ when '%x'
+ result << File.extname(self)
+ when '%X'
+ result << self.ext
+ when '%p'
+ result << self
+ when '%s'
+ result << (File::ALT_SEPARATOR || File::SEPARATOR)
+ when '%-'
+ # do nothing
+ 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)
+ when /^%/
+ fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'"
+ else
+ result << frag
+ end
+ end
+ result
+ end
+ end
+end # class String
+
Added: MacRuby/trunk/test/libs/rake/lib/rake/ext/time.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/ext/time.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/ext/time.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,14 @@
+# ###########################################################################
+# Extensions to time to allow comparisons with an early time class.
+#
+class Time
+ alias rake_original_time_compare :<=>
+ def <=>(other)
+ if Rake::EarlyTime === other
+ - other.<=>(self)
+ else
+ rake_original_time_compare(other)
+ end
+ end
+end # class Time
+
Added: MacRuby/trunk/test/libs/rake/lib/rake/file_creation_task.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/file_creation_task.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/file_creation_task.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,24 @@
+require 'rake/file_task'
+require 'rake/early_time'
+
+module Rake
+
+ # A FileCreationTask is a file task that when used as a dependency will be
+ # needed if and only if the file has not been created. Once created, it is
+ # not re-triggered if any of its dependencies are newer, nor does trigger
+ # any rebuilds of tasks that depend on it whenever it is updated.
+ #
+ class FileCreationTask < FileTask
+ # Is this file task needed? Yes if it doesn't exist.
+ def needed?
+ ! File.exist?(name)
+ end
+
+ # Time stamp for file creation task. This time stamp is earlier
+ # than any other time stamp.
+ def timestamp
+ Rake::EARLY
+ end
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/file_list.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/file_list.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/file_list.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,395 @@
+require 'rake/cloneable'
+require 'rake/rake_file_utils'
+
+######################################################################
+module Rake
+
+ # #########################################################################
+ # A FileList is essentially an array with a few helper methods defined to
+ # make file manipulation a bit easier.
+ #
+ # FileLists are lazy. When given a list of glob patterns for possible files
+ # to be included in the file list, instead of searching the file structures
+ # to find the files, a FileList holds the pattern for latter use.
+ #
+ # This allows us to define a number of FileList to match any number of
+ # files, but only search out the actual files when then FileList itself is
+ # actually used. The key is that the first time an element of the
+ # FileList/Array is requested, the pending patterns are resolved into a real
+ # list of file names.
+ #
+ class FileList
+
+ include Cloneable
+
+ # == Method Delegation
+ #
+ # The lazy evaluation magic of FileLists happens by implementing all the
+ # array specific methods to call +resolve+ before delegating the heavy
+ # lifting to an embedded array object (@items).
+ #
+ # In addition, there are two kinds of delegation calls. The regular kind
+ # delegates to the @items array and returns the result directly. Well,
+ # almost directly. It checks if the returned value is the @items object
+ # itself, and if so will return the FileList object instead.
+ #
+ # The second kind of delegation call is used in methods that normally
+ # return a new Array object. We want to capture the return value of these
+ # methods and wrap them in a new FileList object. We enumerate these
+ # methods in the +SPECIAL_RETURN+ list below.
+
+ # 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 }
+
+ # List of additional methods that must be delegated.
+ MUST_DEFINE = %w[to_a 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 *]
+
+ # List of delegated methods that return new array values which need
+ # wrapping.
+ SPECIAL_RETURN = %w[
+ map collect sort sort_by select find_all reject grep
+ compact flatten uniq values_at
+ + - & |
+ ]
+
+ DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).collect{ |s| s.to_s }.sort.uniq
+
+ # Now do the delegation.
+ DELEGATING_METHODS.each_with_index do |sym, i|
+ if SPECIAL_RETURN.include?(sym)
+ ln = __LINE__+1
+ class_eval %{
+ def #{sym}(*args, &block)
+ resolve
+ result = @items.send(:#{sym}, *args, &block)
+ FileList.new.import(result)
+ end
+ }, __FILE__, ln
+ else
+ ln = __LINE__+1
+ class_eval %{
+ def #{sym}(*args, &block)
+ resolve
+ result = @items.send(:#{sym}, *args, &block)
+ result.object_id == @items.object_id ? self : result
+ end
+ }, __FILE__, ln
+ end
+ end
+
+ # 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.
+ #
+ # Example:
+ # file_list = FileList.new('lib/**/*.rb', 'test/test*.rb')
+ #
+ # pkg_files = FileList.new('lib/**/*') do |fl|
+ # fl.exclude(/\bCVS\b/)
+ # end
+ #
+ def initialize(*patterns)
+ @pending_add = []
+ @pending = false
+ @exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup
+ @exclude_procs = DEFAULT_IGNORE_PROCS.dup
+ @items = []
+ patterns.each { |pattern| include(pattern) }
+ yield self if block_given?
+ end
+
+ # Add file names defined by glob patterns to the file list. If an array
+ # is given, add each element of the array.
+ #
+ # Example:
+ # file_list.include("*.java", "*.cfg")
+ # file_list.include %w( math.c lib.h *.o )
+ #
+ def include(*filenames)
+ # TODO: check for pending
+ filenames.each do |fn|
+ if fn.respond_to? :to_ary
+ include(*fn.to_ary)
+ else
+ @pending_add << fn
+ end
+ end
+ @pending = true
+ self
+ end
+ alias :add :include
+
+ # Register a list of file name patterns that should be excluded from the
+ # list. Patterns may be regular expressions, glob patterns or regular
+ # strings. In addition, a block given to exclude will remove entries that
+ # return true when given to the block.
+ #
+ # Note that glob patterns are expanded against the file system. If a file
+ # is explicitly added to a file list, but does not exist in the file
+ # system, then an glob pattern in the exclude list will not exclude the
+ # file.
+ #
+ # Examples:
+ # FileList['a.c', 'b.c'].exclude("a.c") => ['b.c']
+ # FileList['a.c', 'b.c'].exclude(/^a/) => ['b.c']
+ #
+ # If "a.c" is a file, then ...
+ # FileList['a.c', 'b.c'].exclude("a.*") => ['b.c']
+ #
+ # If "a.c" is not a file, then ...
+ # FileList['a.c', 'b.c'].exclude("a.*") => ['a.c', 'b.c']
+ #
+ def exclude(*patterns, &block)
+ patterns.each do |pat|
+ @exclude_patterns << pat
+ end
+ if block_given?
+ @exclude_procs << block
+ end
+ resolve_exclude if ! @pending
+ self
+ end
+
+
+ # Clear all the exclude patterns so that we exclude nothing.
+ def clear_exclude
+ @exclude_patterns = []
+ @exclude_procs = []
+ self
+ end
+
+ # Define equality.
+ def ==(array)
+ to_ary == array
+ end
+
+ # Return the internal array object.
+ def to_a
+ resolve
+ @items
+ end
+
+ # Return the internal array object.
+ def to_ary
+ to_a
+ end
+
+ # Lie about our class.
+ def is_a?(klass)
+ klass == Array || super(klass)
+ end
+ alias kind_of? is_a?
+
+ # Redefine * to return either a string or a new file list.
+ def *(other)
+ result = @items * other
+ case result
+ when Array
+ FileList.new.import(result)
+ else
+ result
+ end
+ end
+
+ # Resolve all the pending adds now.
+ def resolve
+ if @pending
+ @pending = false
+ @pending_add.each do |fn| resolve_add(fn) end
+ @pending_add = []
+ resolve_exclude
+ end
+ self
+ end
+
+ def resolve_add(fn)
+ case fn
+ when %r{[*?\[\{]}
+ add_matching(fn)
+ else
+ self << fn
+ end
+ end
+ private :resolve_add
+
+ def resolve_exclude
+ reject! { |fn| exclude?(fn) }
+ self
+ end
+ private :resolve_exclude
+
+ # Return a new FileList with the results of running +sub+ against each
+ # element of the oringal list.
+ #
+ # Example:
+ # 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) }
+ end
+
+ # Return a new FileList with the results of running +gsub+ against each
+ # element of the original list.
+ #
+ # Example:
+ # FileList['lib/test/file', 'x/y'].gsub(/\//, "\\")
+ # => ['lib\\test\\file', 'x\\y']
+ #
+ def gsub(pat, rep)
+ inject(FileList.new) { |res, fn| res << fn.gsub(pat,rep) }
+ end
+
+ # Same as +sub+ except that the oringal file list is modified.
+ def sub!(pat, rep)
+ each_with_index { |fn, i| self[i] = fn.sub(pat,rep) }
+ self
+ end
+
+ # Same as +gsub+ except that the original file list is modified.
+ def gsub!(pat, rep)
+ each_with_index { |fn, i| self[i] = fn.gsub(pat,rep) }
+ self
+ end
+
+ # 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) }
+ end
+
+ # Return a new FileList with <tt>String#ext</tt> method applied
+ # to each member of the array.
+ #
+ # This method is a shortcut for:
+ #
+ # array.collect { |item| item.ext(newext) }
+ #
+ # +ext+ is a user added method for the Array class.
+ 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,
+ # a standard emac style file:linenumber:line message will be printed to
+ # standard out.
+ def egrep(pattern, *options)
+ each do |fn|
+ open(fn, "rb", *options) do |inf|
+ count = 0
+ inf.each do |line|
+ count += 1
+ if pattern.match(line)
+ if block_given?
+ yield fn, count, line
+ else
+ puts "#{fn}:#{count}:#{line}"
+ end
+ end
+ end
+ end
+ end
+ end
+
+ # 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) }
+ 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) }
+ self
+ end
+
+ # FileList version of partition. Needed because the nested arrays should
+ # be FileLists in this version.
+ def partition(&block) # :nodoc:
+ resolve
+ result = @items.partition(&block)
+ [
+ FileList.new.import(result[0]),
+ FileList.new.import(result[1]),
+ ]
+ end
+
+ # Convert a FileList to a string by joining all elements with a space.
+ def to_s
+ resolve
+ self.join(' ')
+ end
+
+ # Add matching glob patterns.
+ def add_matching(pattern)
+ Dir[pattern].each do |fn|
+ self << fn unless exclude?(fn)
+ end
+ end
+ private :add_matching
+
+ # Should the given file name be excluded?
+ def exclude?(fn)
+ return true if @exclude_patterns.any? do |pat|
+ case pat
+ when Regexp
+ fn =~ pat
+ when /[*?]/
+ File.fnmatch?(pat, fn, File::FNM_PATHNAME)
+ else
+ fn == pat
+ end
+ end
+ @exclude_procs.any? { |p| p.call(fn) }
+ end
+
+ DEFAULT_IGNORE_PATTERNS = [
+ /(^|[\/\\])CVS([\/\\]|$)/,
+ /(^|[\/\\])\.svn([\/\\]|$)/,
+ /\.bak$/,
+ /~$/
+ ]
+ DEFAULT_IGNORE_PROCS = [
+ proc { |fn| fn =~ /(^|[\/\\])core$/ && ! File.directory?(fn) }
+ ]
+
+ def import(array)
+ @items = array
+ self
+ end
+
+ class << self
+ # Create a new file list including the files listed. Similar to:
+ #
+ # FileList.new(*args)
+ def [](*args)
+ new(*args)
+ end
+ end
+ end
+end
+
+module Rake
+ class << self
+
+ # Yield each file or directory component.
+ def each_dir_parent(dir) # :nodoc:
+ old_length = nil
+ while dir != '.' && dir.length != old_length
+ yield(dir)
+ old_length = dir.length
+ dir = File.dirname(dir)
+ end
+ end
+ end
+end # module Rake
Added: MacRuby/trunk/test/libs/rake/lib/rake/file_task.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/file_task.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/file_task.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,47 @@
+require 'rake/task.rb'
+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
+ # supplied actions).
+ #
+ 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)
+ end
+
+ # Time stamp for file task.
+ def timestamp
+ if File.exist?(name)
+ File.mtime(name.to_s)
+ else
+ Rake::EARLY
+ end
+ end
+
+ private
+
+ # 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}
+ end
+
+ # ----------------------------------------------------------------
+ # Task class methods.
+ #
+ 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
+ end
+ end
+ end
+end
+
Added: MacRuby/trunk/test/libs/rake/lib/rake/file_utils.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/file_utils.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/file_utils.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,108 @@
+# ###########################################################################
+# This a FileUtils extension that defines several additional commands to be
+# added to the FileUtils utility functions.
+#
+module FileUtils
+ RUBY = File.join(
+ Config::CONFIG['bindir'],
+ Config::CONFIG['ruby_install_name'] + Config::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
+ # Kernel::system).
+ #
+ # Example:
+ # sh %{ls -ltr}
+ #
+ # sh 'ls', 'file with spaces'
+ #
+ # # check exit status after command runs
+ # sh %{grep pattern file} do |ok, res|
+ # if ! ok
+ # puts "pattern not found (status = #{res.exitstatus})"
+ # end
+ # end
+ #
+ 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] ||= RakeFileUtils.nowrite_flag
+ rake_check_options options, :noop, :verbose
+ rake_output_message cmd.join(" ") if options[:verbose]
+ unless options[:noop]
+ res = rake_system(*cmd)
+ status = $?
+ status = PseudoStatus.new(1) if !res && status.nil?
+ shell_runner.call(res, status)
+ end
+ end
+
+ def create_shell_runner(cmd)
+ show_command = cmd.join(" ")
+ show_command = show_command[0,42] + "..." unless $trace
+ block = lambda { |ok, status|
+ ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
+ }
+ end
+ private :create_shell_runner
+
+ def set_verbose_option(options)
+ if options[:verbose].nil?
+ options[:verbose] = RakeFileUtils.verbose_flag.nil? || RakeFileUtils.verbose_flag
+ end
+ end
+ private :set_verbose_option
+
+ def rake_system(*cmd)
+ Rake::AltSystem.system(*cmd)
+ end
+ private :rake_system
+
+ # Run a Ruby interpreter with the given arguments.
+ #
+ # Example:
+ # ruby %{-pe '$_.upcase!' <README}
+ #
+ def ruby(*args,&block)
+ options = (Hash === args.last) ? args.pop : {}
+ if args.length > 1 then
+ sh(*([RUBY] + args + [options]), &block)
+ else
+ sh("#{RUBY} #{args.first}", options, &block)
+ end
+ end
+
+ LN_SUPPORTED = [true]
+
+ # Attempt to do a normal file link, but fall back to a copy if the link
+ # fails.
+ def safe_ln(*args)
+ unless LN_SUPPORTED[0]
+ cp(*args)
+ else
+ begin
+ ln(*args)
+ rescue StandardError, NotImplementedError => ex
+ LN_SUPPORTED[0] = false
+ cp(*args)
+ end
+ end
+ end
+
+ # Split a file path into individual directory names.
+ #
+ # Example:
+ # split_all("a/b/c") => ['a', 'b', 'c']
+ #
+ def split_all(path)
+ head, tail = File.split(path)
+ return [tail] if head == '.' || tail == '/'
+ return [head, tail] if head == '/'
+ return split_all(head) + [tail]
+ end
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/gempackagetask.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/gempackagetask.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/gempackagetask.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,97 @@
+#!/usr/bin/env ruby
+
+# Define a package task library to aid in the definition of GEM
+# packages.
+
+require 'rubygems'
+require 'rake'
+require 'rake/packagetask'
+require 'rubygems/user_interaction'
+require 'rubygems/builder'
+
+module Rake
+
+ # Create a package based upon a Gem spec. Gem packages, as well as
+ # zip files and tar/gzipped packages can be produced by this task.
+ #
+ # In addition to the Rake targets generated by PackageTask, a
+ # GemPackageTask will also generate the following tasks:
+ #
+ # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.gem"</b>]
+ # Create a Ruby GEM package with the given name and version.
+ #
+ # Example using a Ruby GEM spec:
+ #
+ # require 'rubygems'
+ #
+ # spec = Gem::Specification.new do |s|
+ # s.platform = Gem::Platform::RUBY
+ # s.summary = "Ruby based make-like utility."
+ # s.name = 'rake'
+ # s.version = PKG_VERSION
+ # s.requirements << 'none'
+ # s.require_path = 'lib'
+ # s.autorequire = 'rake'
+ # s.files = PKG_FILES
+ # s.description = <<EOF
+ # Rake is a Make-like program implemented in Ruby. Tasks
+ # and dependencies are specified in standard Ruby syntax.
+ # EOF
+ # end
+ #
+ # Rake::GemPackageTask.new(spec) do |pkg|
+ # pkg.need_zip = true
+ # pkg.need_tar = true
+ # end
+ #
+ class GemPackageTask < PackageTask
+ # Ruby GEM spec containing the metadata for this package. The
+ # name, version and package_files are automatically determined
+ # from the GEM spec and don't need to be explicitly provided.
+ attr_accessor :gem_spec
+
+ # Create a GEM Package task library. Automatically define the gem
+ # if a block is given. If no block is supplied, then +define+
+ # needs to be called to define the task.
+ def initialize(gem_spec)
+ init(gem_spec)
+ yield self if block_given?
+ define if block_given?
+ end
+
+ # Initialization tasks without the "yield self" or define
+ # operations.
+ def init(gem)
+ super(gem.name, gem.version)
+ @gem_spec = gem
+ @package_files += gem_spec.files if gem_spec.files
+ end
+
+ # Create the Rake tasks and actions specified by this
+ # GemPackageTask. (+define+ is automatically called if a block is
+ # given to +new+).
+ def define
+ super
+ task :package => [:gem]
+ desc "Build the gem file #{gem_file}"
+ task :gem => ["#{package_dir}/#{gem_file}"]
+ file "#{package_dir}/#{gem_file}" => [package_dir] + @gem_spec.files do
+ when_writing("Creating GEM") {
+ Gem::Builder.new(gem_spec).build
+ verbose(true) {
+ mv gem_file, "#{package_dir}/#{gem_file}"
+ }
+ }
+ end
+ end
+
+ def gem_file
+ if @gem_spec.platform == Gem::Platform::RUBY
+ "#{package_name}.gem"
+ else
+ "#{package_name}-#{@gem_spec.platform}.gem"
+ end
+ end
+
+ end
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/invocation_chain.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/invocation_chain.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/invocation_chain.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,51 @@
+module Rake
+
+ ####################################################################
+ # InvocationChain tracks the chain of task invocations to detect
+ # circular dependencies.
+ class InvocationChain
+ def initialize(value, tail)
+ @value = value
+ @tail = tail
+ end
+
+ def member?(obj)
+ @value == obj || @tail.member?(obj)
+ end
+
+ def append(value)
+ if member?(value)
+ fail RuntimeError, "Circular dependency detected: #{to_s} => #{value}"
+ end
+ self.class.new(value, self)
+ end
+
+ def to_s
+ "#{prefix}#{@value}"
+ end
+
+ def self.append(value, chain)
+ chain.append(value)
+ end
+
+ private
+
+ def prefix
+ "#{@tail.to_s} => "
+ end
+
+ class EmptyInvocationChain
+ def member?(obj)
+ false
+ end
+ def append(value)
+ InvocationChain.new(value, self)
+ end
+ def to_s
+ "TOP"
+ end
+ end
+
+ EMPTY = EmptyInvocationChain.new
+ end
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/invocation_exception_mixin.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/invocation_exception_mixin.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/invocation_exception_mixin.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,16 @@
+module Rake
+ module InvocationExceptionMixin
+ # Return the invocation chain (list of Rake tasks) that were in
+ # effect when this execption was detected by rake. May be null if
+ # no tasks were active.
+ def chain
+ @rake_invocation_chain ||= nil
+ end
+
+ # Set the invocation chain in effect when this exception was
+ # detected.
+ def chain=(value)
+ @rake_invocation_chain = value
+ end
+ end
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/lib/project.rake
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/lib/project.rake (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/lib/project.rake 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+# -*- ruby -*-
+
+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
Added: MacRuby/trunk/test/libs/rake/lib/rake/loaders/makefile.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/loaders/makefile.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/loaders/makefile.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,44 @@
+#!/usr/bin/env ruby
+
+module Rake
+
+ # Makefile loader to be used with the import file loader.
+ class MakefileLoader
+ include Rake::DSL
+
+ SPACE_MARK = "__&NBSP;__"
+
+ # Load the makefile dependencies in +fn+.
+ def load(fn)
+ open(fn) do |mf|
+ lines = mf.read
+ lines.gsub!(/\\ /, SPACE_MARK)
+ lines.gsub!(/#[^\n]*\n/m, "")
+ lines.gsub!(/\\\n/, ' ')
+ lines.split("\n").each do |line|
+ process_line(line)
+ end
+ end
+ end
+
+ private
+
+ # Process one logical line of makefile data.
+ def process_line(line)
+ file_tasks, args = line.split(':')
+ return if args.nil?
+ dependents = args.split.map { |d| respace(d) }
+ file_tasks.strip.split.each do |file_task|
+ file_task = respace(file_task)
+ file file_task => dependents
+ end
+ end
+
+ def respace(str)
+ str.gsub(/#{SPACE_MARK}/, ' ')
+ end
+ end
+
+ # Install the handler
+ Rake.application.add_loader('mf', MakefileLoader.new)
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/multi_task.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/multi_task.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/multi_task.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,16 @@
+module Rake
+
+ # Same as a regular task, but the immediate prerequisites are done in
+ # parallel using Ruby threads.
+ #
+ class MultiTask < Task
+ private
+ def invoke_prerequisites(args, invocation_chain)
+ threads = @prerequisites.collect { |p|
+ Thread.new(p) { |r| application[r, @scope].invoke_with_call_chain(args, invocation_chain) }
+ }
+ threads.each { |t| t.join }
+ end
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/name_space.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/name_space.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/name_space.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,25 @@
+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
+ end
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/packagetask.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/packagetask.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/packagetask.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,184 @@
+#!/usr/bin/env ruby
+
+# Define a package task libarary to aid in the definition of
+# redistributable package files.
+
+require 'rake'
+require 'rake/tasklib'
+
+module Rake
+
+ # Create a packaging task that will package the project into
+ # distributable files (e.g zip archive or tar files).
+ #
+ # The PackageTask will create the following targets:
+ #
+ # [<b>:package</b>]
+ # Create all the requested package files.
+ #
+ # [<b>:clobber_package</b>]
+ # Delete all the package files. This target is automatically
+ # added to the main clobber target.
+ #
+ # [<b>:repackage</b>]
+ # Rebuild the package files from scratch, even if they are not out
+ # of date.
+ #
+ # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tgz"</b>]
+ # Create a gzipped tar package (if <em>need_tar</em> is true).
+ #
+ # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.gz"</b>]
+ # Create a gzipped tar package (if <em>need_tar_gz</em> is true).
+ #
+ # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.bz2"</b>]
+ # Create a bzip2'd tar package (if <em>need_tar_bz2</em> is true).
+ #
+ # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.zip"</b>]
+ # Create a zip package archive (if <em>need_zip</em> is true).
+ #
+ # Example:
+ #
+ # Rake::PackageTask.new("rake", "1.2.3") do |p|
+ # p.need_tar = true
+ # p.package_files.include("lib/**/*.rb")
+ # end
+ #
+ class PackageTask < TaskLib
+ # Name of the package (from the GEM Spec).
+ attr_accessor :name
+
+ # Version of the package (e.g. '1.3.2').
+ attr_accessor :version
+
+ # Directory used to store the package files (default is 'pkg').
+ attr_accessor :package_dir
+
+ # True if a gzipped tar file (tgz) should be produced (default is false).
+ attr_accessor :need_tar
+
+ # True if a gzipped tar file (tar.gz) should be produced (default is false).
+ attr_accessor :need_tar_gz
+
+ # True if a bzip2'd tar file (tar.bz2) should be produced (default is false).
+ attr_accessor :need_tar_bz2
+
+ # True if a zip file should be produced (default is false)
+ attr_accessor :need_zip
+
+ # List of files to be included in the package.
+ attr_accessor :package_files
+
+ # Tar command for gzipped or bzip2ed archives. The default is 'tar'.
+ attr_accessor :tar_command
+
+ # Zip command for zipped archives. The default is 'zip'.
+ attr_accessor :zip_command
+
+ # Create a Package Task with the given name and version.
+ def initialize(name=nil, version=nil)
+ init(name, version)
+ yield self if block_given?
+ define unless name.nil?
+ end
+
+ # Initialization that bypasses the "yield self" and "define" step.
+ def init(name, version)
+ @name = name
+ @version = version
+ @package_files = Rake::FileList.new
+ @package_dir = 'pkg'
+ @need_tar = false
+ @need_tar_gz = false
+ @need_tar_bz2 = false
+ @need_zip = false
+ @tar_command = 'tar'
+ @zip_command = 'zip'
+ end
+
+ # Create the tasks defined by this task library.
+ def define
+ fail "Version required (or :noversion)" if @version.nil?
+ @version = nil if :noversion == @version
+
+ desc "Build all the packages"
+ task :package
+
+ desc "Force a rebuild of the package files"
+ task :repackage => [:clobber_package, :package]
+
+ desc "Remove package products"
+ task :clobber_package do
+ rm_r package_dir rescue nil
+ end
+
+ 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)|
+ if need
+ 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
+ end
+ end
+ end
+
+ if need_zip
+ 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
+ end
+ end
+
+ directory package_dir
+
+ file package_dir_path => @package_files do
+ mkdir_p package_dir rescue nil
+ @package_files.each do |fn|
+ f = File.join(package_dir_path, fn)
+ fdir = File.dirname(f)
+ mkdir_p(fdir) if !File.exist?(fdir)
+ if File.directory?(fn)
+ mkdir_p(f)
+ else
+ rm_f f
+ safe_ln(fn, f)
+ end
+ end
+ end
+ self
+ end
+
+ def package_name
+ @version ? "#{@name}-#{@version}" : @name
+ end
+
+ def package_dir_path
+ "#{package_dir}/#{package_name}"
+ end
+
+ def tgz_file
+ "#{package_name}.tgz"
+ end
+
+ def tar_gz_file
+ "#{package_name}.tar.gz"
+ end
+
+ def tar_bz2_file
+ "#{package_name}.tar.bz2"
+ end
+
+ def zip_file
+ "#{package_name}.zip"
+ end
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/psuedo_status.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/psuedo_status.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/psuedo_status.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,24 @@
+module Rake
+
+ ####################################################################
+ # Exit status class for times the system just gives us a nil.
+ class PseudoStatus
+ attr_reader :exitstatus
+ def initialize(code=0)
+ @exitstatus = code
+ end
+ def to_i
+ @exitstatus << 8
+ end
+ def >>(n)
+ to_i >> n
+ end
+ def stopped?
+ false
+ end
+ def exited?
+ true
+ end
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/rake_file_utils.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/rake_file_utils.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/rake_file_utils.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,133 @@
+require 'rake/file_utils'
+
+# ###########################################################################
+# RakeFileUtils provides a custom version of the FileUtils methods that
+# respond to the <tt>verbose</tt> and <tt>nowrite</tt> commands.
+#
+module RakeFileUtils
+ include FileUtils
+
+ class << self
+ attr_accessor :verbose_flag, :nowrite_flag
+ end
+ RakeFileUtils.verbose_flag = nil
+ RakeFileUtils.nowrite_flag = false
+
+ $fileutils_verbose = true
+ $fileutils_nowrite = false
+
+ FileUtils::OPT_TABLE.each do |name, opts|
+ default_options = []
+ if opts.include?(:verbose) || opts.include?("verbose")
+ default_options << ':verbose => RakeFileUtils.verbose_flag'
+ end
+ if opts.include?(:noop) || opts.include?("noop")
+ default_options << ':noop => RakeFileUtils.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)
+ end
+ EOS
+ end
+
+ # Get/set the verbose flag controlling output from the FileUtils utilities.
+ # If verbose is true, then the utility method is echoed to standard output.
+ #
+ # Examples:
+ # verbose # return the current value of the verbose flag
+ # verbose(v) # set the verbose flag to _v_.
+ # verbose(v) { code } # Execute code with the verbose flag set temporarily to _v_.
+ # # Return to the original value when code is done.
+ def verbose(value=nil)
+ oldvalue = RakeFileUtils.verbose_flag
+ RakeFileUtils.verbose_flag = value unless value.nil?
+ if block_given?
+ begin
+ yield
+ ensure
+ RakeFileUtils.verbose_flag = oldvalue
+ end
+ end
+ RakeFileUtils.verbose_flag
+ end
+
+ # Get/set the nowrite flag controlling output from the FileUtils utilities.
+ # If verbose is true, then the utility method is echoed to standard output.
+ #
+ # Examples:
+ # nowrite # return the current value of the nowrite flag
+ # nowrite(v) # set the nowrite flag to _v_.
+ # nowrite(v) { code } # Execute code with the nowrite flag set temporarily to _v_.
+ # # Return to the original value when code is done.
+ def nowrite(value=nil)
+ oldvalue = RakeFileUtils.nowrite_flag
+ RakeFileUtils.nowrite_flag = value unless value.nil?
+ if block_given?
+ begin
+ yield
+ ensure
+ RakeFileUtils.nowrite_flag = oldvalue
+ end
+ end
+ oldvalue
+ end
+
+ # Use this function to prevent protentially destructive ruby code from
+ # running when the :nowrite flag is set.
+ #
+ # Example:
+ #
+ # when_writing("Building Project") do
+ # project.build
+ # end
+ #
+ # The following code will build the project under normal conditions. If the
+ # nowrite(true) flag is set, then the example will print:
+ # DRYRUN: Building Project
+ # instead of actually building the project.
+ #
+ def when_writing(msg=nil)
+ if RakeFileUtils.nowrite_flag
+ puts "DRYRUN: #{msg}" if msg
+ else
+ yield
+ 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
+ private :rake_merge_option
+
+ # Send the message to the default rake output (which is $stderr).
+ def rake_output_message(message)
+ $stderr.puts(message)
+ end
+ private :rake_output_message
+
+ # Check that the options do not contain options not listed in +optdecl+. An
+ # ArgumentError exception is thrown if non-declared options are found.
+ def rake_check_options(options, *optdecl)
+ h = options.dup
+ optdecl.each do |name|
+ h.delete name
+ end
+ raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty?
+ end
+ private :rake_check_options
+
+ extend self
+end
+
Added: MacRuby/trunk/test/libs/rake/lib/rake/rake_module.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/rake_module.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/rake_module.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,25 @@
+require 'rake/application'
+
+module Rake
+
+ # Rake module singleton methods.
+ #
+ class << self
+ # Current Rake Application
+ def application
+ @application ||= Rake::Application.new
+ end
+
+ # Set the current Rake application object.
+ def application=(app)
+ @application = app
+ end
+
+ # Return the original directory where the Rake application was started.
+ def original_dir
+ application.original_dir
+ end
+
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/rake_test_loader.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/rake_test_loader.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/rake_test_loader.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+require 'rake'
+
+# Load the test files from the command line.
+
+ARGV.each do |f|
+ next if f =~ /^-/
+
+ if f =~ /\*/
+ FileList[f].to_a.each { |f| load f }
+ else
+ load f
+ end
+end
+
Added: MacRuby/trunk/test/libs/rake/lib/rake/rdoctask.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/rdoctask.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/rdoctask.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,209 @@
+#!/usr/bin/env ruby
+
+require 'rake'
+require 'rake/tasklib'
+
+module Rake
+
+ # Create a documentation task that will generate the RDoc files for
+ # a project.
+ #
+ # The RDocTask will create the following targets:
+ #
+ # [<b><em>rdoc</em></b>]
+ # Main task for this RDOC task.
+ #
+ # [<b>:clobber_<em>rdoc</em></b>]
+ # Delete all the rdoc files. This target is automatically
+ # added to the main clobber target.
+ #
+ # [<b>:re<em>rdoc</em></b>]
+ # Rebuild the rdoc files from scratch, even if they are not out
+ # of date.
+ #
+ # Simple Example:
+ #
+ # Rake::RDocTask.new do |rd|
+ # rd.main = "README.rdoc"
+ # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
+ # end
+ #
+ # The +rd+ object passed to the block is an RDocTask object. See the
+ # attributes list for the RDocTask class for available customization options.
+ #
+ # == Specifying different task names
+ #
+ # You may wish to give the task a different name, such as if you are
+ # generating two sets of documentation. For instance, if you want to have a
+ # development set of documentation including private methods:
+ #
+ # Rake::RDocTask.new(:rdoc_dev) do |rd|
+ # rd.main = "README.doc"
+ # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
+ # rd.options << "--all"
+ # end
+ #
+ # The tasks would then be named :<em>rdoc_dev</em>, :clobber_<em>rdoc_dev</em>, and
+ # :re<em>rdoc_dev</em>.
+ #
+ # If you wish to have completely different task names, then pass a Hash as
+ # first argument. With the <tt>:rdoc</tt>, <tt>:clobber_rdoc</tt> and
+ # <tt>:rerdoc</tt> options, you can customize the task names to your liking.
+ # For example:
+ #
+ # Rake::RDocTask.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force")
+ #
+ # This will create the tasks <tt>:rdoc</tt>, <tt>:rdoc_clean</tt> and
+ # <tt>:rdoc:force</tt>.
+ #
+ class RDocTask < TaskLib
+ # Name of the main, top level task. (default is :rdoc)
+ attr_accessor :name
+
+ # Name of directory to receive the html output files. (default is "html")
+ attr_accessor :rdoc_dir
+
+ # Title of RDoc documentation. (defaults to rdoc's default)
+ attr_accessor :title
+
+ # Name of file to be used as the main, top level file of the
+ # RDoc. (default is none)
+ attr_accessor :main
+
+ # Name of template to be used by rdoc. (defaults to rdoc's default)
+ attr_accessor :template
+
+ # List of files to be included in the rdoc generation. (default is [])
+ attr_accessor :rdoc_files
+
+ # Additional list of options to be passed rdoc. (default is [])
+ attr_accessor :options
+
+ # Whether to run the rdoc process as an external shell (default is false)
+ attr_accessor :external
+
+ attr_accessor :inline_source
+
+ # Create an RDoc task with the given name. See the RDocTask class overview
+ # for documentation.
+ def initialize(name = :rdoc) # :yield: self
+ if name.is_a?(Hash)
+ invalid_options = name.keys.map { |k| k.to_sym } - [:rdoc, :clobber_rdoc, :rerdoc]
+ if !invalid_options.empty?
+ raise ArgumentError, "Invalid option(s) passed to RDocTask.new: #{invalid_options.join(", ")}"
+ end
+ end
+
+ @name = name
+ @rdoc_files = Rake::FileList.new
+ @rdoc_dir = 'html'
+ @main = nil
+ @title = nil
+ @template = nil
+ @external = false
+ @inline_source = true
+ @options = []
+ yield self if block_given?
+ define
+ end
+
+ # Create the tasks defined by this task lib.
+ def define
+ if rdoc_task_name != "rdoc"
+ desc "Build the RDOC HTML Files"
+ else
+ desc "Build the #{rdoc_task_name} HTML Files"
+ end
+ task rdoc_task_name
+
+ desc "Force a rebuild of the RDOC files"
+ task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
+
+ desc "Remove rdoc products"
+ task clobber_task_name do
+ rm_r rdoc_dir rescue nil
+ end
+
+ task :clobber => [clobber_task_name]
+
+ directory @rdoc_dir
+ task rdoc_task_name => [rdoc_target]
+ file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
+ rm_r @rdoc_dir rescue nil
+ @before_running_rdoc.call if @before_running_rdoc
+ args = option_list + @rdoc_files
+ if @external
+ argstring = args.join(' ')
+ sh %{ruby -Ivendor vendor/rd #{argstring}}
+ else
+ require 'rdoc/rdoc'
+ RDoc::RDoc.new.document(args)
+ end
+ end
+ self
+ end
+
+ def option_list
+ result = @options.dup
+ result << "-o" << @rdoc_dir
+ result << "--main" << quote(main) if main
+ result << "--title" << quote(title) if title
+ result << "-T" << quote(template) if template
+ result << "--inline-source" if inline_source && !@options.include?("--inline-source") && !@options.include?("-S")
+ result
+ end
+
+ def quote(str)
+ if @external
+ "'#{str}'"
+ else
+ str
+ end
+ end
+
+ def option_string
+ option_list.join(' ')
+ end
+
+ # The block passed to this method will be called just before running the
+ # RDoc generator. It is allowed to modify RDocTask attributes inside the
+ # block.
+ def before_running_rdoc(&block)
+ @before_running_rdoc = block
+ end
+
+ private
+
+ def rdoc_target
+ "#{rdoc_dir}/index.html"
+ end
+
+ def rdoc_task_name
+ case name
+ when Hash
+ (name[:rdoc] || "rdoc").to_s
+ else
+ name.to_s
+ end
+ end
+
+ def clobber_task_name
+ case name
+ when Hash
+ (name[:clobber_rdoc] || "clobber_rdoc").to_s
+ else
+ "clobber_#{name}"
+ end
+ end
+
+ def rerdoc_task_name
+ case name
+ when Hash
+ (name[:rerdoc] || "rerdoc").to_s
+ else
+ "re#{name}"
+ end
+ end
+
+ end
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/ruby182_test_unit_fix.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/ruby182_test_unit_fix.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/ruby182_test_unit_fix.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,25 @@
+# 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{|t| add_suite(suites, t.suite)}
+ ensure
+ $:.delete_at $:.rindex(dir)
+ end
+ end
+ end
+ end
+end
Property changes on: MacRuby/trunk/test/libs/rake/lib/rake/ruby182_test_unit_fix.rb
___________________________________________________________________
Added: svn:executable
+ *
Added: MacRuby/trunk/test/libs/rake/lib/rake/rule_recursion_overflow_error.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/rule_recursion_overflow_error.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/rule_recursion_overflow_error.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,20 @@
+
+module Rake
+
+ # Error indicating a recursion overflow error in task selection.
+ class RuleRecursionOverflowError < StandardError
+ def initialize(*args)
+ super
+ @targets = []
+ end
+
+ def add_target(target)
+ @targets << target
+ end
+
+ def message
+ super + ": [" + @targets.reverse.join(' => ') + "]"
+ end
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/runtest.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/runtest.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/runtest.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'test/unit/assertions'
+
+module Rake
+ include Test::Unit::Assertions
+
+ def run_tests(pattern='test/test*.rb', log_enabled=false)
+ Dir["#{pattern}"].each { |fn|
+ puts fn if log_enabled
+ begin
+ load fn
+ rescue Exception => ex
+ puts "Error in #{fn}: #{ex.message}"
+ puts ex.backtrace
+ assert false
+ end
+ }
+ end
+
+ extend self
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/task.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/task.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/task.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,318 @@
+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
+ # opportunity to run and then it will execute its own actions.
+ #
+ # Tasks are not usually created directly using the new method, but rather
+ # use the +file+ and +task+ convenience methods.
+ #
+ class Task
+ # List of prerequisites for a task.
+ attr_reader :prerequisites
+
+ # List of actions attached to a task.
+ attr_reader :actions
+
+ # Application owning this task.
+ attr_accessor :application
+
+ # Comment for this task. Restricted to a single line of no more than 50
+ # characters.
+ attr_reader :comment
+
+ # Full text of the (possibly multi-line) comment.
+ attr_reader :full_comment
+
+ # Array of nested namespaces names used for task lookup by this task.
+ attr_reader :scope
+
+ # File/Line locations of each of the task definitions for this
+ # task (only valid if the task was defined with the detect
+ # location option set).
+ attr_reader :locations
+
+ # Return task name
+ def to_s
+ name
+ end
+
+ def inspect
+ "<#{self.class} #{name} => [#{prerequisites.join(', ')}]>"
+ end
+
+ # List of sources for task.
+ attr_writer :sources
+ def sources
+ @sources ||= []
+ end
+
+ # First source from a rule (nil if no sources)
+ def source
+ @sources.first if defined?(@sources)
+ end
+
+ # Create a task named +task_name+ with no actions or prerequisites. Use
+ # +enhance+ to add actions and prerequisites.
+ def initialize(task_name, app)
+ @name = task_name.to_s
+ @prerequisites = []
+ @actions = []
+ @already_invoked = false
+ @full_comment = nil
+ @comment = nil
+ @lock = Monitor.new
+ @application = app
+ @scope = app.current_scope
+ @arg_names = nil
+ @locations = []
+ end
+
+ # Enhance a task with prerequisites or actions. Returns self.
+ def enhance(deps=nil, &block)
+ @prerequisites |= deps if deps
+ @actions << block if block_given?
+ self
+ end
+
+ # Name of the task, including any namespace qualifiers.
+ def name
+ @name.to_s
+ end
+
+ # Name of task with argument list description.
+ def name_with_args # :nodoc:
+ if arg_description
+ "#{name}#{arg_description}"
+ else
+ name
+ end
+ end
+
+ # Argument description (nil if none).
+ def arg_description # :nodoc:
+ @arg_names ? "[#{(arg_names || []).join(',')}]" : nil
+ end
+
+ # Name of arguments for this task.
+ def arg_names
+ @arg_names || []
+ end
+
+ # Reenable the task, allowing its tasks to be executed if the task
+ # is invoked again.
+ def reenable
+ @already_invoked = false
+ end
+
+ # Clear the existing prerequisites and actions of a rake task.
+ def clear
+ clear_prerequisites
+ clear_actions
+ self
+ end
+
+ # Clear the existing prerequisites of a rake task.
+ def clear_prerequisites
+ prerequisites.clear
+ self
+ end
+
+ # Clear the existing actions on a rake task.
+ def clear_actions
+ actions.clear
+ self
+ end
+
+ # Invoke the task if it is needed. Prerequites are invoked first.
+ def invoke(*args)
+ task_args = TaskArguments.new(arg_names, args)
+ invoke_with_call_chain(task_args, InvocationChain::EMPTY)
+ end
+
+ # 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)
+ @lock.synchronize do
+ if application.options.trace
+ puts "** Invoke #{name} #{format_trace_flags}"
+ 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)
+ exception.extend(InvocationExceptionMixin) unless exception.respond_to?(:chain)
+ exception.chain = new_chain if exception.chain.nil?
+ end
+ private :add_chain_to
+
+ # Invoke all the prerequisites of a task.
+ def invoke_prerequisites(task_args, invocation_chain) # :nodoc:
+ @prerequisites.each { |n|
+ prereq = application[n, @scope]
+ prereq_args = task_args.new_scope(prereq.arg_names)
+ prereq.invoke_with_call_chain(prereq_args, invocation_chain)
+ }
+ end
+
+ # Format the trace flags for display.
+ def format_trace_flags
+ flags = []
+ flags << "first_time" unless @already_invoked
+ flags << "not_needed" unless needed?
+ flags.empty? ? "" : "(" + flags.join(", ") + ")"
+ end
+ private :format_trace_flags
+
+ # Execute the actions associated with this task.
+ def execute(args=nil)
+ args ||= EMPTY_TASK_ARGS
+ if application.options.dryrun
+ puts "** Execute (dry run) #{name}"
+ return
+ end
+ if application.options.trace
+ puts "** Execute #{name}"
+ end
+ 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
+ end
+ end
+
+ # Is this task needed?
+ def needed?
+ true
+ end
+
+ # Timestamp for this task. Basic tasks return the current time for their
+ # time stamp. Other tasks can be more sophisticated.
+ def timestamp
+ @prerequisites.collect { |p| application[p, @scope].timestamp }.max || Time.now
+ end
+
+ # Add a description to the task. The description can consist of an option
+ # argument list (enclosed brackets) and an optional comment.
+ def add_description(description)
+ return if ! description
+ comment = description.strip
+ add_comment(comment) if comment && ! comment.empty?
+ end
+
+ # Writing to the comment attribute is the same as adding a description.
+ def comment=(description)
+ add_description(description)
+ end
+
+ # Add a comment to the task. If a comment alread exists, separate
+ # the new comment with " / ".
+ def add_comment(comment)
+ if @full_comment
+ @full_comment << " / "
+ else
+ @full_comment = ''
+ end
+ @full_comment << comment
+ if @full_comment =~ /\A([^.]+?\.)( |$)/
+ @comment = $1
+ else
+ @comment = @full_comment
+ end
+ end
+ private :add_comment
+
+ # 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 }
+ end
+
+ # Return a string describing the internal state of a task. Useful for
+ # debugging.
+ def investigation
+ result = "------------------------------\n"
+ result << "Investigating #{name}\n"
+ result << "class: #{self.class}\n"
+ result << "task needed: #{needed?}\n"
+ result << "timestamp: #{timestamp}\n"
+ result << "pre-requisites: \n"
+ prereqs = @prerequisites.collect {|name| application[name, @scope]}
+ prereqs.sort! {|a,b| a.timestamp <=> b.timestamp}
+ prereqs.each do |p|
+ result << "--#{p.name} (#{p.timestamp})\n"
+ end
+ latest_prereq = @prerequisites.collect{|n| application[n, @scope].timestamp}.max
+ result << "latest-prerequisite time: #{latest_prereq}\n"
+ result << "................................\n\n"
+ return result
+ end
+
+ # ----------------------------------------------------------------
+ # Rake Module Methods
+ #
+ class << self
+
+ # Clear the task list. This cause rake to immediately forget all the
+ # tasks that have been assigned. (Normally used in the unit tests.)
+ def clear
+ Rake.application.clear
+ end
+
+ # List of all defined tasks.
+ def tasks
+ Rake.application.tasks
+ end
+
+ # Return a task with the given name. If the task is not currently
+ # known, try to synthesize one from the defined rules. If no rules are
+ # found, but an existing file matches the task name, assume it is a file
+ # task with no dependencies or actions.
+ def [](task_name)
+ Rake.application[task_name]
+ end
+
+ # TRUE if the task name is already defined.
+ def task_defined?(task_name)
+ Rake.application.lookup(task_name) != nil
+ end
+
+ # Define a task given +args+ and an option block. If a rule with the
+ # given name already exists, the prerequisites and actions are added to
+ # the existing task. Returns the defined task.
+ def define_task(*args, &block)
+ Rake.application.define_task(self, *args, &block)
+ end
+
+ # Define a rule for synthesizing tasks.
+ def create_rule(*args, &block)
+ Rake.application.create_rule(*args, &block)
+ end
+
+ # Apply the scope to the task name according to the rules for
+ # 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(':')
+ end
+
+ end # class << Rake::Task
+ end # class Rake::Task
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/task_argument_error.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/task_argument_error.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/task_argument_error.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,7 @@
+module Rake
+
+ # Error indicating an ill-formed task declaration.
+ class TaskArgumentError < ArgumentError
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/task_arguments.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/task_arguments.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/task_arguments.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,78 @@
+module Rake
+
+ ####################################################################
+ # TaskAguments manage the arguments passed to a task.
+ #
+ class TaskArguments
+ include Enumerable
+
+ 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.
+ def initialize(names, values, parent=nil)
+ @names = names
+ @parent = parent
+ @hash = {}
+ names.each_with_index { |name, i|
+ @hash[name.to_sym] = values[i] unless values[i].nil?
+ }
+ end
+
+ # Create a new argument scope using the prerequisite argument
+ # names.
+ def new_scope(names)
+ values = names.collect { |n| self[n] }
+ self.class.new(names, values, self)
+ end
+
+ # Find an argument value by name or index.
+ def [](index)
+ lookup(index.to_sym)
+ end
+
+ # Specify a hash of default values for task arguments. Use the
+ # defaults only if there is no specific value for the given
+ # argument.
+ def with_defaults(defaults)
+ @hash = defaults.merge(@hash)
+ end
+
+ def each(&block)
+ @hash.each(&block)
+ end
+
+ def method_missing(sym, *args, &block)
+ lookup(sym.to_sym)
+ end
+
+ def to_hash
+ @hash
+ end
+
+ def to_s
+ @hash.inspect
+ end
+
+ def inspect
+ to_s
+ end
+
+ protected
+
+ def lookup(name)
+ if @hash.has_key?(name)
+ @hash[name]
+ elsif ENV.has_key?(name.to_s)
+ ENV[name.to_s]
+ elsif ENV.has_key?(name.to_s.upcase)
+ ENV[name.to_s.upcase]
+ elsif @parent
+ @parent.lookup(name)
+ end
+ end
+ end
+
+ EMPTY_TASK_ARGS = TaskArguments.new([], [])
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/task_manager.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/task_manager.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/task_manager.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,328 @@
+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
+ super
+ @tasks = Hash.new
+ @rules = Array.new
+ @scope = Array.new
+ @last_description = nil
+ end
+
+ def create_rule(*args, &block)
+ pattern, arg_names, deps = resolve_args(args)
+ pattern = Regexp.new(Regexp.quote(pattern) + '$') if String === pattern
+ @rules << [pattern, deps, block]
+ end
+
+ def define_task(task_class, *args, &block)
+ task_name, arg_names, deps = resolve_args(args)
+ task_name = task_class.scope_name(@scope, task_name)
+ deps = [deps] unless deps.respond_to?(:to_ary)
+ deps = deps.collect {|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)
+ end
+
+ # Lookup a task. Return an existing task if found, otherwise
+ # create a task of the current type.
+ def intern(task_class, task_name)
+ @tasks[task_name.to_s] ||= task_class.new(task_name, self)
+ end
+
+ # Find a matching task for +task_name+.
+ def [](task_name, scopes=nil)
+ task_name = task_name.to_s
+ 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}'"
+ end
+
+ def synthesize_file_task(task_name)
+ 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].
+ def resolve_args(args)
+ if args.last.is_a?(Hash)
+ deps = args.pop
+ resolve_args_with_dependencies(args, deps)
+ else
+ resolve_args_without_dependencies(args)
+ end
+ end
+
+ # Resolve task arguments for a task or rule when there are no
+ # dependencies declared.
+ #
+ # The patterns recognized by this argument resolving function are:
+ #
+ # task :t
+ # task :t, [:a]
+ # task :t, :a (deprecated)
+ #
+ def resolve_args_without_dependencies(args)
+ task_name = args.shift
+ if args.size == 1 && args.first.respond_to?(:to_ary)
+ arg_names = args.first.to_ary
+ else
+ arg_names = args
+ end
+ [task_name, arg_names, []]
+ end
+ private :resolve_args_without_dependencies
+
+ # Resolve task arguments for a task or rule when there are
+ # dependencies declared.
+ #
+ # The patterns recognized by this argument resolving function are:
+ #
+ # task :t => [:d]
+ # task :t, [a] => [:d]
+ # task :t, :needs => [:d] (deprecated)
+ # task :t, :a, :needs => [:d] (deprecated)
+ #
+ def resolve_args_with_dependencies(args, hash) # :nodoc:
+ fail "Task Argument Error" if hash.size != 1
+ key, value = hash.map { |k, v| [k,v] }.first
+ if args.empty?
+ task_name = key
+ arg_names = []
+ deps = value
+ elsif key == :needs
+ task_name = args.shift
+ arg_names = args
+ deps = value
+ else
+ task_name = args.shift
+ arg_names = key
+ deps = value
+ end
+ deps = [deps] unless deps.respond_to?(:to_ary)
+ [task_name, arg_names, deps]
+ end
+ private :resolve_args_with_dependencies
+
+ # If a rule can be found that matches the task name, enhance the
+ # task with the prerequisites and actions from the rule. Set the
+ # source attribute of the task appropriately for the rule. Return
+ # the enhanced task or nil of no rule was found.
+ def enhance_with_matching_rule(task_name, level=0)
+ fail Rake::RuleRecursionOverflowError,
+ "Rule Recursion Too Deep" if level >= 16
+ @rules.each do |pattern, extensions, block|
+ if md = pattern.match(task_name)
+ task = attempt_rule(task_name, extensions, block, level)
+ return task if task
+ end
+ end
+ nil
+ rescue Rake::RuleRecursionOverflowError => ex
+ ex.add_target(task_name)
+ fail ex
+ end
+
+ # List of all defined tasks in this application.
+ def tasks
+ @tasks.values.sort_by { |t| t.name }
+ end
+
+ # List of all the tasks defined in the given scope (and its
+ # sub-scopes).
+ def tasks_in_scope(scope)
+ prefix = scope.join(":")
+ tasks.select { |t|
+ /^#{prefix}:/ =~ t.name
+ }
+ end
+
+ # Clear all tasks in this application.
+ def clear
+ @tasks.clear
+ @rules.clear
+ end
+
+ # Lookup a task, using scope and the scope hints in the task name.
+ # This method performs straight lookups without trying to
+ # synthesize file tasks or rules. Special scope names (e.g. '^')
+ # are recognized. If no scope argument is supplied, use the
+ # current scope. Return nil if the task cannot be found.
+ def lookup(task_name, initial_scope=nil)
+ initial_scope ||= @scope
+ task_name = task_name.to_s
+ if task_name =~ /^rake:/
+ scopes = []
+ task_name = task_name.sub(/^rake:/, '')
+ elsif task_name =~ /^(\^+)/
+ scopes = initial_scope[0, initial_scope.size - $1.size]
+ task_name = task_name.sub(/^(\^+)/, '')
+ else
+ scopes = initial_scope
+ end
+ lookup_in_scope(task_name, scopes)
+ end
+
+ # Lookup the task name
+ def lookup_in_scope(name, scope)
+ n = scope.size
+ while n >= 0
+ tn = (scope[0,n] + [name]).join(':')
+ task = @tasks[tn]
+ return task if task
+ n -= 1
+ end
+ nil
+ end
+ private :lookup_in_scope
+
+ # Return the list of scope names currently active in the task
+ # manager.
+ def current_scope
+ @scope.dup
+ end
+
+ # Evaluate the block in a nested namespace named +name+. Create
+ # an anonymous namespace if +name+ is nil.
+ def in_namespace(name)
+ name ||= generate_name
+ @scope.push(name)
+ ns = NameSpace.new(self, @scope)
+ yield(ns)
+ ns
+ ensure
+ @scope.pop
+ end
+
+ private
+
+ # Add a location to the locations field of the given task.
+ def add_location(task)
+ loc = find_location
+ task.locations << loc if loc
+ task
+ end
+
+ # Find the location that called into the dsl layer.
+ def find_location
+ locations = caller
+ i = 0
+ while locations[i]
+ return locations[i+1] if locations[i] =~ /rake\/dsl.rb/
+ i += 1
+ end
+ nil
+ end
+
+ # Generate an anonymous namespace name.
+ def generate_name
+ @seed ||= 0
+ @seed += 1
+ "_anon_#{@seed}"
+ end
+
+ def trace_rule(level, message)
+ 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, extensions, block, level)
+ sources = make_sources(task_name, extensions)
+ prereqs = sources.collect { |source|
+ trace_rule level, "Attempting Rule #{task_name} => #{source}"
+ if File.exist?(source) || Rake::Task.task_defined?(source)
+ trace_rule level, "(#{task_name} => #{source} ... EXIST)"
+ source
+ elsif parent = enhance_with_matching_rule(source, level+1)
+ trace_rule level, "(#{task_name} => #{source} ... ENHANCE)"
+ parent.name
+ else
+ trace_rule level, "(#{task_name} => #{source} ... FAIL)"
+ return nil
+ end
+ }
+ task = FileTask.define_task({task_name => 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)
+ extensions.collect { |ext|
+ case ext
+ when /%/
+ task_name.pathmap(ext)
+ when %r{/}
+ ext
+ when /^\./
+ task_name.ext(ext)
+ when String
+ ext
+ when Proc
+ if ext.arity == 1
+ ext.call(task_name)
+ else
+ ext.call
+ end
+ else
+ fail "Don't know how to handle rule dependent: #{ext.inspect}"
+ end
+ }.flatten
+ end
+
+
+ private
+
+ # Return the current description. If there isn't one, try to find it
+ # by reading in the source file and looking for a comment immediately
+ # prior to the task definition
+ def get_description(task)
+ desc = @last_description || find_preceding_comment_for_task(task)
+ @last_description = nil
+ desc
+ end
+
+ def find_preceding_comment_for_task(task)
+ loc = task.locations.last
+ file_name, line = parse_location(loc)
+ return nil unless file_name
+ comment_from_file(file_name, line)
+ end
+
+ def parse_location(loc)
+ if loc =~ /^(.*):(\d+)/
+ [ $1, Integer($2) ]
+ else
+ nil
+ end
+ end
+
+ def comment_from_file(file_name, line)
+ return if file_name == '(eval)'
+ @file_cache ||= {}
+ content = (@file_cache[file_name] ||= File.readlines(file_name))
+ line -= 2
+ return nil unless content[line] =~ /^\s*#\s*(.*)/
+ $1
+ end
+
+ class << self
+ attr_accessor :record_task_metadata
+ TaskManager.record_task_metadata = false
+ end
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/tasklib.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/tasklib.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/tasklib.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+
+require 'rake'
+
+module Rake
+
+ # Base class for Task Libraries.
+ 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
Added: MacRuby/trunk/test/libs/rake/lib/rake/testtask.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/testtask.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/testtask.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,175 @@
+#!/usr/bin/env ruby
+
+# Define a task library for running unit tests.
+
+require 'rake'
+require 'rake/tasklib'
+
+module Rake
+
+ # Create a task that runs a set of tests.
+ #
+ # Example:
+ #
+ # Rake::TestTask.new do |t|
+ # t.libs << "test"
+ # t.test_files = FileList['test/test*.rb']
+ # t.verbose = true
+ # end
+ #
+ # If rake is invoked with a "TEST=filename" command line option,
+ # then the list of test files will be overridden to include only the
+ # filename specified on the command line. This provides an easy way
+ # to run just one test.
+ #
+ # If rake is invoked with a "TESTOPTS=options" command line option,
+ # then the given options are passed to the test process after a
+ # '--'. This allows Test::Unit options to be passed to the test
+ # suite.
+ #
+ # Examples:
+ #
+ # rake test # run tests normally
+ # rake test TEST=just_one_file.rb # run just one test file.
+ # rake test TESTOPTS="-v" # run in verbose mode
+ # rake test TESTOPTS="--runner=fox" # use the fox test runner
+ #
+ class TestTask < TaskLib
+
+ # Name of test task. (default is :test)
+ attr_accessor :name
+
+ # List of directories to added to $LOAD_PATH before running the
+ # tests. (default is 'lib')
+ attr_accessor :libs
+
+ # True if verbose test output desired. (default is false)
+ attr_accessor :verbose
+
+ # Test options passed to the test suite. An explicit
+ # TESTOPTS=opts on the command line will override this. (default
+ # is NONE)
+ attr_accessor :options
+
+ # Request that the tests be run with the warning flag set.
+ # E.g. warning=true implies "ruby -w" used to run the tests.
+ attr_accessor :warning
+
+ # Glob pattern to match test files. (default is 'test/test*.rb')
+ attr_accessor :pattern
+
+ # Style of test loader to use. Options are:
+ #
+ # * :rake -- Rake provided test loading script (default).
+ # * :testrb -- Ruby provided test loading script.
+ # * :direct -- Load tests using command line loader.
+ #
+ attr_accessor :loader
+
+ # Array of commandline options to pass to ruby when running test loader.
+ attr_accessor :ruby_opts
+
+ # 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
+ # used, then the list of test files is the union of the two.
+ def test_files=(list)
+ @test_files = list
+ end
+
+ # Create a testing task.
+ def initialize(name=:test)
+ @name = name
+ @libs = ["lib"]
+ @pattern = nil
+ @options = nil
+ @test_files = nil
+ @verbose = false
+ @warning = false
+ @loader = :rake
+ @ruby_opts = []
+ yield self if block_given?
+ @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
+ RakeFileUtils.verbose(@verbose) do
+ ruby "#{ruby_opts_string} #{run_code} #{file_list_string} #{option_list}"
+ end
+ end
+ self
+ end
+
+ def option_list # :nodoc:
+ ENV['TESTOPTS'] || @options || ""
+ end
+
+ def ruby_opts_string
+ opts = @ruby_opts.dup
+ opts.unshift( "-I\"#{lib_path}\"" ) unless @libs.empty?
+ opts.unshift( "-w" ) if @warning
+ opts.join(" ")
+ end
+
+ def lib_path
+ @libs.join(File::PATH_SEPARATOR)
+ end
+
+ def file_list_string
+ file_list.collect { |fn| "\"#{fn}\"" }.join(' ')
+ end
+
+ def file_list # :nodoc:
+ if ENV['TEST']
+ FileList[ ENV['TEST'] ]
+ else
+ result = []
+ result += @test_files.to_a if @test_files
+ result << @pattern 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
+ RUBY_VERSION
+ end
+
+ def run_code
+ case @loader
+ when :direct
+ "-e \"ARGV.each{|f| load f}\""
+ when :testrb
+ "-S testrb #{fix}"
+ when :rake
+ "\"#{rake_loader}\""
+ end
+ end
+
+ def rake_loader # :nodoc:
+ find_file('rake/rake_test_loader') or
+ fail "unable to find rake test loader"
+ end
+
+ def find_file(fn) # :nodoc:
+ $LOAD_PATH.each do |path|
+ file_path = File.join(path, "#{fn}.rb")
+ return file_path if File.exist? file_path
+ end
+ nil
+ end
+
+ end
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake/win32.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake/win32.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake/win32.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,55 @@
+
+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
+
+ # Error indicating a problem in locating the home directory on a
+ # Win32 system.
+ class Win32HomeError < RuntimeError
+ end
+
+ 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)
+ end
+
+ # The standard directory containing system wide rake files on
+ # Win 32 systems. Try the following environment variables (in
+ # order):
+ #
+ # * HOME
+ # * HOMEDRIVE + HOMEPATH
+ # * APPDATA
+ # * USERPROFILE
+ #
+ # 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']
+ end
+
+ 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'))
+ end
+
+ # Normalize a win32 path so that the slashes are all forward slashes.
+ def normalize(path)
+ path.gsub(/\\/, '/')
+ end
+
+ end
+ end
+end
Added: MacRuby/trunk/test/libs/rake/lib/rake.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/lib/rake.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/lib/rake.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,72 @@
+#!/usr/bin/env ruby
+
+#--
+
+# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 by Jim Weirich (jim.weirich at gmail.com)
+#
+# 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.
+#++
+
+RAKEVERSION = '0.8.99.3'
+
+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/win32'
+
+require 'rake/task_argument_error'
+require 'rake/rule_recursion_overflow_error'
+require 'rake/rake_module'
+require 'rake/psuedo_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'
+require 'rake/rake_file_utils'
+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/environment'
+
+$trace = false
+
+# Alias FileList to be available at the top level.
+FileList = Rake::FileList
+
+# Include the FileUtils file manipulation functions in the top level module,
+# but mark them private so that they don't unintentionally define methods on
+# other objects.
+
+include RakeFileUtils
+private(*FileUtils.instance_methods(false))
+private(*RakeFileUtils.instance_methods(false))
Property changes on: MacRuby/trunk/test/libs/rake/lib/rake.rb
___________________________________________________________________
Added: svn:executable
+ *
Added: MacRuby/trunk/test/libs/rake/rake.blurb
===================================================================
--- MacRuby/trunk/test/libs/rake/rake.blurb (rev 0)
+++ MacRuby/trunk/test/libs/rake/rake.blurb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,19 @@
+name: rake
+document: http://rake.rubyforge.org
+download: http://rubyforge.org/project/showfiles.php?group_id=50
+description: >
+ <p>This package contains Rake, a simple ruby build program with
+ capabilities similar to make.</p>
+
+ <p> Rake has the following features: </p>
+
+ <ul>
+ <li>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?)</li>
+ <li>Users can specify tasks with prerequisites.</li>
+ <li>Rake supports rule patterns to sythesize implicit tasks.</li>
+ <li>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.</li>
+ </ul>
Added: MacRuby/trunk/test/libs/rake/rake.gemspec
===================================================================
--- MacRuby/trunk/test/libs/rake/rake.gemspec (rev 0)
+++ MacRuby/trunk/test/libs/rake/rake.gemspec 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,214 @@
+--- !ruby/object:Gem::Specification
+name: rake
+version: !ruby/object:Gem::Version
+ version: 0.8.5
+platform: ruby
+authors:
+- Jim Weirich
+autorequire:
+bindir: bin
+cert_chain: []
+
+date: 2009-05-11 00:00:00 -04:00
+default_executable: rake
+dependencies: []
+
+description: Rake is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax.
+email: jim at weirichhouse.org
+executables:
+- rake
+extensions: []
+
+extra_rdoc_files:
+- README
+- MIT-LICENSE
+- TODO
+- CHANGES
+- doc/command_line_usage.rdoc
+- doc/glossary.rdoc
+- doc/proto_rake.rdoc
+- doc/rakefile.rdoc
+- doc/rational.rdoc
+- doc/release_notes/rake-0.4.14.rdoc
+- doc/release_notes/rake-0.4.15.rdoc
+- doc/release_notes/rake-0.5.0.rdoc
+- doc/release_notes/rake-0.5.3.rdoc
+- doc/release_notes/rake-0.5.4.rdoc
+- doc/release_notes/rake-0.6.0.rdoc
+- doc/release_notes/rake-0.7.0.rdoc
+- doc/release_notes/rake-0.7.1.rdoc
+- doc/release_notes/rake-0.7.2.rdoc
+- doc/release_notes/rake-0.7.3.rdoc
+- doc/release_notes/rake-0.8.0.rdoc
+- doc/release_notes/rake-0.8.2.rdoc
+- doc/release_notes/rake-0.8.3.rdoc
+- doc/release_notes/rake-0.8.4.rdoc
+- doc/release_notes/rake-0.8.5.rdoc
+files:
+- install.rb
+- CHANGES
+- MIT-LICENSE
+- Rakefile
+- README
+- TODO
+- bin/rake
+- lib/rake/alt_system.rb
+- lib/rake/application.rb
+- lib/rake/classic_namespace.rb
+- lib/rake/clean.rb
+- lib/rake/cloneable.rb
+- lib/rake/contrib/compositepublisher.rb
+- lib/rake/contrib/ftptools.rb
+- lib/rake/contrib/publisher.rb
+- lib/rake/contrib/rubyforgepublisher.rb
+- lib/rake/contrib/sshpublisher.rb
+- lib/rake/contrib/sys.rb
+- lib/rake/default_loader.rb
+- lib/rake/dsl.rb
+- lib/rake/early_time.rb
+- lib/rake/ext/module.rb
+- lib/rake/ext/string.rb
+- lib/rake/ext/time.rb
+- lib/rake/file_creation_task.rb
+- lib/rake/file_list.rb
+- lib/rake/file_task.rb
+- lib/rake/file_utils.rb
+- lib/rake/gempackagetask.rb
+- lib/rake/invocation_chain.rb
+- lib/rake/loaders/makefile.rb
+- lib/rake/multi_task.rb
+- lib/rake/name_space.rb
+- lib/rake/packagetask.rb
+- lib/rake/psuedo_status.rb
+- lib/rake/rake_file_utils.rb
+- lib/rake/rake_module.rb
+- lib/rake/rake_test_loader.rb
+- lib/rake/rdoctask.rb
+- lib/rake/ruby182_test_unit_fix.rb
+- lib/rake/rule_recursion_overflow_error.rb
+- lib/rake/runtest.rb
+- lib/rake/task.rb
+- lib/rake/task_argument_error.rb
+- lib/rake/task_arguments.rb
+- lib/rake/task_manager.rb
+- lib/rake/tasklib.rb
+- lib/rake/testtask.rb
+- lib/rake/win32.rb
+- lib/rake.rb
+- test/capture_stdout.rb
+- test/check_expansion.rb
+- test/check_no_expansion.rb
+- test/contrib/test_sys.rb
+- test/data/rakelib/test1.rb
+- test/data/rbext/rakefile.rb
+- test/filecreation.rb
+- test/functional.rb
+- test/in_environment.rb
+- test/rake_test_setup.rb
+- test/reqfile.rb
+- test/reqfile2.rb
+- test/session_functional.rb
+- test/shellcommand.rb
+- test/test_application.rb
+- test/test_clean.rb
+- test/test_definitions.rb
+- test/test_earlytime.rb
+- test/test_extension.rb
+- test/test_file_creation_task.rb
+- test/test_file_task.rb
+- test/test_filelist.rb
+- test/test_fileutils.rb
+- test/test_ftp.rb
+- test/test_invocation_chain.rb
+- test/test_makefile_loader.rb
+- test/test_multitask.rb
+- test/test_namespace.rb
+- test/test_package_task.rb
+- test/test_pathmap.rb
+- test/test_pseudo_status.rb
+- test/test_rake.rb
+- test/test_rdoc_task.rb
+- test/test_require.rb
+- test/test_rules.rb
+- test/test_task_arguments.rb
+- test/test_task_manager.rb
+- test/test_tasklib.rb
+- test/test_tasks.rb
+- test/test_test_task.rb
+- test/test_top_level_functions.rb
+- test/test_win32.rb
+- test/data/imports/deps.mf
+- test/data/sample.mf
+- test/data/chains/Rakefile
+- test/data/comments/Rakefile
+- test/data/default/Rakefile
+- test/data/dryrun/Rakefile
+- test/data/file_creation_task/Rakefile
+- test/data/imports/Rakefile
+- test/data/multidesc/Rakefile
+- test/data/namespace/Rakefile
+- test/data/statusreturn/Rakefile
+- test/data/unittest/Rakefile
+- test/data/unittest/subdir
+- doc/command_line_usage.rdoc
+- doc/example
+- doc/example/a.c
+- doc/example/b.c
+- doc/example/main.c
+- doc/example/Rakefile1
+- doc/example/Rakefile2
+- doc/glossary.rdoc
+- doc/jamis.rb
+- doc/proto_rake.rdoc
+- doc/rake.1.gz
+- doc/rakefile.rdoc
+- doc/rational.rdoc
+- doc/release_notes
+- doc/release_notes/rake-0.4.14.rdoc
+- doc/release_notes/rake-0.4.15.rdoc
+- doc/release_notes/rake-0.5.0.rdoc
+- doc/release_notes/rake-0.5.3.rdoc
+- doc/release_notes/rake-0.5.4.rdoc
+- doc/release_notes/rake-0.6.0.rdoc
+- doc/release_notes/rake-0.7.0.rdoc
+- doc/release_notes/rake-0.7.1.rdoc
+- doc/release_notes/rake-0.7.2.rdoc
+- doc/release_notes/rake-0.7.3.rdoc
+- doc/release_notes/rake-0.8.0.rdoc
+- doc/release_notes/rake-0.8.2.rdoc
+- doc/release_notes/rake-0.8.3.rdoc
+- doc/release_notes/rake-0.8.4.rdoc
+- doc/release_notes/rake-0.8.5.rdoc
+has_rdoc: true
+homepage: http://rake.rubyforge.org
+post_install_message:
+rdoc_options:
+- --line-numbers
+- --inline-source
+- --main
+- README
+- --title
+- Rake -- Ruby Make
+require_paths:
+- lib
+required_ruby_version: !ruby/object:Gem::Requirement
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ version: "0"
+ version:
+required_rubygems_version: !ruby/object:Gem::Requirement
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ version: "0"
+ version:
+requirements: []
+
+rubyforge_project: rake
+rubygems_version: 1.3.1
+signing_key:
+specification_version: 2
+summary: Ruby based make-like utility.
+test_files: []
+
Added: MacRuby/trunk/test/libs/rake/rakelib/extra.rake
===================================================================
--- MacRuby/trunk/test/libs/rake/rakelib/extra.rake (rev 0)
+++ MacRuby/trunk/test/libs/rake/rakelib/extra.rake 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,8 @@
+# Added for testing
+
+namespace :extra do
+ desc "An Extra Task"
+ task :extra do
+ puts "Read all about it"
+ end
+end
Added: MacRuby/trunk/test/libs/rake/rakelib/publish.rake
===================================================================
--- MacRuby/trunk/test/libs/rake/rakelib/publish.rake (rev 0)
+++ MacRuby/trunk/test/libs/rake/rakelib/publish.rake 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,22 @@
+# Optional publish task for Rake
+
+begin
+ require 'rake/contrib/sshpublisher'
+ require 'rake/contrib/rubyforgepublisher'
+
+ publisher = Rake::CompositePublisher.new
+ publisher.add Rake::RubyForgePublisher.new('rake', 'jimweirich')
+ publisher.add Rake::SshFilePublisher.new(
+ 'umlcoop',
+ 'htdocs/software/rake',
+ '.',
+ 'rake.blurb')
+
+ 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
Added: MacRuby/trunk/test/libs/rake/rakelib/rbx.rake
===================================================================
--- MacRuby/trunk/test/libs/rake/rakelib/rbx.rake (rev 0)
+++ MacRuby/trunk/test/libs/rake/rakelib/rbx.rake 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,82 @@
+module Rbx
+ PROG = '/usr/local/bin/rbx'
+ GEM_HOME = '/usr/local/lib/rubinius/gems/1.8'
+
+ RELEASE_FILES = FileList['bin/rake', 'lib/rake.rb', 'lib/rake/**/*']
+ RELEASE_FILES.exclude('lib/rake/lib', 'project.rake', 'lib/rake/plugins', 'lib/rake/contrib')
+
+ SVN = "../thirdparty/ruby"
+
+ def run_tests(files, opts='')
+ sh "#{PROG} -Ilib lib/rake/rake_test_loader.rb #{opts} #{files}"
+ end
+
+ extend self
+end
+
+namespace "rbx" do
+ desc "Ruby Release Files"
+ task :release_files do
+ puts Rbx::RELEASE_FILES
+ end
+
+ desc "Release Rake Files to Ruby 19 SVN working area"
+ task :release => [:check_svn] do
+ dirs = Rbx::RELEASE_FILES.select { |fn| File.directory?(fn) }
+ dirs.each do |dir| mkdir_p "#{Rbx::SVN}/#{dir}" end
+ Rbx::RELEASE_FILES.each do |fn|
+ cp fn, "#{Rbx::SVN}/#{fn}" unless File.directory?(fn)
+ end
+ end
+
+ desc "Remove Rake from the Ruby 19 SVN"
+ task :unrelease => [:check_svn] do
+ rm_r "#{Rbx::SVN}/bin/rake" rescue nil
+ rm_r "#{Rbx::SVN}/lib/rake" rescue nil
+ rm_r "#{Rbx::SVN}/lib/rake.rb" rescue nil
+ end
+
+ task :check_svn do
+ fail "Cannot find Ruby 1.9 SVN directory: #{Rbx::SVN}" unless
+ File.directory?(Rbx::SVN)
+ end
+
+
+ namespace "test" do
+
+ desc "Check the file paths"
+ task :check do
+ raise "Ruby 1.9 executable not found" unless File.exist?(Rbx::PROG)
+ raise "Ruby 1.9 Gem Home not found" unless File.exist?(Rbx::GEM_HOME)
+ end
+
+ task :env19 => :check do
+ ENV['GEM_HOME'] = Rbx::GEM_HOME
+ end
+
+ desc "Describe the Ruby 1.9 version used for testing"
+ task :version => [:env19] do
+ sh "#{Rbx::PROG} --version", :verbose => false
+ sh "#{Rbx::PROG} -rubygems -e 'puts \"Gem Path = \#{Gem.path}\"'", :verbose => false
+ sh "#{Rbx::PROG} -Ilib bin/rake --version"
+ end
+
+ desc "Run the unit tests in Ruby 1.9"
+ task :units, :opts, :needs => [:env19] do |t, args|
+ test_files = FileList['test/lib/*_test.rb']
+ Rbx.run_tests(test_files, args.opts)
+ end
+
+ desc "Run the functional tests in Ruby 1.9"
+ task :functionals, :opts, :needs => [:env19] do |t, args|
+ test_files = FileList['test/functional/*_test.rb']
+ Rbx.run_tests(test_files, args.opts)
+ end
+
+ desc "Run the all the tests in Ruby 1.9"
+ task :all, :opts, :needs => [:env19] do |t, args|
+ test_files = FileList['test/functional/*_test.rb', 'test/lib/*_test.rb']
+ Rbx.run_tests(test_files, args.opts)
+ end
+ end
+end
Added: MacRuby/trunk/test/libs/rake/rakelib/ruby19.rake
===================================================================
--- MacRuby/trunk/test/libs/rake/rakelib/ruby19.rake (rev 0)
+++ MacRuby/trunk/test/libs/rake/rakelib/ruby19.rake 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,88 @@
+module Ruby19
+ PROG = '/Users/jim/local/ruby19/bin/ruby'
+ GEM_HOME = '/Users/jim/local/ruby19.gems'
+
+ RELEASE_FILES = FileList['bin/rake', 'lib/rake.rb', 'lib/rake/**/*']
+ RELEASE_FILES.exclude('lib/rake/lib', 'project.rake', 'lib/rake/plugins', 'lib/rake/contrib')
+
+ SVN = "#{ENV['HOME']}/working/svn/software/thirdparty/ruby"
+
+ def run_tests(files, opts='')
+ sh "#{PROG} -w -Ilib lib/rake/rake_test_loader.rb #{opts} #{files}"
+ end
+
+ extend self
+end
+
+namespace "ruby19" do
+ desc "Generate a diff file between the primary repo and Ruby 1.9"
+ task :diff => [:check_svn] do
+ sh %{diff -u #{Ruby19::SVN}/lib/rake.rb lib/rake.rb}
+ sh %{diff -u -x .svn -x contrib -x lib #{Ruby19::SVN}/lib/rake lib/rake}
+ end
+
+ desc "Ruby Release Files"
+ task :release_files do
+ puts Ruby19::RELEASE_FILES
+ end
+
+ desc "Release Rake Files to Ruby 19 SVN working area"
+ task :release => [:check_svn] do
+ dirs = Ruby19::RELEASE_FILES.select { |fn| File.directory?(fn) }
+ dirs.each do |dir| mkdir_p "#{Ruby19::SVN}/#{dir}" end
+ Ruby19::RELEASE_FILES.each do |fn|
+ cp fn, "#{Ruby19::SVN}/#{fn}" unless File.directory?(fn)
+ end
+ end
+
+ desc "Remove Rake from the Ruby 19 SVN"
+ task :unrelease => [:check_svn] do
+ rm_r "#{Ruby19::SVN}/bin/rake" rescue nil
+ rm_r "#{Ruby19::SVN}/lib/rake" rescue nil
+ rm_r "#{Ruby19::SVN}/lib/rake.rb" rescue nil
+ end
+
+ task :check_svn do
+ fail "Cannot find Ruby 1.9 SVN directory: #{Ruby19::SVN}" unless
+ File.directory?(Ruby19::SVN)
+ end
+
+
+ namespace "test" do
+
+ desc "Check the file paths"
+ task :check do
+ raise "Ruby 1.9 executable not found" unless File.exist?(Ruby19::PROG)
+ raise "Ruby 1.9 Gem Home not found" unless File.exist?(Ruby19::GEM_HOME)
+ end
+
+ task :env19 => :check do
+ ENV['GEM_HOME'] = Ruby19::GEM_HOME
+ end
+
+ desc "Describe the Ruby 1.9 version used for testing"
+ task :version => [:env19] do
+ sh "#{Ruby19::PROG} --version", :verbose => false
+ sh "#{Ruby19::PROG} -rubygems -e 'puts \"Gem Path = \#{Gem.path}\"'", :verbose => false
+ sh "#{Ruby19::PROG} -Ilib bin/rake --version"
+ end
+
+ desc "Run the unit tests in Ruby 1.9"
+ task :units, :opts, :needs => [:env19] do |t, args|
+ test_files = FileList['test/lib/*_test.rb']
+ Ruby19.run_tests(test_files, args.opts)
+ end
+
+ desc "Run the functional tests in Ruby 1.9"
+ task :functionals, :opts, :needs => [:env19] do |t, args|
+ test_files = FileList['test/functional/*_test.rb']
+ Ruby19.run_tests(test_files, args.opts)
+ end
+
+ desc "Run the all the tests in Ruby 1.9"
+ task :all, :opts, :needs => [:env19] do |t, args|
+ test_files = FileList['test/functional/*_test.rb', 'test/lib/*_test.rb']
+ Ruby19.run_tests(test_files, args.opts)
+ end
+ end
+end
Added: MacRuby/trunk/test/libs/rake/rakelib/tags.rake
===================================================================
--- MacRuby/trunk/test/libs/rake/rakelib/tags.rake (rev 0)
+++ MacRuby/trunk/test/libs/rake/rakelib/tags.rake 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+
+module Tags
+ PROG = ENV['TAGS'] || 'ctags'
+ RUBY_FILES = FileList['**/*.rb'].exclude('sys.rb')
+ RUBY_FILES.include('**/*.rake')
+end
+
+namespace "tags" do
+ desc "Generate an Emacs TAGS file"
+ task :emacs => Tags::RUBY_FILES do
+ puts "Making Emacs TAGS file"
+ sh "#{Tags::PROG} -e #{Tags::RUBY_FILES}", :verbose => false
+ end
+end
+
+desc "Generate the TAGS file"
+task :tags => ["tags:emacs"]
Added: MacRuby/trunk/test/libs/rake/test/capture_stdout.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/capture_stdout.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/capture_stdout.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+
+require 'stringio'
+
+# Mix-in for capturing standard output.
+module CaptureStdout
+ def capture_stdout
+ s = StringIO.new
+ oldstdout = $stdout
+ $stdout = s
+ yield
+ s.string
+ ensure
+ $stdout = oldstdout
+ end
+
+ def capture_stderr
+ s = StringIO.new
+ oldstderr = $stderr
+ $stderr = s
+ yield
+ s.string
+ ensure
+ $stderr = oldstderr
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/check_expansion.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/check_expansion.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/check_expansion.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,5 @@
+if ARGV[0] != ARGV[1]
+ exit 1
+else
+ exit 0
+end
Added: MacRuby/trunk/test/libs/rake/test/check_no_expansion.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/check_no_expansion.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/check_no_expansion.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,5 @@
+if ARGV[0] != ARGV[1]
+ exit 0
+else
+ exit 1
+end
Added: MacRuby/trunk/test/libs/rake/test/contrib/test_sys.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/contrib/test_sys.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/contrib/test_sys.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,47 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'test/filecreation'
+require 'rake/contrib/sys'
+
+class TestSys < Test::Unit::TestCase
+ include FileCreation
+
+# def test_delete
+# create_file("testdata/a")
+# Sys.delete_all("testdata/a")
+# assert ! File.exist?("testdata/a")
+# end
+
+# def test_copy
+# create_file("testdata/a")
+# Sys.copy("testdata/a", "testdata/b")
+# assert File.exist?("testdata/b")
+# end
+
+# def test_for_files
+# test_files = ["testdata/a.pl", "testdata/c.pl", "testdata/b.rb"]
+# test_files.each { |fn| create_file(fn) }
+# list = []
+# Sys.for_files("testdata/*.pl", "testdata/*.rb") { |fn|
+# list << fn
+# }
+# assert_equal test_files.sort, list.sort
+# end
+
+# def test_indir
+# here = Dir.pwd
+# Sys.makedirs("testdata/dir")
+# assert_equal "#{here}/testdata/dir", Sys.indir("testdata/dir") { Dir.pwd }
+# assert_equal here, Dir.pwd
+# end
+
+ def test_split_all
+ assert_equal ['a'], Sys.split_all('a')
+ assert_equal ['..'], Sys.split_all('..')
+ assert_equal ['/'], Sys.split_all('/')
+ assert_equal ['a', 'b'], Sys.split_all('a/b')
+ assert_equal ['/', 'a', 'b'], Sys.split_all('/a/b')
+ assert_equal ['..', 'a', 'b'], Sys.split_all('../a/b')
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/data/chains/.cvsignore
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/chains/.cvsignore (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/chains/.cvsignore 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1 @@
+play.*
Added: MacRuby/trunk/test/libs/rake/test/data/chains/Rakefile
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/chains/Rakefile (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/chains/Rakefile 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,15 @@
+# -*- ruby -*-
+
+task :default => "play.app"
+
+file "play.scpt" => "base" do |t|
+ cp t.prerequisites.first, t.name
+end
+
+rule ".app" => ".scpt" do |t|
+ cp t.source, t.name
+end
+
+file 'base' do
+ touch 'base'
+end
Added: MacRuby/trunk/test/libs/rake/test/data/comments/Rakefile
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/comments/Rakefile (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/comments/Rakefile 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,18 @@
+# comment for t1
+task :t1 do
+end
+
+# no comment or task because there's a blank line
+
+task :t2 do
+end
+
+desc "override comment for t3"
+# this is not the description
+multitask :t3 do
+end
+
+# this is not the description
+desc "override comment for t4"
+file :t4 do
+end
\ No newline at end of file
Added: MacRuby/trunk/test/libs/rake/test/data/default/Rakefile
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/default/Rakefile (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/default/Rakefile 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+
+if ENV['TESTTOPSCOPE']
+ puts "TOPSCOPE"
+end
+
+task :default do
+ puts "DEFAULT"
+end
+
+task :other => [:default] do
+ puts "OTHER"
+end
+
+task :task_scope do
+ if ENV['TESTTASKSCOPE']
+ puts "TASKSCOPE"
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/data/dryrun/.cvsignore
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/dryrun/.cvsignore (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/dryrun/.cvsignore 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1 @@
+temp_*
Added: MacRuby/trunk/test/libs/rake/test/data/dryrun/Rakefile
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/dryrun/Rakefile (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/dryrun/Rakefile 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,22 @@
+#
+
+task :default => ["temp_main"]
+
+file "temp_main" => [:all_apps] do touch "temp_main" end
+
+task :all_apps => [:one, :two]
+task :one => ["temp_one"]
+task :two => ["temp_two"]
+
+file "temp_one" do |t|
+ touch "temp_one"
+end
+file "temp_two" do |t|
+ touch "temp_two"
+end
+
+task :clean do
+ ["temp_one", "temp_two", "temp_main"].each do |file|
+ rm_f file
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/data/file_creation_task/.cvsignore
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/file_creation_task/.cvsignore (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/file_creation_task/.cvsignore 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,2 @@
+src
+build
Added: MacRuby/trunk/test/libs/rake/test/data/file_creation_task/.gitignore
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/file_creation_task/.gitignore (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/file_creation_task/.gitignore 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,2 @@
+src
+build
Added: MacRuby/trunk/test/libs/rake/test/data/file_creation_task/Rakefile
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/file_creation_task/Rakefile (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/file_creation_task/Rakefile 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby
+
+N = 2
+
+task :default => :run
+
+BUILD_DIR = 'build'
+task :clean do
+ rm_rf 'build'
+ rm_rf 'src'
+end
+
+task :run
+
+TARGET_DIR = 'build/copies'
+
+FileList['src/*'].each do |src|
+ directory TARGET_DIR
+ target = File.join TARGET_DIR, File.basename(src)
+ file target => [src, TARGET_DIR] do
+ cp src, target
+ # sleep 3 if src !~ /foo#{N-1}$/ # I'm commenting out this sleep, it doesn't seem to do anything.
+ end
+ task :run => target
+end
+
+task :prep => :clean do
+ mkdir_p 'src'
+ N.times do |n|
+ puts "DBG: Touching src/foo#{n}"
+ touch "src/foo#{n}"
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/data/imports/.cvsignore
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/imports/.cvsignore (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/imports/.cvsignore 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1 @@
+dynamic_deps
Added: MacRuby/trunk/test/libs/rake/test/data/imports/Rakefile
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/imports/Rakefile (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/imports/Rakefile 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,19 @@
+# -*- ruby -*-
+
+require 'rake/loaders/makefile'
+
+task :default
+
+task :other do
+ puts "OTHER"
+end
+
+file "dynamic_deps" do |t|
+ open(t.name, "w") do |f| f.puts "puts 'DYNAMIC'" end
+end
+
+import "dynamic_deps"
+import "static_deps"
+import "static_deps"
+import "deps.mf"
+puts "FIRST"
Added: MacRuby/trunk/test/libs/rake/test/data/imports/deps.mf
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/imports/deps.mf (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/imports/deps.mf 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1 @@
+default: other
Added: MacRuby/trunk/test/libs/rake/test/data/multidesc/Rakefile
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/multidesc/Rakefile (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/multidesc/Rakefile 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+
+task :b
+
+desc "A"
+task :a
+
+desc "B"
+task :b
+
+desc "A2"
+task :a
+
+task :c
+
+desc "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+task :d
Added: MacRuby/trunk/test/libs/rake/test/data/namespace/.gitignore
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/namespace/.gitignore (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/namespace/.gitignore 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1 @@
+scopedep.rb
Added: MacRuby/trunk/test/libs/rake/test/data/namespace/Rakefile
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/namespace/Rakefile (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/namespace/Rakefile 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,66 @@
+#!/usr/bin/env ruby
+
+desc "copy"
+task :copy do
+ puts "COPY"
+end
+
+namespace "nest" do
+ desc "nest copy"
+ task :copy do
+ puts "NEST COPY"
+ end
+ task :xx => :copy
+end
+
+anon_ns = namespace do
+ desc "anonymous copy task"
+ task :copy do
+ puts "ANON COPY"
+ end
+end
+
+desc "Top level task to run the anonymous version of copy"
+task :anon => anon_ns[:copy]
+
+namespace "very" do
+ namespace "nested" do
+ task "run" => "rake:copy"
+ end
+end
+
+namespace "a" do
+ desc "Run task in the 'a' namespace"
+ task "run" do
+ puts "IN A"
+ end
+end
+
+namespace "b" do
+ desc "Run task in the 'b' namespace"
+ task "run" => "a:run" do
+ puts "IN B"
+ end
+end
+
+namespace "file1" do
+ file "xyz.rb" do
+ puts "XYZ1"
+ end
+end
+
+namespace "file2" do
+ file "xyz.rb" do
+ puts "XYZ2"
+ end
+end
+
+namespace "scopedep" do
+ task :prepare do
+ touch "scopedep.rb"
+ puts "PREPARE"
+ end
+ file "scopedep.rb" => [:prepare] do
+ puts "SCOPEDEP"
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/data/nosearch/dummy
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/nosearch/dummy (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/nosearch/dummy 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1 @@
+Dummy file to give the directory some content.
Added: MacRuby/trunk/test/libs/rake/test/data/rakelib/test1.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/rakelib/test1.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/rakelib/test1.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,5 @@
+Rake::DSL.environment do
+ task :default do
+ puts "TEST1"
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/data/rakelib/test2.rake
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/rakelib/test2.rake (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/rakelib/test2.rake 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,3 @@
+task :default do
+ puts "TEST2"
+end
Added: MacRuby/trunk/test/libs/rake/test/data/rbext/rakefile.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/rbext/rakefile.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/rbext/rakefile.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,3 @@
+task :default do
+ puts "OK"
+end
Added: MacRuby/trunk/test/libs/rake/test/data/sample.mf
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/sample.mf (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/sample.mf 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,14 @@
+# Comments
+a: a1 a2 a3 a4
+b: b1 b2 b3 \
+ b4 b5 b6\
+# Mid: Comment
+b7
+
+ a : a5 a6 a7
+c: c1
+d: d1 d2 \
+
+e f : e1 f1
+
+g\ 0: g1 g\ 2 g\ 3 g4
Added: MacRuby/trunk/test/libs/rake/test/data/statusreturn/Rakefile
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/statusreturn/Rakefile (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/statusreturn/Rakefile 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+
+task :exit5 do
+ exit(5)
+end
+
+task :normal do
+end
Added: MacRuby/trunk/test/libs/rake/test/data/sys/sys1.rake
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/sys/sys1.rake (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/sys/sys1.rake 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,3 @@
+task "sys1" do
+ puts "SYS1"
+end
Added: MacRuby/trunk/test/libs/rake/test/data/unittest/Rakefile
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/unittest/Rakefile (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/unittest/Rakefile 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1 @@
+# Empty Rakefile for Unit Test
Added: MacRuby/trunk/test/libs/rake/test/data/verbose/Rakefile
===================================================================
--- MacRuby/trunk/test/libs/rake/test/data/verbose/Rakefile (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/data/verbose/Rakefile 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,34 @@
+
+task :standalone_verbose_true do
+ verbose true
+ sh "ruby -e '0'"
+end
+
+task :standalone_verbose_false do
+ verbose false
+ sh "ruby -e '0'"
+end
+
+task :inline_verbose_default do
+ sh "ruby -e '0'"
+end
+
+task :inline_verbose_false do
+ sh "ruby -e '0'", :verbose => false
+end
+
+task :inline_verbose_true do
+ sh "ruby -e '0'", :verbose => true
+end
+
+task :block_verbose_true do
+ verbose(true) do
+ sh "ruby -e '0'"
+ end
+end
+
+task :block_verbose_false do
+ verbose(false) do
+ sh "ruby -e '0'"
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/filecreation.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/filecreation.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/filecreation.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,32 @@
+#!/usr/bin/env ruby
+
+module FileCreation
+ OLDFILE = "testdata/old"
+ NEWFILE = "testdata/new"
+
+ def create_timed_files(oldfile, *newfiles)
+ return if File.exist?(oldfile) && newfiles.all? { |newfile| File.exist?(newfile) }
+ old_time = create_file(oldfile)
+ newfiles.each do |newfile|
+ while create_file(newfile) <= old_time
+ sleep(0.1)
+ File.delete(newfile) rescue nil
+ end
+ end
+ end
+
+ def create_dir(dirname)
+ FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
+ File.stat(dirname).mtime
+ end
+
+ def create_file(name)
+ create_dir(File.dirname(name))
+ FileUtils.touch(name) unless File.exist?(name)
+ File.stat(name).mtime
+ end
+
+ def delete_file(name)
+ File.delete(name) rescue nil
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/functional/functional_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/functional/functional_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/functional/functional_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+
+begin
+ require 'rubygems'
+ gem 'session'
+ require 'session'
+rescue LoadError
+ puts "UNABLE TO RUN FUNCTIONAL TESTS"
+ puts "No Session Found (gem install session)"
+end
+
+if defined?(Session)
+ puts "RUNNING WITH SESSIONS"
+ require 'test/functional/session_based_tests.rb'
+end
Added: MacRuby/trunk/test/libs/rake/test/functional/session_based_tests.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/functional/session_based_tests.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/functional/session_based_tests.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,442 @@
+#!/usr/bin/env ruby
+
+begin
+ require 'rubygems'
+rescue LoadError => ex
+end
+require 'test/unit'
+require 'fileutils'
+require 'session'
+require 'test/in_environment'
+require 'test/rake_test_setup'
+require 'rake'
+
+# Version 2.1.9 of session has a bug where the @debug instance
+# variable is not initialized, causing warning messages. This snippet
+# of code fixes that problem.
+module Session
+ class AbstractSession
+ alias old_initialize initialize
+ def initialize(*args)
+ @debug = nil
+ old_initialize(*args)
+ end
+ end
+end
+
+class SessionBasedTests < Test::Unit::TestCase
+ include InEnvironment
+ include TestMethods
+
+ RUBY_COMMAND = 'ruby'
+
+ def setup
+ @rake_path = File.expand_path("bin/rake")
+ lib_path = File.expand_path("lib")
+ @ruby_options = "-I#{lib_path} -I."
+ @verbose = ! ENV['VERBOSE'].nil?
+ if @verbose
+ puts
+ puts
+ puts "--------------------------------------------------------------------"
+ puts name
+ puts "--------------------------------------------------------------------"
+ end
+ end
+
+ def test_rake_default
+ Dir.chdir("test/data/default") do rake end
+ assert_match(/^DEFAULT$/, @out)
+ assert_status
+ end
+
+ def test_rake_error_on_bad_task
+ Dir.chdir("test/data/default") do rake "xyz" end
+ assert_match(/rake aborted/, @err)
+ assert_status(1)
+ end
+
+ def test_env_availabe_at_top_scope
+ Dir.chdir("test/data/default") do rake "TESTTOPSCOPE=1" end
+ assert_match(/^TOPSCOPE$/, @out)
+ assert_status
+ end
+
+ def test_env_availabe_at_task_scope
+ Dir.chdir("test/data/default") do rake "TESTTASKSCOPE=1 task_scope" end
+ assert_match(/^TASKSCOPE$/, @out)
+ assert_status
+ end
+
+ def test_multi_desc
+ in_environment(
+ 'RAKE_COLUMNS' => "80",
+ "PWD" => "test/data/multidesc"
+ ) do
+ rake "-T"
+ end
+ assert_match %r{^rake a *# A / A2 *$}, @out
+ assert_match %r{^rake b *# B *$}, @out
+ assert_no_match %r{^rake c}, @out
+ assert_match %r{^rake d *# x{65}\.\.\.$}, @out
+ end
+
+ def test_long_description
+ in_environment("PWD" => "test/data/multidesc") do
+ rake "--describe"
+ end
+ assert_match %r{^rake a\n *A / A2 *$}m, @out
+ assert_match %r{^rake b\n *B *$}m, @out
+ assert_match %r{^rake d\n *x{80}}m, @out
+ assert_no_match %r{^rake c\n}m, @out
+ end
+
+ def test_rbext
+ in_environment("PWD" => "test/data/rbext") do
+ rake "-N"
+ end
+ assert_match %r{^OK$}, @out
+ end
+
+ def test_system
+ in_environment('RAKE_SYSTEM' => 'test/data/sys') do
+ rake '-g', "sys1"
+ end
+ assert_match %r{^SYS1}, @out
+ end
+
+ def test_system_excludes_rakelib_files_too
+ in_environment('RAKE_SYSTEM' => 'test/data/sys') do
+ rake '-g', "sys1", '-T', 'extra'
+ end
+ assert_no_match %r{extra:extra}, @out
+ end
+
+ def test_by_default_rakelib_files_are_included
+ in_environment('RAKE_SYSTEM' => 'test/data/sys') do
+ rake '-T', 'extra'
+ end
+ assert_match %r{extra:extra}, @out
+ end
+
+ def test_implicit_system
+ in_environment('RAKE_SYSTEM' => File.expand_path('test/data/sys'), "PWD" => "/") do
+ rake "sys1", "--trace"
+ end
+ assert_match %r{^SYS1}, @out
+ end
+
+ def test_no_system
+ in_environment('RAKE_SYSTEM' => 'test/data/sys') do
+ rake '-G', "sys1"
+ end
+ assert_match %r{^Don't know how to build task}, @err # emacs wart: '
+ end
+
+ def test_nosearch_with_rakefile_uses_local_rakefile
+ in_environment("PWD" => "test/data/default") do
+ rake "--nosearch"
+ end
+ assert_match %r{^DEFAULT}, @out
+ end
+
+ def test_nosearch_without_rakefile_finds_system
+ in_environment(
+ "PWD" => "test/data/nosearch",
+ "RAKE_SYSTEM" => File.expand_path("test/data/sys")
+ ) do
+ rake "--nosearch", "sys1"
+ end
+ assert_match %r{^SYS1}, @out
+ end
+
+ def test_nosearch_without_rakefile_and_no_system_fails
+ in_environment("PWD" => "test/data/nosearch", "RAKE_SYSTEM" => "not_exist") do
+ rake "--nosearch"
+ end
+ assert_match %r{^No Rakefile found}, @err
+ end
+
+ def test_invalid_command_line_options
+ in_environment("PWD" => "test/data/default") do
+ rake "--bad-options"
+ end
+ assert_match %r{invalid +option}i, @err
+ end
+
+ def test_inline_verbose_default_should_show_command
+ in_environment("PWD" => "test/data/verbose") do
+ rake "inline_verbose_default"
+ end
+ assert_match(/ruby -e/, @err)
+ end
+
+ def test_inline_verbose_true_should_show_command
+ in_environment("PWD" => "test/data/verbose") do
+ rake "inline_verbose_true"
+ end
+ assert_match(/ruby -e/, @err)
+ end
+
+ def test_inline_verbose_false_should_not_show_command
+ in_environment("PWD" => "test/data/verbose") do
+ rake "inline_verbose_false"
+ end
+ assert_no_match(/ruby -e/, @err)
+ end
+
+ def test_block_verbose_false_should_not_show_command
+ in_environment("PWD" => "test/data/verbose") do
+ rake "block_verbose_false"
+ end
+ assert_no_match(/ruby -e/, @err)
+ end
+
+ def test_block_verbose_true_should_show_command
+ in_environment("PWD" => "test/data/verbose") do
+ rake "block_verbose_true"
+ end
+ assert_match(/ruby -e/, @err)
+ end
+
+ def test_standalone_verbose_true_should_show_command
+ in_environment("PWD" => "test/data/verbose") do
+ rake "standalone_verbose_true"
+ end
+ assert_match(/ruby -e/, @err)
+ end
+
+ def test_standalone_verbose_false_should_not_show_command
+ in_environment("PWD" => "test/data/verbose") do
+ rake "standalone_verbose_false"
+ end
+ assert_no_match(/ruby -e/, @err)
+ end
+
+ def test_dry_run
+ in_environment("PWD" => "test/data/default") do rake "-n", "other" end
+ assert_match %r{Execute \(dry run\) default}, @out
+ assert_match %r{Execute \(dry run\) other}, @out
+ assert_no_match %r{DEFAULT}, @out
+ assert_no_match %r{OTHER}, @out
+ end
+
+ # Test for the trace/dry_run bug found by Brian Chandler
+ def test_dry_run_bug
+ in_environment("PWD" => "test/data/dryrun") do
+ rake
+ end
+ FileUtils.rm_f "test/data/dryrun/temp_one"
+ in_environment("PWD" => "test/data/dryrun") do
+ rake "--dry-run"
+ end
+ assert_no_match(/No such file/, @out)
+ assert_status
+ end
+
+ # Test for the trace/dry_run bug found by Brian Chandler
+ def test_trace_bug
+ in_environment("PWD" => "test/data/dryrun") do
+ rake
+ end
+ FileUtils.rm_f "test/data/dryrun/temp_one"
+ in_environment("PWD" => "test/data/dryrun") do
+ rake "--trace"
+ end
+ assert_no_match(/No such file/, @out)
+ assert_status
+ end
+
+ def test_imports
+ open("test/data/imports/static_deps", "w") do |f|
+ f.puts 'puts "STATIC"'
+ end
+ FileUtils.rm_f "test/data/imports/dynamic_deps"
+ in_environment("PWD" => "test/data/imports") do
+ rake
+ end
+ assert File.exist?("test/data/imports/dynamic_deps"),
+ "'dynamic_deps' file should exist"
+ assert_match(/^FIRST$\s+^DYNAMIC$\s+^STATIC$\s+^OTHER$/, @out)
+ assert_status
+ FileUtils.rm_f "test/data/imports/dynamic_deps"
+ FileUtils.rm_f "test/data/imports/static_deps"
+ end
+
+ def test_rules_chaining_to_file_task
+ remove_chaining_files
+ in_environment("PWD" => "test/data/chains") do
+ rake
+ end
+ assert File.exist?("test/data/chains/play.app"),
+ "'play.app' file should exist"
+ assert_status
+ remove_chaining_files
+ end
+
+ def test_file_creation_task
+ in_environment("PWD" => "test/data/file_creation_task") do
+ rake "prep"
+ rake "run"
+ rake "run"
+ end
+ assert(@err !~ /^cp src/, "Should not recopy data")
+ end
+
+ def test_dash_f_with_no_arg_foils_rakefile_lookup
+ rake "-I test/data/rakelib -rtest1 -f"
+ assert_match(/^TEST1$/, @out)
+ end
+
+ def test_dot_rake_files_can_be_loaded_with_dash_r
+ rake "-I test/data/rakelib -rtest2 -f"
+ assert_match(/^TEST2$/, @out)
+ end
+
+ def test_can_invoke_task_in_toplevel_namespace
+ in_environment("PWD" => "test/data/namespace") do
+ rake "copy"
+ end
+ assert_match(/^COPY$/, @out)
+ end
+
+ def test_can_invoke_task_in_nested_namespace
+ in_environment("PWD" => "test/data/namespace") do
+ rake "nest:copy"
+ assert_match(/^NEST COPY$/, @out)
+ end
+ end
+
+ def test_tasks_can_reference_task_in_same_namespace
+ in_environment("PWD" => "test/data/namespace") do
+ rake "nest:xx"
+ assert_match(/^NEST COPY$/m, @out)
+ end
+ end
+
+ def test_tasks_can_reference_task_in_other_namespaces
+ in_environment("PWD" => "test/data/namespace") do
+ rake "b:run"
+ assert_match(/^IN A\nIN B$/m, @out)
+ end
+ end
+
+ def test_anonymous_tasks_can_be_invoked_indirectly
+ in_environment("PWD" => "test/data/namespace") do
+ rake "anon"
+ assert_match(/^ANON COPY$/m, @out)
+ end
+ end
+
+ def test_rake_namespace_refers_to_toplevel
+ in_environment("PWD" => "test/data/namespace") do
+ rake "very:nested:run"
+ assert_match(/^COPY$/m, @out)
+ end
+ end
+
+ def test_file_task_are_not_scoped_by_namespaces
+ in_environment("PWD" => "test/data/namespace") do
+ rake "xyz.rb"
+ assert_match(/^XYZ1\nXYZ2$/m, @out)
+ end
+ end
+
+ def test_file_task_dependencies_scoped_by_namespaces
+ in_environment("PWD" => "test/data/namespace") do
+ rake "scopedep.rb"
+ assert_match(/^PREPARE\nSCOPEDEP$/m, @out)
+ end
+ ensure
+ remove_namespace_files
+ end
+
+ def test_rake_returns_status_error_values
+ in_environment("PWD" => "test/data/statusreturn") do
+ rake "exit5"
+ assert_status(5)
+ end
+ end
+
+ def test_rake_returns_no_status_error_on_normal_exit
+ in_environment("PWD" => "test/data/statusreturn") do
+ rake "normal"
+ assert_status(0)
+ end
+ end
+
+ def test_comment_before_task_acts_like_desc
+ in_environment("PWD" => "test/data/comments") do
+ rake "-T"
+ end
+ assert_match("comment for t1", @out)
+ end
+
+ def test_comment_separated_from_task_by_blank_line_is_not_picked_up
+ Dir.chdir("test/data/comments") { rake("-T")}
+ assert_not_match("t2", @out)
+ end
+
+ def test_comment_after_desc_is_ignored
+ Dir.chdir("test/data/comments") { rake("-T")}
+ assert_match("override comment for t3", @out)
+ end
+
+ def test_comment_before_desc_is_ignored
+ Dir.chdir("test/data/comments") { rake("-T")}
+ assert_match("override comment for t4", @out)
+ end
+
+ def test_correct_number_of_tasks_reported
+ Dir.chdir("test/data/comments") { rake("-T")}
+ assert_equal(3, @out.split(/\n/).grep(/t\d/).size)
+ end
+
+ private
+
+ def assert_not_match(pattern, string, comment="'#{pattern}' was found (incorrectly) in '#{string}.inspect")
+ assert_nil Regexp.new(pattern).match(string), comment
+ end
+
+ def remove_chaining_files
+ %w(play.scpt play.app base).each do |fn|
+ FileUtils.rm_f File.join("test/data/chains", fn)
+ end
+ end
+
+ def remove_namespace_files
+ %w(scopedep.rb).each do |fn|
+ FileUtils.rm_f File.join("test/data/namespace", fn)
+ end
+ end
+
+ class << self
+ def format_command
+ @format_command ||= lambda { |ruby_options, rake_path, options|
+ "ruby #{ruby_options} #{rake_path} #{options}"
+ }
+ end
+
+ def format_command=(fmt_command)
+ @format_command = fmt_command
+ end
+ end
+
+ def rake(*option_list)
+ options = option_list.join(' ')
+ shell = Session::Shell.new
+ command = self.class.format_command[@ruby_options, @rake_path, options]
+ puts "COMMAND: [#{command}]" if @verbose
+ @out, @err = shell.execute command
+ @status = shell.exit_status
+ puts "STATUS: [#{@status}]" if @verbose
+ puts "OUTPUT: [#{@out}]" if @verbose
+ puts "ERROR: [#{@err}]" if @verbose
+ puts "PWD: [#{Dir.pwd}]" if @verbose
+ shell.close
+ end
+
+ def assert_status(expected_status=0)
+ assert_equal expected_status, @status
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/in_environment.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/in_environment.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/in_environment.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,32 @@
+module InEnvironment
+ private
+
+ # Create an environment for a test. At the completion of the yielded
+ # block, the environment is restored to its original conditions.
+ def in_environment(settings=nil)
+ settings ||= {}
+ full_settings = {"RAKEOPT" => nil}.merge(settings)
+ original_settings = set_env(full_settings)
+ yield
+ ensure
+ set_env(original_settings)
+ end
+
+ # Set the environment according to the settings hash.
+ def set_env(settings) # :nodoc:
+ result = {}
+ settings.each do |k, v|
+ result[k] = ENV[k]
+ if k == 'PWD'
+ result[k] = Dir.pwd
+ Dir.chdir(v)
+ elsif v.nil?
+ ENV.delete(k)
+ else
+ ENV[k] = v
+ end
+ end
+ result
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/application_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/application_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/application_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,769 @@
+#!/usr/bin/env ruby
+
+begin
+ require 'rubygems'
+rescue LoadError
+ # got no gems
+end
+
+require 'test/unit'
+require 'rake'
+require 'test/rake_test_setup'
+require 'test/capture_stdout'
+require 'test/in_environment'
+
+TESTING_REQUIRE = [ ]
+
+######################################################################
+class TestApplication < Test::Unit::TestCase
+ include CaptureStdout
+ include InEnvironment
+ include TestMethods
+
+ def setup
+ @app = Rake::Application.new
+ @app.options.rakelib = []
+ Rake::TaskManager.record_task_metadata = true
+ end
+
+ def test_constant_warning
+ err = capture_stderr do @app.instance_eval { const_warning("Task") } end
+ assert_match(/warning/i, err)
+ assert_match(/deprecated/i, err)
+ assert_match(/Task/i, err)
+ end
+
+ def test_display_tasks
+ @app.options.show_tasks = :tasks
+ @app.options.show_task_pattern = //
+ @app.last_description = "COMMENT"
+ @app.define_task(Rake::Task, "t")
+ out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
+ assert_match(/^rake t/, out)
+ assert_match(/# COMMENT/, out)
+ end
+
+ def test_display_tasks_with_long_comments
+ in_environment('RAKE_COLUMNS' => '80') do
+ @app.options.show_tasks = :tasks
+ @app.options.show_task_pattern = //
+ @app.last_description = "1234567890" * 8
+ @app.define_task(Rake::Task, "t")
+ out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
+ assert_match(/^rake t/, out)
+ assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
+ end
+ end
+
+ def test_display_tasks_with_task_name_wider_than_tty_display
+ in_environment('RAKE_COLUMNS' => '80') do
+ @app.options.show_tasks = :tasks
+ @app.options.show_task_pattern = //
+ description = "something short"
+ task_name = "task name" * 80
+ @app.last_description = "something short"
+ @app.define_task(Rake::Task, task_name )
+ out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
+ # Ensure the entire task name is output and we end up showing no description
+ assert_match(/rake #{task_name} # .../, out)
+ end
+ end
+
+ def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment
+ @app.options.show_tasks = :tasks
+ @app.options.show_task_pattern = //
+ @app.tty_output = false
+ description = "something short"
+ task_name = "task name" * 80
+ @app.last_description = "something short"
+ @app.define_task(Rake::Task, task_name )
+ out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
+ # Ensure the entire task name is output and we end up showing no description
+ assert_match(/rake #{task_name} # #{description}/, out)
+ end
+
+ def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment
+ @app.options.show_tasks = :tasks
+ @app.options.show_task_pattern = //
+ @app.tty_output = false
+ @app.last_description = "1234567890" * 8
+ @app.define_task(Rake::Task, "t")
+ out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
+ assert_match(/^rake t/, out)
+ assert_match(/# #{@app.last_description}/, out)
+ end
+
+ def test_display_tasks_with_long_comments_to_a_non_tty_with_columns_set_truncates_comments
+ in_environment("RAKE_COLUMNS" => '80') do
+ @app.options.show_tasks = :tasks
+ @app.options.show_task_pattern = //
+ @app.tty_output = false
+ @app.last_description = "1234567890" * 8
+ @app.define_task(Rake::Task, "t")
+ out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
+ assert_match(/^rake t/, out)
+ assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
+ end
+ end
+
+ def test_describe_tasks
+ @app.options.show_tasks = :describe
+ @app.options.show_task_pattern = //
+ @app.last_description = "COMMENT"
+ @app.define_task(Rake::Task, "t")
+ out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
+ assert_match(/^rake t$/, out)
+ assert_match(/^ {4}COMMENT$/, out)
+ end
+
+ def test_show_lines
+ @app.options.show_tasks = :lines
+ @app.options.show_task_pattern = //
+ @app.last_description = "COMMENT"
+ @app.define_task(Rake::Task, "t")
+ @app['t'].locations << "HERE:1"
+ out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
+ assert_match(/^rake t +[^:]+:\d+ *$/, out)
+ end
+
+ def test_finding_rakefile
+ assert_match(/Rakefile/i, @app.instance_eval { have_rakefile })
+ end
+
+ def test_not_finding_rakefile
+ @app.instance_eval { @rakefiles = ['NEVER_FOUND'] }
+ assert( ! @app.instance_eval do have_rakefile end )
+ assert_nil @app.rakefile
+ end
+
+ def test_load_rakefile
+ in_environment("PWD" => "test/data/unittest") do
+ @app.instance_eval do
+ handle_options
+ options.silent = true
+ load_rakefile
+ end
+ assert_equal "rakefile", @app.rakefile.downcase
+ assert_match(%r(unittest$), Dir.pwd)
+ end
+ end
+
+ def test_load_rakefile_from_subdir
+ in_environment("PWD" => "test/data/unittest/subdir") do
+ @app.instance_eval do
+ handle_options
+ options.silent = true
+ load_rakefile
+ end
+ assert_equal "rakefile", @app.rakefile.downcase
+ assert_match(%r(unittest$), Dir.pwd)
+ end
+ end
+
+ def test_load_rakefile_not_found
+ in_environment("PWD" => "/", "RAKE_SYSTEM" => 'not_exist') do
+ @app.instance_eval do
+ handle_options
+ options.silent = true
+ end
+ ex = assert_exception(RuntimeError) do
+ @app.instance_eval do raw_load_rakefile end
+ end
+ assert_match(/no rakefile found/i, ex.message)
+ end
+ end
+
+ def test_load_from_system_rakefile
+ in_environment('RAKE_SYSTEM' => 'test/data/sys') do
+ @app.options.rakelib = []
+ @app.instance_eval do
+ handle_options
+ options.silent = true
+ options.load_system = true
+ options.rakelib = []
+ load_rakefile
+ end
+ assert_equal "test/data/sys", @app.system_dir
+ assert_nil @app.rakefile
+ end
+ end
+
+ def test_windows
+ assert ! (@app.windows? && @app.unix?)
+ end
+
+ def test_loading_imports
+ mock = flexmock("loader")
+ mock.should_receive(:load).with("x.dummy").once
+ @app.instance_eval do
+ add_loader("dummy", mock)
+ add_import("x.dummy")
+ load_imports
+ end
+ end
+
+ def test_building_imported_files_on_demand
+ mock = flexmock("loader")
+ mock.should_receive(:load).with("x.dummy").once
+ mock.should_receive(:make_dummy).with_no_args.once
+ @app.instance_eval do
+ intern(Rake::Task, "x.dummy").enhance do mock.make_dummy end
+ add_loader("dummy", mock)
+ add_import("x.dummy")
+ load_imports
+ end
+ end
+
+ def test_handle_options_should_strip_options_from_ARGV
+ assert !@app.options.trace
+
+ valid_option = '--trace'
+ ARGV.clear
+ ARGV << valid_option
+
+ @app.handle_options
+
+ assert !ARGV.include?(valid_option)
+ assert @app.options.trace
+ end
+
+ def test_good_run
+ ran = false
+ ARGV.clear
+ ARGV << '--rakelib=""'
+ @app.options.silent = true
+ @app.instance_eval do
+ intern(Rake::Task, "default").enhance { ran = true }
+ end
+ in_environment("PWD" => "test/data/default") do
+ @app.run
+ end
+ assert ran
+ end
+
+ 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_stdout { @app.run }
+ assert @app.options.show_tasks
+ assert ! ran
+ assert_match(/rake default/, out)
+ assert_match(/# COMMENT/, out)
+ end
+
+ 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_stdout { @app.run }
+ assert @app.options.show_prereqs
+ assert ! ran
+ assert_match(/rake a$/, out)
+ assert_match(/rake b$/, out)
+ assert_match(/rake default\n( *(a|b)\n){2}/m, out)
+ end
+
+ def test_bad_run
+ @app.intern(Rake::Task, "default").enhance { fail }
+ ARGV.clear
+ ARGV << '-f' << '-s' << '--rakelib=""'
+ assert_exception(SystemExit) {
+ err = capture_stderr { @app.run }
+ assert_match(/see full trace/, err)
+ }
+ ensure
+ ARGV.clear
+ end
+
+ def test_bad_run_with_trace
+ @app.intern(Rake::Task, "default").enhance { fail }
+ ARGV.clear
+ ARGV << '-f' << '-s' << '-t'
+ assert_exception(SystemExit) {
+ err = capture_stderr { capture_stdout { @app.run } }
+ assert_no_match(/see full trace/, err)
+ }
+ ensure
+ ARGV.clear
+ end
+
+ def test_run_with_bad_options
+ @app.intern(Rake::Task, "default").enhance { fail }
+ ARGV.clear
+ ARGV << '-f' << '-s' << '--xyzzy'
+ assert_exception(SystemExit) {
+ err = capture_stderr { capture_stdout { @app.run } }
+ }
+ ensure
+ ARGV.clear
+ end
+end
+
+
+######################################################################
+class TestApplicationOptions < Test::Unit::TestCase
+ include CaptureStdout
+ include TestMethods
+ include InEnvironment
+
+ def setup
+ clear_argv
+ RakeFileUtils.verbose_flag = false
+ RakeFileUtils.nowrite_flag = false
+ TESTING_REQUIRE.clear
+ end
+
+ def teardown
+ clear_argv
+ RakeFileUtils.verbose_flag = false
+ RakeFileUtils.nowrite_flag = false
+ end
+
+ def clear_argv
+ while ! ARGV.empty?
+ ARGV.pop
+ end
+ end
+
+ def test_default_options
+ in_environment("RAKEOPT" => nil) do
+ opts = command_line
+ assert_nil opts.classic_namespace
+ assert_nil opts.dryrun
+ assert_nil opts.ignore_system
+ assert_nil opts.load_system
+ assert_nil opts.nosearch
+ assert_equal ['rakelib'], opts.rakelib
+ assert_nil opts.show_prereqs
+ assert_nil opts.show_task_pattern
+ assert_nil opts.show_tasks
+ assert_nil opts.silent
+ assert_nil opts.trace
+ assert_equal ['rakelib'], opts.rakelib
+ assert ! RakeFileUtils.verbose_flag
+ assert ! RakeFileUtils.nowrite_flag
+ end
+ end
+
+ def test_dry_run
+ in_environment do
+ flags('--dry-run', '-n') do |opts|
+ assert opts.dryrun
+ assert opts.trace
+ assert RakeFileUtils.verbose_flag
+ assert RakeFileUtils.nowrite_flag
+ end
+ end
+ end
+
+ def test_describe
+ in_environment do
+ flags('--describe') do |opts|
+ assert_equal :describe, opts.show_tasks
+ assert_equal(//.to_s, opts.show_task_pattern.to_s)
+ end
+ end
+ end
+
+ def test_describe_with_pattern
+ in_environment do
+ flags('--describe=X') do |opts|
+ assert_equal :describe, opts.show_tasks
+ assert_equal(/X/.to_s, opts.show_task_pattern.to_s)
+ end
+ end
+ end
+
+ def test_execute
+ in_environment do
+ $xyzzy = 0
+ flags('--execute=$xyzzy=1', '-e $xyzzy=1') do |opts|
+ assert_equal 1, $xyzzy
+ assert_equal :exit, @exit
+ $xyzzy = 0
+ end
+ end
+ end
+
+ def test_execute_and_continue
+ in_environment do
+ $xyzzy = 0
+ flags('--execute-continue=$xyzzy=1', '-E $xyzzy=1') do |opts|
+ assert_equal 1, $xyzzy
+ assert_not_equal :exit, @exit
+ $xyzzy = 0
+ end
+ end
+ end
+
+ def test_execute_and_print
+ in_environment do
+ $xyzzy = 0
+ flags('--execute-print=$xyzzy="pugh"', '-p $xyzzy="pugh"') do |opts|
+ assert_equal 'pugh', $xyzzy
+ assert_equal :exit, @exit
+ assert_match(/^pugh$/, @out)
+ $xyzzy = 0
+ end
+ end
+ end
+
+ def test_help
+ in_environment do
+ flags('--help', '-H', '-h') do |opts|
+ assert_match(/\Arake/, @out)
+ assert_match(/\boptions\b/, @out)
+ assert_match(/\btargets\b/, @out)
+ assert_equal :exit, @exit
+ assert_equal :exit, @exit
+ end
+ end
+ end
+
+ def test_libdir
+ in_environment do
+ flags(['--libdir', 'xx'], ['-I', 'xx'], ['-Ixx']) do |opts|
+ $:.include?('xx')
+ end
+ end
+ ensure
+ $:.delete('xx')
+ end
+
+ def test_rakefile
+ in_environment do
+ flags(['--rakefile', 'RF'], ['--rakefile=RF'], ['-f', 'RF'], ['-fRF']) do |opts|
+ assert_equal ['RF'], @app.instance_eval { @rakefiles }
+ end
+ end
+ end
+
+ def test_rakelib
+ in_environment do
+ flags(['--rakelibdir', 'A:B:C'], ['--rakelibdir=A:B:C'], ['-R', 'A:B:C'], ['-RA:B:C']) do |opts|
+ assert_equal ['A', 'B', 'C'], opts.rakelib
+ end
+ end
+ end
+
+ def test_require
+ in_environment do
+ flags(['--require', 'test/reqfile'], '-rtest/reqfile2', '-rtest/reqfile3') do |opts|
+ end
+ assert TESTING_REQUIRE.include?(1)
+ assert TESTING_REQUIRE.include?(2)
+ assert TESTING_REQUIRE.include?(3)
+ assert_equal 3, TESTING_REQUIRE.size
+ end
+ end
+
+ def test_missing_require
+ in_environment do
+ ex = assert_exception(LoadError) do
+ flags(['--require', 'test/missing']) do |opts|
+ end
+ end
+ assert_match(/no such file/, ex.message)
+ assert_match(/test\/missing/, ex.message)
+ end
+ end
+
+ def test_prereqs
+ in_environment do
+ flags('--prereqs', '-P') do |opts|
+ assert opts.show_prereqs
+ end
+ end
+ end
+
+ def test_quiet
+ in_environment do
+ flags('--quiet', '-q') do |opts|
+ assert ! RakeFileUtils.verbose_flag
+ assert ! opts.silent
+ end
+ end
+ end
+
+ def test_no_search
+ in_environment do
+ flags('--nosearch', '--no-search', '-N') do |opts|
+ assert opts.nosearch
+ end
+ end
+ end
+
+ def test_silent
+ in_environment do
+ flags('--silent', '-s') do |opts|
+ assert ! RakeFileUtils.verbose_flag
+ assert opts.silent
+ end
+ end
+ end
+
+ def test_system
+ in_environment do
+ flags('--system', '-g') do |opts|
+ assert opts.load_system
+ end
+ end
+ end
+
+ def test_no_system
+ in_environment do
+ flags('--no-system', '-G') do |opts|
+ assert opts.ignore_system
+ end
+ end
+ end
+
+ def test_trace
+ in_environment do
+ flags('--trace', '-t') do |opts|
+ assert opts.trace
+ assert RakeFileUtils.verbose_flag
+ assert ! RakeFileUtils.nowrite_flag
+ end
+ end
+ end
+
+ def test_trace_rules
+ in_environment do
+ flags('--rules') do |opts|
+ assert opts.trace_rules
+ end
+ end
+ end
+
+ def test_tasks
+ in_environment do
+ flags('--tasks', '-T') do |opts|
+ assert_equal :tasks, opts.show_tasks
+ assert_equal(//.to_s, opts.show_task_pattern.to_s)
+ end
+ flags(['--tasks', 'xyz'], ['-Txyz']) do |opts|
+ assert_equal :tasks, opts.show_tasks
+ assert_equal(/xyz/, opts.show_task_pattern)
+ end
+ end
+ end
+
+ def test_verbose
+ in_environment do
+ flags('--verbose', '-V') do |opts|
+ assert RakeFileUtils.verbose_flag
+ assert ! opts.silent
+ end
+ end
+ end
+
+ def test_version
+ in_environment do
+ flags('--version', '-V') do |opts|
+ assert_match(/\bversion\b/, @out)
+ assert_match(/\b#{RAKEVERSION}\b/, @out)
+ assert_equal :exit, @exit
+ end
+ end
+ end
+
+ def test_classic_namespace
+ in_environment do
+ flags(['--classic-namespace'], ['-C', '-T', '-P', '-n', '-s', '-t']) do |opts|
+ assert opts.classic_namespace
+ assert_equal opts.show_tasks, $show_tasks
+ assert_equal opts.show_prereqs, $show_prereqs
+ assert_equal opts.trace, $trace
+ assert_equal opts.dryrun, $dryrun
+ assert_equal opts.silent, $silent
+ end
+ end
+ end
+
+ def test_bad_option
+ in_environment do
+ error_output = capture_stderr do
+ ex = assert_exception(OptionParser::InvalidOption) do
+ flags('--bad-option')
+ end
+ if ex.message =~ /^While/ # Ruby 1.9 error message
+ assert_match(/while parsing/i, ex.message)
+ else # Ruby 1.8 error message
+ assert_match(/(invalid|unrecognized) option/i, ex.message)
+ assert_match(/--bad-option/, ex.message)
+ end
+ end
+ assert_equal '', error_output
+ end
+ end
+
+ def test_task_collection
+ command_line("a", "b")
+ assert_equal ["a", "b"], @tasks.sort
+ end
+
+ def test_default_task_collection
+ command_line()
+ assert_equal ["default"], @tasks
+ end
+
+ def test_environment_definition
+ ENV.delete('TESTKEY')
+ command_line("a", "TESTKEY=12")
+ assert_equal ["a"], @tasks.sort
+ assert '12', ENV['TESTKEY']
+ end
+
+ private
+
+ def flags(*sets)
+ sets.each do |set|
+ ARGV.clear
+ @out = capture_stdout {
+ @exit = catch(:system_exit) { opts = command_line(*set) }
+ }
+ yield(@app.options) if block_given?
+ end
+ 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
+ end
+ @tasks = @app.top_level_tasks
+ @app.options
+ end
+end
+
+class TestTaskArgumentParsing < Test::Unit::TestCase
+ def setup
+ @app = Rake::Application.new
+ end
+
+ def test_name_only
+ name, args = @app.parse_task_string("name")
+ assert_equal "name", name
+ assert_equal [], args
+ end
+
+ def test_empty_args
+ name, args = @app.parse_task_string("name[]")
+ assert_equal "name", name
+ assert_equal [], args
+ end
+
+ def test_one_argument
+ name, args = @app.parse_task_string("name[one]")
+ assert_equal "name", name
+ assert_equal ["one"], args
+ end
+
+ def test_two_arguments
+ name, args = @app.parse_task_string("name[one,two]")
+ assert_equal "name", name
+ assert_equal ["one", "two"], args
+ end
+
+ def test_can_handle_spaces_between_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
+
+end
+
+class TestTaskArgumentParsing < Test::Unit::TestCase
+ include InEnvironment
+
+ def test_terminal_width_using_env
+ app = Rake::Application.new
+ in_environment('RAKE_COLUMNS' => '1234') do
+ assert_equal 1234, app.terminal_width
+ end
+ end
+
+ def test_terminal_width_using_stty
+ app = Rake::Application.new
+ flexmock(app,
+ :unix? => true,
+ :dynamic_width_stty => 1235,
+ :dynamic_width_tput => 0)
+ in_environment('RAKE_COLUMNS' => nil) do
+ assert_equal 1235, app.terminal_width
+ end
+ end
+
+ def test_terminal_width_using_tput
+ app = Rake::Application.new
+ flexmock(app,
+ :unix? => true,
+ :dynamic_width_stty => 0,
+ :dynamic_width_tput => 1236)
+ in_environment('RAKE_COLUMNS' => nil) do
+ assert_equal 1236, app.terminal_width
+ end
+ end
+
+ def test_terminal_width_using_hardcoded_80
+ app = Rake::Application.new
+ flexmock(app, :unix? => false)
+ in_environment('RAKE_COLUMNS' => nil) do
+ assert_equal 80, app.terminal_width
+ end
+ end
+
+ def test_terminal_width_with_failure
+ app = Rake::Application.new
+ flexmock(app).should_receive(:unix?).and_throw(RuntimeError)
+ in_environment('RAKE_COLUMNS' => nil) do
+ assert_equal 80, app.terminal_width
+ end
+ end
+
+ def test_no_rakeopt
+ in_environment do
+ ARGV << '--trace'
+ app = Rake::Application.new
+ app.init
+ assert !app.options.silent
+ end
+ end
+
+ def test_rakeopt_with_blank_options
+ in_environment("RAKEOPT" => "") do
+ ARGV << '--trace'
+ app = Rake::Application.new
+ app.init
+ assert !app.options.silent
+ end
+ end
+
+ def test_rakeopt_with_silent_options
+ in_environment("RAKEOPT" => "-s") do
+ app = Rake::Application.new
+ app.init
+ assert app.options.silent
+ end
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/clean_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/clean_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/clean_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'rake'
+require 'rake/clean'
+
+class TestClean < Test::Unit::TestCase
+ include Rake
+ def test_clean
+ assert Task['clean'], "Should define clean"
+ assert Task['clobber'], "Should define clobber"
+ assert Task['clobber'].prerequisites.include?("clean"),
+ "Clobber should require clean"
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/definitions_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/definitions_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/definitions_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,85 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'fileutils'
+require 'rake'
+require 'test/filecreation'
+require 'test/rake_test_setup'
+
+######################################################################
+class TestDefinitions < Test::Unit::TestCase
+ include Rake
+ include TestMethods
+
+ EXISTINGFILE = "testdata/existing"
+
+ def setup
+ Task.clear
+ end
+
+ def test_task
+ done = false
+ task :one => [:two] do done = true end
+ task :two
+ task :three => [:one, :two]
+ check_tasks(:one, :two, :three)
+ assert done, "Should be done"
+ end
+
+ def test_file_task
+ done = false
+ file "testdata/one" => "testdata/two" do done = true end
+ file "testdata/two"
+ file "testdata/three" => ["testdata/one", "testdata/two"]
+ check_tasks("testdata/one", "testdata/two", "testdata/three")
+ assert done, "Should be done"
+ end
+
+ 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.collect{|n| n.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.collect{|n|n.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 :t2
+ task :t3
+ Task[:t1].invoke
+ assert_equal ["A", "B"], runs
+ assert_equal ["t2", "t3"], Task[:t1].prerequisites
+ end
+
+ def test_missing_dependencies
+ task :x => ["testdata/missing"]
+ assert_exception(RuntimeError) { Task[:x].invoke }
+ end
+
+ def test_implicit_file_dependencies
+ runs = []
+ create_existing_file
+ task :y => [EXISTINGFILE] do |t| runs << t.name end
+ Task[:y].invoke
+ assert_equal runs, ['y']
+ end
+
+ private # ----------------------------------------------------------
+
+ def create_existing_file
+ Dir.mkdir File.dirname(EXISTINGFILE) unless
+ File.exist?(File.dirname(EXISTINGFILE))
+ open(EXISTINGFILE, "w") do |f| f.puts "HI" end unless
+ File.exist?(EXISTINGFILE)
+ end
+
+end
+
Added: MacRuby/trunk/test/libs/rake/test/lib/dsl_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/dsl_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/dsl_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,41 @@
+#!/usr/bin/env ruby
+
+begin
+ require 'rubygems'
+rescue LoadError
+ # got no gems
+end
+
+require 'test/unit'
+require 'flexmock/test_unit'
+require 'rake'
+require 'test/rake_test_setup'
+
+class DslTest < Test::Unit::TestCase
+
+ def test_namespace_command
+ namespace "n" do
+ task "t"
+ end
+ assert_not_nil Rake::Task["n:t"]
+ end
+
+ def test_namespace_command_with_bad_name
+ ex = assert_raise(ArgumentError) do
+ namespace 1 do end
+ end
+ assert_match(/string/i, ex.message)
+ assert_match(/symbol/i, ex.message)
+ end
+
+ def test_namespace_command_with_a_string_like_object
+ name = Object.new
+ def name.to_str
+ "bob"
+ end
+ namespace name do
+ task "t"
+ end
+ assert_not_nil Rake::Task["bob:t"]
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/earlytime_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/earlytime_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/earlytime_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,35 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'rake'
+
+class TestEarlyTime < Test::Unit::TestCase
+ def test_create
+ early = Rake::EarlyTime.instance
+ time = Time.mktime(1970, 1, 1, 0, 0, 0)
+ assert early <= Time.now
+ assert early < Time.now
+ assert early != Time.now
+ assert Time.now > early
+ assert Time.now >= early
+ assert Time.now != early
+ end
+
+ def test_equality
+ early = Rake::EarlyTime.instance
+ assert_equal early, early, "two early times should be equal"
+ end
+
+ def test_original_time_compare_is_not_messed_up
+ t1 = Time.mktime(1970, 1, 1, 0, 0, 0)
+ t2 = Time.now
+ assert t1 < t2
+ assert t2 > t1
+ assert t1 == t1
+ assert t2 == t2
+ end
+
+ def test_to_s
+ assert_equal "<EARLY TIME>", Rake::EARLY.to_s
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/environment_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/environment_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/environment_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+
+require 'test/test_helper'
+require 'rake/environment'
+
+class TestEnvironment < Test::Unit::TestCase
+ def test_load_string
+ Rake::Task.clear
+ Rake::Environment.load_string("task :xyz")
+ assert Rake::Task[:xyz], "should have a task named xyz"
+ end
+
+ def test_load_rakefile
+ Rake::Task.clear
+ Rake::Environment.load_rakefile("test/data/default/Rakefile")
+ assert Rake::Task[:default], "Should have a default task"
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/extension_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/extension_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/extension_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,63 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'rake'
+require 'stringio'
+
+######################################################################
+class TestExtension < Test::Unit::TestCase
+
+ module Redirect
+ def error_redirect
+ old_err = $stderr
+ result = StringIO.new
+ $stderr = result
+ yield
+ result
+ ensure
+ $stderr = old_err
+ end
+ end
+
+ class Sample
+ extend Redirect
+
+ def duplicate_method
+ :original
+ end
+
+ OK_ERRS = error_redirect do
+ rake_extension("a") do
+ def ok_method
+ end
+ end
+ end
+
+
+ DUP_ERRS = error_redirect do
+ rake_extension("duplicate_method") do
+ def duplicate_method
+ :override
+ end
+ end
+ end
+ end
+
+ def test_methods_actually_exist
+ sample = Sample.new
+ sample.ok_method
+ sample.duplicate_method
+ end
+
+ def test_no_warning_when_defining_ok_method
+ assert_equal "", Sample::OK_ERRS.string
+ end
+
+ def test_extension_complains_when_a_method_that_is_present
+ assert_match(/warning:/i, Sample::DUP_ERRS.string)
+ assert_match(/already exists/i, Sample::DUP_ERRS.string)
+ assert_match(/duplicate_method/i, Sample::DUP_ERRS.string)
+ assert_equal :original, Sample.new.duplicate_method
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/file_creation_task_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/file_creation_task_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/file_creation_task_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,62 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'fileutils'
+require 'rake'
+require 'test/filecreation'
+
+######################################################################
+class TestFileCreationTask < Test::Unit::TestCase
+ include Rake
+ include FileCreation
+
+ DUMMY_DIR = 'testdata/dummy_dir'
+
+ def setup
+ Task.clear
+ end
+
+ def teardown
+ FileUtils.rm_rf DUMMY_DIR
+ end
+
+ def test_file_needed
+ create_dir DUMMY_DIR
+ fc_task = Task[DUMMY_DIR]
+ assert_equal DUMMY_DIR, fc_task.name
+ 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.collect{|n| Task[n].timestamp}.max
+ assert ! fc_task.needed?, "file should not be needed"
+ end
+
+ def test_directory
+ directory DUMMY_DIR
+ fc_task = Task[DUMMY_DIR]
+ assert_equal DUMMY_DIR, fc_task.name
+ assert FileCreationTask === fc_task
+ end
+
+ def test_no_retriggers_on_filecreate_task
+ create_timed_files(OLDFILE, NEWFILE)
+ t1 = Rake.application.intern(FileCreationTask, OLDFILE).enhance([NEWFILE])
+ t2 = Rake.application.intern(FileCreationTask, NEWFILE)
+ assert ! t2.needed?, "Should not need to build new file"
+ assert ! t1.needed?, "Should not need to rebuild old file because of new"
+ end
+
+ def test_no_retriggers_on_file_task
+ create_timed_files(OLDFILE, NEWFILE)
+ t1 = Rake.application.intern(FileCreationTask, OLDFILE).enhance([NEWFILE])
+ t2 = Rake.application.intern(FileCreationTask, NEWFILE)
+ assert ! t2.needed?, "Should not need to build new file"
+ assert ! t1.needed?, "Should not need to rebuild old file because of new"
+ end
+
+ def test_very_early_timestamp
+ t1 = Rake.application.intern(FileCreationTask, OLDFILE)
+ assert t1.timestamp < Time.now
+ assert t1.timestamp < Time.now - 1000000
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/file_task_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/file_task_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/file_task_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,143 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'fileutils'
+require 'rake'
+require 'test/filecreation'
+require 'test/rake_test_setup'
+
+######################################################################
+class TestFileTask < Test::Unit::TestCase
+ include Rake
+ include FileCreation
+ include TestMethods
+
+ def setup
+ Task.clear
+ @runs = Array.new
+ FileUtils.rm_f NEWFILE
+ FileUtils.rm_f OLDFILE
+ end
+
+ def test_file_need
+ name = "testdata/dummy"
+ file name
+ ftask = Task[name]
+ assert_equal name.to_s, ftask.name
+ File.delete(ftask.name) rescue nil
+ assert ftask.needed?, "file should be needed"
+ open(ftask.name, "w") { |f| f.puts "HI" }
+ assert_equal nil, ftask.prerequisites.collect{|n| Task[n].timestamp}.max
+ assert ! ftask.needed?, "file should not be needed"
+ File.delete(ftask.name) rescue nil
+ end
+
+ def test_file_times_new_depends_on_old
+ create_timed_files(OLDFILE, NEWFILE)
+
+ t1 = Rake.application.intern(FileTask, NEWFILE).enhance([OLDFILE])
+ t2 = Rake.application.intern(FileTask, OLDFILE)
+ assert ! t2.needed?, "Should not need to build old file"
+ assert ! t1.needed?, "Should not need to rebuild new file because of old"
+ end
+
+ def test_file_times_old_depends_on_new
+ create_timed_files(OLDFILE, NEWFILE)
+
+ t1 = Rake.application.intern(FileTask,OLDFILE).enhance([NEWFILE])
+ t2 = Rake.application.intern(FileTask, NEWFILE)
+ assert ! t2.needed?, "Should not need to build new file"
+ preq_stamp = t1.prerequisites.collect{|t| Task[t].timestamp}.max
+ assert_equal t2.timestamp, preq_stamp
+ assert t1.timestamp < preq_stamp, "T1 should be older"
+ assert t1.needed?, "Should need to rebuild old file because of new"
+ end
+
+ 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
+ file OLDFILE do |t| @runs << t.name end
+
+ Task[:obj].invoke
+ Task[NEWFILE].invoke
+ assert ! @runs.include?(NEWFILE)
+ end
+
+ def test_existing_file_depends_on_non_existing_file
+ create_file(OLDFILE)
+ delete_file(NEWFILE)
+ file NEWFILE
+ file OLDFILE => NEWFILE
+ assert_nothing_raised do Task[OLDFILE].invoke end
+ end
+
+ # I have currently disabled this test. I'm not convinced that
+ # deleting the file target on failure is always the proper thing to
+ # do. I'm willing to hear input on this topic.
+ def ztest_file_deletes_on_failure
+ task :obj
+ file NEWFILE => [:obj] do |t|
+ FileUtils.touch NEWFILE
+ fail "Ooops"
+ end
+ assert Task[NEWFILE]
+ begin
+ Task[NEWFILE].invoke
+ rescue Exception
+ end
+ assert( ! File.exist?(NEWFILE), "NEWFILE should be deleted")
+ end
+
+end
+
+######################################################################
+class TestDirectoryTask < Test::Unit::TestCase
+ include Rake
+
+ def setup
+ rm_rf "testdata", :verbose=>false
+ end
+
+ def teardown
+ rm_rf "testdata", :verbose=>false
+ end
+
+ def test_directory
+ desc "DESC"
+ directory "testdata/a/b/c"
+ assert_equal FileCreationTask, Task["testdata"].class
+ assert_equal FileCreationTask, Task["testdata/a"].class
+ assert_equal FileCreationTask, Task["testdata/a/b/c"].class
+ assert_nil Task["testdata"].comment
+ assert_equal "DESC", Task["testdata/a/b/c"].comment
+ assert_nil Task["testdata/a/b"].comment
+ verbose(false) {
+ Task['testdata/a/b'].invoke
+ }
+ assert File.exist?("testdata/a/b")
+ assert ! File.exist?("testdata/a/b/c")
+ end
+
+ if Rake::Win32.windows?
+ def test_directory_win32
+ desc "WIN32 DESC"
+ FileUtils.mkdir_p("testdata")
+ Dir.chdir("testdata") do
+ directory 'c:/testdata/a/b/c'
+ assert_equal FileCreationTask, Task['c:/testdata'].class
+ assert_equal FileCreationTask, Task['c:/testdata/a'].class
+ assert_equal FileCreationTask, Task['c:/testdata/a/b/c'].class
+ assert_nil Task['c:/testdata'].comment
+ assert_equal "WIN32 DESC", Task['c:/testdata/a/b/c'].comment
+ assert_nil Task['c:/testdata/a/b'].comment
+ verbose(false) {
+ Task['c:/testdata/a/b'].invoke
+ }
+ assert File.exist?('c:/testdata/a/b')
+ assert ! File.exist?('c:/testdata/a/b/c')
+ end
+ end
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/filelist_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/filelist_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/filelist_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,623 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'rake'
+
+require 'test/capture_stdout'
+require 'test/rake_test_setup'
+
+class TestFileList < Test::Unit::TestCase
+ FileList = Rake::FileList
+ include CaptureStdout
+ include TestMethods
+
+ def setup
+ create_test_data
+ end
+
+ def teardown
+# FileList.select_default_ignore_patterns
+ FileUtils.rm_rf("testdata")
+ end
+
+ def test_delgating_methods_do_not_include_to_a_or_to_ary
+ assert ! FileList::DELEGATING_METHODS.include?("to_a"), "should not include to_a"
+ assert ! FileList::DELEGATING_METHODS.include?(:to_a), "should not include to_a"
+ assert ! FileList::DELEGATING_METHODS.include?("to_ary"), "should not include to_ary"
+ assert ! FileList::DELEGATING_METHODS.include?(:to_ary), "should not include to_ary"
+ end
+
+ def test_create
+ fl = FileList.new
+ assert_equal 0, fl.size
+ end
+
+ def test_create_with_args
+ fl = FileList.new("testdata/*.c", "x")
+ assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
+ fl.sort
+ end
+
+ def test_create_with_block
+ fl = FileList.new { |f| f.include("x") }
+ assert_equal ["x"], fl.resolve
+ end
+
+ def test_create_with_brackets
+ fl = FileList["testdata/*.c", "x"]
+ assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
+ fl.sort
+ end
+
+ def test_create_with_brackets_and_filelist
+ fl = FileList[FileList["testdata/*.c", "x"]]
+ assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
+ fl.sort
+ end
+
+ def test_include_with_another_array
+ fl = FileList.new.include(["x", "y", "z"])
+ assert_equal ["x", "y", "z"].sort, fl.sort
+ end
+
+ def test_include_with_another_filelist
+ fl = FileList.new.include(FileList["testdata/*.c", "x"])
+ assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
+ fl.sort
+ end
+
+ def test_append
+ fl = FileList.new
+ fl << "a.rb" << "b.rb"
+ assert_equal ['a.rb', 'b.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
+ end
+
+ def test_add_return
+ f = FileList.new
+ g = f << "x"
+ assert_equal f.object_id, g.object_id
+ h = f.include("y")
+ assert_equal f.object_id, h.object_id
+ end
+
+ def test_match
+ fl = FileList.new
+ fl.include('test/lib/*_test.rb')
+ assert fl.include?("test/lib/filelist_test.rb")
+ assert fl.size > 3
+ fl.each { |fn| assert_match(/\.rb$/, fn) }
+ end
+
+ def test_add_matching
+ fl = FileList.new
+ fl << "a.java"
+ fl.include("test/lib/*.rb")
+ assert_equal "a.java", fl[0]
+ assert fl.size > 2
+ assert fl.include?("test/lib/filelist_test.rb")
+ end
+
+ def test_multiple_patterns
+ create_test_data
+ fl = FileList.new
+ fl.include('*.c', '*xist*')
+ assert_equal [], fl
+ fl.include('testdata/*.c', 'testdata/*xist*')
+ assert_equal [
+ 'testdata/x.c', 'testdata/xyz.c', 'testdata/abc.c', 'testdata/existing'
+ ].sort, fl.sort
+ end
+
+ def test_square_bracket_pattern
+ fl = FileList.new
+ fl.include("testdata/abc.[ch]")
+ assert fl.size == 2
+ assert fl.include?("testdata/abc.c")
+ assert fl.include?("testdata/abc.h")
+ end
+
+ def test_curly_bracket_pattern
+ fl = FileList.new
+ fl.include("testdata/abc.{c,h}")
+ assert fl.size == 2
+ assert fl.include?("testdata/abc.c")
+ assert fl.include?("testdata/abc.h")
+ end
+
+ def test_reject
+ fl = FileList.new
+ fl.include %w(testdata/x.c testdata/abc.c testdata/xyz.c testdata/existing)
+ fl.reject! { |fn| fn =~ %r{/x} }
+ assert_equal [
+ 'testdata/abc.c', 'testdata/existing'
+ ], fl
+ end
+
+ def test_exclude
+ fl = FileList['testdata/x.c', 'testdata/abc.c', 'testdata/xyz.c', 'testdata/existing']
+ fl.each { |fn| touch fn, :verbose => false }
+ x = fl.exclude(%r{/x.+\.})
+ assert_equal FileList, x.class
+ assert_equal %w(testdata/x.c testdata/abc.c testdata/existing), fl
+ assert_equal fl.object_id, x.object_id
+ fl.exclude('testdata/*.c')
+ assert_equal ['testdata/existing'], fl
+ fl.exclude('testdata/existing')
+ assert_equal [], fl
+ end
+
+ def test_excluding_via_block
+ fl = FileList['testdata/a.c', 'testdata/b.c', 'testdata/xyz.c']
+ fl.exclude { |fn| fn.pathmap('%n') == 'xyz' }
+ assert fl.exclude?("xyz.c"), "Should exclude xyz.c"
+ assert_equal ['testdata/a.c', 'testdata/b.c'], fl
+ end
+
+ def test_exclude_return_on_create
+ fl = FileList['testdata/*'].exclude(/.*\.[hcx]$/)
+ assert_equal ['testdata/existing', 'testdata/cfiles'].sort, fl.sort
+ assert_equal FileList, fl.class
+ end
+
+ def test_exclude_with_string_return_on_create
+ fl = FileList['testdata/*'].exclude('testdata/abc.c')
+ assert_equal %w(testdata/existing testdata/cfiles testdata/x.c testdata/abc.h testdata/abc.x testdata/xyz.c).sort, fl.sort
+ assert_equal FileList, fl.class
+ end
+
+ def test_default_exclude
+ fl = FileList.new
+ fl.clear_exclude
+ fl.include("**/*~", "**/*.bak", "**/core")
+ assert fl.member?("testdata/core"), "Should include core"
+ assert fl.member?("testdata/x.bak"), "Should include .bak files"
+ end
+
+ 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
+ fl.uniq!
+ assert_equal ['x.c', 'a.c', 'b.rb'], fl
+ end
+
+ def test_to_string
+ fl = FileList.new
+ fl << "a.java" << "b.java"
+ assert_equal "a.java b.java", fl.to_s
+ assert_equal "a.java b.java", "#{fl}"
+ end
+
+ def test_to_array
+ 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 Array, fl.to_ary.class
+ end
+
+ def test_to_s_pending
+ fl = FileList['testdata/abc.*']
+ result = fl.to_s
+ assert_match(%r{testdata/abc\.c}, result)
+ assert_match(%r{testdata/abc\.h}, result)
+ assert_match(%r{testdata/abc\.x}, result)
+ assert_match(%r{(testdata/abc\..\b ?){2}}, result)
+ end
+
+ def test_inspect_pending
+ fl = FileList['testdata/abc.*']
+ result = fl.inspect
+ assert_match(%r{"testdata/abc\.c"}, result)
+ assert_match(%r{"testdata/abc\.h"}, result)
+ assert_match(%r{"testdata/abc\.x"}, result)
+ assert_match(%r|^\[("testdata/abc\..", ){2}"testdata/abc\.."\]$|, result)
+ end
+
+ def test_sub
+ fl = FileList["testdata/*.c"]
+ f2 = fl.sub(/\.c$/, ".o")
+ assert_equal FileList, f2.class
+ assert_equal ["testdata/abc.o", "testdata/x.o", "testdata/xyz.o"].sort,
+ f2.sort
+ f3 = fl.gsub(/\.c$/, ".o")
+ assert_equal FileList, f3.class
+ assert_equal ["testdata/abc.o", "testdata/x.o", "testdata/xyz.o"].sort,
+ f3.sort
+ end
+
+ def test_claim_to_be_a_kind_of_array
+ fl = FileList['testdata/*.c']
+ assert fl.is_a?(Array)
+ assert fl.kind_of?(Array)
+ end
+
+ def test_claim_to_be_a_kind_of_filelist
+ fl = FileList['testdata/*.c']
+ assert fl.is_a?(FileList)
+ assert fl.kind_of?(FileList)
+ end
+
+ def test_claim_to_be_a_filelist_instance
+ fl = FileList['testdata/*.c']
+ assert fl.instance_of?(FileList)
+ end
+
+ def test_dont_claim_to_be_an_array_instance
+ fl = FileList['testdata/*.c']
+ assert ! fl.instance_of?(Array)
+ end
+
+ def test_sub!
+ f = "x/a.c"
+ fl = FileList[f, "x/b.c"]
+ res = fl.sub!(/\.c$/, ".o")
+ assert_equal ["x/a.o", "x/b.o"].sort, fl.sort
+ assert_equal "x/a.c", f
+ assert_equal fl.object_id, res.object_id
+ end
+
+ def test_sub_with_block
+ fl = FileList["src/org/onestepback/a.java", "src/org/onestepback/b.java"]
+# The block version doesn't work the way I want it to ...
+# f2 = fl.sub(%r{^src/(.*)\.java$}) { |x| "classes/" + $1 + ".class" }
+ f2 = fl.sub(%r{^src/(.*)\.java$}, "classes/\\1.class")
+ assert_equal [
+ "classes/org/onestepback/a.class",
+ "classes/org/onestepback/b.class"
+ ].sort,
+ f2.sort
+ end
+
+ def test_string_ext
+ assert_equal "one.net", "one.two".ext("net")
+ assert_equal "one.net", "one.two".ext(".net")
+ assert_equal "one.net", "one".ext("net")
+ assert_equal "one.net", "one".ext(".net")
+ assert_equal "one.two.net", "one.two.c".ext(".net")
+ assert_equal "one/two.net", "one/two.c".ext(".net")
+ assert_equal "one.x/two.net", "one.x/two.c".ext(".net")
+ assert_equal "one.x/two.net", "one.x/two".ext(".net")
+ 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".ext
+ assert_equal ".", ".".ext("c")
+ assert_equal "..", "..".ext("c")
+ # These only need to work in windows
+ if Rake::Win32.windows?
+ assert_equal "one.x\\two.net", "one.x\\two.c".ext(".net")
+ assert_equal "one.x\\two.net", "one.x\\two".ext(".net")
+ end
+ end
+
+ def test_filelist_ext
+ assert_equal FileList['one.c', '.one.c'],
+ FileList['one.net', '.one'].ext('c')
+ end
+
+ def test_gsub
+ create_test_data
+ fl = FileList["testdata/*.c"]
+ f2 = fl.gsub(/a/, "A")
+ assert_equal ["testdAtA/Abc.c", "testdAtA/x.c", "testdAtA/xyz.c"].sort,
+ f2.sort
+ end
+
+ def test_gsub!
+ create_test_data
+ f = FileList["testdata/*.c"]
+ f.gsub!(/a/, "A")
+ assert_equal ["testdAtA/Abc.c", "testdAtA/x.c", "testdAtA/xyz.c"].sort,
+ f.sort
+ end
+
+ def test_egrep_with_output
+ files = FileList['test/lib/*_test.rb']
+ the_line_number = __LINE__ + 1
+ out = capture_stdout do files.egrep(/PUGH/) end
+ assert_match(/:#{the_line_number}:/, out)
+ end
+
+ def test_egrep_with_block
+ files = FileList['test/lib/*_test.rb']
+ found = false
+ the_line_number = __LINE__ + 1
+ files.egrep(/XYZZY/) do |fn, ln, line |
+ assert_equal 'test/lib/filelist_test.rb', fn
+ assert_equal the_line_number, ln
+ assert_match(/files\.egrep/, line)
+ found = true
+ end
+ assert found, "should have found a matching line"
+ end
+
+ def test_existing
+ fl = FileList['testdata/abc.c', 'testdata/notthere.c']
+ assert_equal ["testdata/abc.c"], fl.existing
+ assert fl.existing.is_a?(FileList)
+ end
+
+ def test_existing!
+ fl = FileList['testdata/abc.c', 'testdata/notthere.c']
+ result = fl.existing!
+ assert_equal ["testdata/abc.c"], fl
+ assert_equal fl.object_id, result.object_id
+ end
+
+ def test_ignore_special
+ f = FileList['testdata/*']
+ assert ! f.include?("testdata/CVS"), "Should not contain CVS"
+ assert ! f.include?("testdata/.svn"), "Should not contain .svn"
+ assert ! f.include?("testdata/.dummy"), "Should not contain dot files"
+ assert ! f.include?("testdata/x.bak"), "Should not contain .bak files"
+ assert ! f.include?("testdata/x~"), "Should not contain ~ files"
+ assert ! f.include?("testdata/core"), "Should not contain core files"
+ end
+
+ def test_clear_ignore_patterns
+ f = FileList['testdata/*', 'testdata/.svn']
+ f.clear_exclude
+ assert f.include?("testdata/abc.c")
+ assert f.include?("testdata/xyz.c")
+ assert f.include?("testdata/CVS")
+ assert f.include?("testdata/.svn")
+ assert f.include?("testdata/x.bak")
+ assert f.include?("testdata/x~")
+ end
+
+ def test_exclude_with_alternate_file_seps
+ fl = FileList.new
+ assert fl.exclude?("x/CVS/y")
+ assert fl.exclude?("x\\CVS\\y")
+ assert fl.exclude?("x/.svn/y")
+ assert fl.exclude?("x\\.svn\\y")
+ assert fl.exclude?("x/core")
+ assert fl.exclude?("x\\core")
+ end
+
+ def test_add_default_exclude_list
+ fl = FileList.new
+ fl.exclude(/~\d+$/)
+ assert fl.exclude?("x/CVS/y")
+ assert fl.exclude?("x\\CVS\\y")
+ assert fl.exclude?("x/.svn/y")
+ assert fl.exclude?("x\\.svn\\y")
+ assert fl.exclude?("x/core")
+ assert fl.exclude?("x\\core")
+ assert fl.exclude?("x/abc~1")
+ 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.sort!
+ assert_equal ['a', 'b', 'c'], f
+ end
+
+ def test_flatten
+ assert_equal ['a', 'testdata/x.c', 'testdata/xyz.c', 'testdata/abc.c'].sort,
+ ['a', FileList['testdata/*.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
+ c = a.clone
+ d = a.dup
+ assert c.tainted?, "Clone should be tainted"
+ assert d.tainted?, "Dup should be tainted"
+ end
+
+ def test_duped_items_will_thaw
+ a = FileList['a', 'b', 'c']
+ a.freeze
+ d = a.dup
+ d << 'more'
+ assert_equal ['a', 'b', 'c', 'more'], d
+ end
+
+ def test_cloned_items_stay_frozen
+ a = FileList['a', 'b', 'c']
+ a.freeze
+ c = a.clone
+ assert_exception(TypeError, RuntimeError) do
+ c << 'more'
+ end
+ end
+
+ def test_array_comparisons
+ 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 )
+ assert_equal( -1, a <=> fl )
+ assert_equal( 0, b <=> fl )
+ assert_equal( 1, c <=> fl )
+ end
+
+ def test_array_equality
+ a = FileList['a', 'b']
+ b = ['a', 'b']
+ assert a == b
+ assert b == a
+# assert a.eql?(b)
+# assert b.eql?(a)
+ assert ! a.equal?(b)
+ assert ! b.equal?(a)
+ end
+
+ def test_enumeration_methods
+ a = FileList['a', 'b']
+ b = a.collect { |it| it.upcase }
+ assert_equal ['A', 'B'], b
+ assert_equal FileList, b.class
+
+ b = a.map { |it| it.upcase }
+ assert_equal ['A', 'B'], b
+ assert_equal FileList, b.class
+
+ b = a.sort
+ assert_equal ['a', 'b'], b
+ assert_equal FileList, b.class
+
+ b = a.sort_by { |it| it }
+ assert_equal ['a', 'b'], b
+ assert_equal FileList, b.class
+
+ b = a.find_all { |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 FileList, b.class
+
+ 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 FileList, b.class
+
+ 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
+ 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']
+
+ r = f + g
+ assert_equal ['x', 'y', 'w', 'z'], r
+ assert_equal FileList, r.class
+
+ r = a + g
+ assert_equal ['a', 'b', 'w', 'z'], r
+ assert_equal Array, r.class
+
+ r = f + b
+ assert_equal ['x', 'y', 'c', 'd'], r
+ assert_equal FileList, r.class
+
+ 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
+ assert_equal FileList, r.class
+
+ r = f * 2
+ assert_equal ['x', 'y', 'x', 'y'], r
+ assert_equal FileList, r.class
+
+ r = f * ','
+ assert_equal 'x,y', r
+ assert_equal String, r.class
+
+ 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']
+ r = f.compact
+ 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
+ assert_equal FileList, r.class
+
+ f = FileList['a', ['b', 'c'], FileList['d', 'e']]
+ r = f.flatten
+ assert_equal ['a', 'b', 'c', 'd', 'e'], r
+ assert_equal FileList, r.class
+
+ f = FileList['a', 'b', 'a']
+ r = f.uniq
+ assert_equal ['a', 'b'], r
+ assert_equal FileList, r.class
+
+ f = FileList['a', 'b', 'c', 'd']
+ r = f.values_at(1,3)
+ assert_equal ['b', 'd'], r
+ assert_equal FileList, r.class
+ end
+
+ def test_file_utils_can_use_filelists
+ cfiles = FileList['testdata/*.c']
+
+ 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'))
+ end
+
+ def create_test_data
+ verbose(false) do
+
+ mkdir "testdata" unless File.exist? "testdata"
+ mkdir "testdata/CVS" rescue nil
+ mkdir "testdata/.svn" rescue nil
+ @cdir = "testdata/cfiles"
+ mkdir @cdir rescue nil
+ touch "testdata/.dummy"
+ touch "testdata/x.bak"
+ touch "testdata/x~"
+ touch "testdata/core"
+ touch "testdata/x.c"
+ touch "testdata/xyz.c"
+ touch "testdata/abc.c"
+ touch "testdata/abc.h"
+ touch "testdata/abc.x"
+ touch "testdata/existing"
+ end
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/fileutils_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/fileutils_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/fileutils_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,251 @@
+#!/usr/bin/env ruby
+
+require 'rake'
+require 'test/unit'
+require 'test/filecreation'
+require 'fileutils'
+require 'stringio'
+require 'test/rake_test_setup'
+
+class TestFileUtils < Test::Unit::TestCase
+ include FileCreation
+ include TestMethods
+
+ def setup
+ File.chmod(0750,"test/shellcommand.rb")
+ end
+
+ def teardown
+ FileUtils.rm_rf("testdata")
+ FileUtils::LN_SUPPORTED[0] = true
+ end
+
+ def test_rm_one_file
+ create_file("testdata/a")
+ FileUtils.rm_rf "testdata/a"
+ assert ! File.exist?("testdata/a")
+ end
+
+ def test_rm_two_files
+ create_file("testdata/a")
+ create_file("testdata/b")
+ FileUtils.rm_rf ["testdata/a", "testdata/b"]
+ assert ! File.exist?("testdata/a")
+ assert ! File.exist?("testdata/b")
+ end
+
+ def test_rm_filelist
+ list = Rake::FileList.new << "testdata/a" << "testdata/b"
+ list.each { |fn| create_file(fn) }
+ FileUtils.rm_r list
+ assert ! File.exist?("testdata/a")
+ assert ! File.exist?("testdata/b")
+ end
+
+ def test_ln
+ create_dir("testdata")
+ open("testdata/a", "w") { |f| f.puts "TEST_LN" }
+ RakeFileUtils.safe_ln("testdata/a", "testdata/b", :verbose => false)
+ assert_equal "TEST_LN\n", open("testdata/b") { |f| f.read }
+ end
+
+ class BadLink
+ include RakeFileUtils
+ attr_reader :cp_args
+ def initialize(klass)
+ @failure_class = klass
+ end
+ def cp(*args)
+ @cp_args = args
+ end
+ def ln(*args)
+ fail @failure_class, "ln not supported"
+ end
+ public :safe_ln
+ end
+
+ 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
+ c.safe_ln "x", "y"
+ 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
+ end
+
+ def test_safe_ln_fails_on_script_error
+ FileUtils::LN_SUPPORTED[0] = true
+ c = BadLink.new(ScriptError)
+ assert_exception(ScriptError) do c.safe_ln "a", "b" end
+ end
+
+ def test_verbose
+ verbose true
+ assert_equal true, verbose
+ verbose false
+ assert_equal false, verbose
+ verbose(true) {
+ assert_equal true, verbose
+ }
+ assert_equal false, verbose
+ end
+
+ def test_nowrite
+ nowrite true
+ assert_equal true, nowrite
+ nowrite false
+ assert_equal false, nowrite
+ nowrite(true){
+ assert_equal true, nowrite
+ }
+ assert_equal false, nowrite
+ end
+
+ def test_file_utils_methods_are_available_at_top_level
+ create_file("testdata/a")
+ rm_rf "testdata/a"
+ assert ! File.exist?("testdata/a")
+ end
+
+ def test_fileutils_methods_dont_leak
+ obj = Object.new
+ assert_exception(NoMethodError) { obj.copy } # from FileUtils
+ assert_exception(NoMethodError) { obj.ruby "-v" } # from RubyFileUtils
+ end
+
+ def test_sh
+ verbose(false) { sh %{ruby test/shellcommand.rb} }
+ assert true, "should not fail"
+ end
+
+ # If the :sh method is invoked directly from a test unit instance
+ # (under mini/test), the mini/test version of fail is invoked rather
+ # than the kernel version of fail. So we run :sh from within a
+ # non-test class to avoid the problem.
+ class Sh
+ include FileUtils
+ def run(*args)
+ sh(*args)
+ end
+ def self.run(*args)
+ new.run(*args)
+ end
+ end
+
+ def test_sh_with_a_single_string_argument
+ ENV['RAKE_TEST_SH'] = 'someval'
+ verbose(false) {
+ sh %{ruby test/check_expansion.rb #{env_var} someval}
+ }
+ end
+
+ def test_sh_with_multiple_arguments
+ ENV['RAKE_TEST_SH'] = 'someval'
+ verbose(false) {
+ Sh.run 'ruby', 'test/check_no_expansion.rb', env_var, 'someval'
+ }
+ end
+
+ def test_sh_failure
+ assert_exception(RuntimeError) {
+ verbose(false) { Sh.run %{ruby test/shellcommand.rb 1} }
+ }
+ end
+
+ def test_sh_special_handling
+ count = 0
+ verbose(false) {
+ sh(%{ruby test/shellcommand.rb}) do |ok, res|
+ assert(ok)
+ assert_equal 0, res.exitstatus
+ count += 1
+ end
+ sh(%{ruby test/shellcommand.rb 1}) do |ok, res|
+ assert(!ok)
+ assert_equal 1, res.exitstatus
+ count += 1
+ end
+ }
+ assert_equal 2, count, "Block count should be 2"
+ end
+
+ def test_sh_noop
+ verbose(false) { sh %{test/shellcommand.rb 1}, :noop=>true }
+ assert true, "should not fail"
+ end
+
+ def test_sh_bad_option
+ ex = assert_exception(ArgumentError) {
+ verbose(false) { sh %{test/shellcommand.rb}, :bad_option=>true }
+ }
+ assert_match(/bad_option/, ex.message)
+ end
+
+ def test_sh_verbose
+ out = redirect_stderr {
+ verbose(true) {
+ sh %{test/shellcommand.rb}, :noop=>true
+ }
+ }
+ assert_match(/^test\/shellcommand\.rb$/, out)
+ end
+
+ def test_sh_no_verbose
+ out = redirect_stderr {
+ verbose(false) {
+ sh %{test/shellcommand.rb}, :noop=>true
+ }
+ }
+ assert_equal '', out
+ end
+
+ def test_ruby_with_a_single_string_argument
+ ENV['RAKE_TEST_SH'] = 'someval'
+ verbose(false) {
+ ruby %{test/check_expansion.rb #{env_var} someval}
+ }
+ end
+
+ def test_ruby_with_multiple_arguments
+ ENV['RAKE_TEST_SH'] = 'someval'
+ verbose(false) {
+ ruby 'test/check_no_expansion.rb', env_var, 'someval'
+ }
+ end
+
+ def test_split_all
+ assert_equal ['a'], RakeFileUtils.split_all('a')
+ assert_equal ['..'], RakeFileUtils.split_all('..')
+ assert_equal ['/'], RakeFileUtils.split_all('/')
+ assert_equal ['a', 'b'], RakeFileUtils.split_all('a/b')
+ assert_equal ['/', 'a', 'b'], RakeFileUtils.split_all('/a/b')
+ assert_equal ['..', 'a', 'b'], RakeFileUtils.split_all('../a/b')
+ end
+
+ private
+
+ def redirect_stderr
+ old_err = $stderr
+ $stderr = StringIO.new
+ yield
+ $stderr.string
+ ensure
+ $stderr = old_err
+ end
+
+ def windows?
+ ! File::ALT_SEPARATOR.nil?
+ end
+
+ def env_var
+ windows? ? '%RAKE_TEST_SH%' : '$RAKE_TEST_SH'
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/ftp_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/ftp_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/ftp_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,59 @@
+#!/usr/bin/env ruby
+
+require 'date'
+require 'time'
+require 'test/unit'
+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 TestFtpFile < Test::Unit::TestCase
+
+ def setup
+ 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 121770, 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
Added: MacRuby/trunk/test/libs/rake/test/lib/invocation_chain_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/invocation_chain_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/invocation_chain_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,81 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'rake'
+require 'test/rake_test_setup'
+
+######################################################################
+class TestAnEmptyInvocationChain < Test::Unit::TestCase
+ include TestMethods
+
+ def setup
+ @empty = Rake::InvocationChain::EMPTY
+ end
+
+ def test_should_be_able_to_add_members
+ assert_nothing_raised do
+ @empty.append("A")
+ end
+ end
+
+ def test_to_s
+ assert_equal "TOP", @empty.to_s
+ end
+end
+
+######################################################################
+class TestAnInvocationChainWithOneMember < Test::Unit::TestCase
+ include TestMethods
+
+ def setup
+ @empty = Rake::InvocationChain::EMPTY
+ @first_member = "A"
+ @chain = @empty.append(@first_member)
+ end
+
+ def test_should_report_first_member_as_a_member
+ assert @chain.member?(@first_member)
+ end
+
+ def test_should_fail_when_adding_original_member
+ ex = assert_exception RuntimeError do
+ @chain.append(@first_member)
+ end
+ assert_match(/circular +dependency/i, ex.message)
+ assert_match(/A.*=>.*A/, ex.message)
+ end
+
+ def test_to_s
+ assert_equal "TOP => A", @chain.to_s
+ end
+
+end
+
+######################################################################
+class TestAnInvocationChainWithMultipleMember < Test::Unit::TestCase
+ include TestMethods
+
+ def setup
+ @first_member = "A"
+ @second_member = "B"
+ ch = Rake::InvocationChain::EMPTY.append(@first_member)
+ @chain = ch.append(@second_member)
+ end
+
+ def test_should_report_first_member_as_a_member
+ assert @chain.member?(@first_member)
+ end
+
+ def test_should_report_second_member_as_a_member
+ assert @chain.member?(@second_member)
+ end
+
+ def test_should_fail_when_adding_original_member
+ ex = assert_exception RuntimeError do
+ @chain.append(@first_member)
+ end
+ assert_match(/A.*=>.*B.*=>.*A/, ex.message)
+ end
+end
+
+
Added: MacRuby/trunk/test/libs/rake/test/lib/makefile_loader_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/makefile_loader_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/makefile_loader_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'rake'
+require 'rake/loaders/makefile'
+
+class TestMakefileLoader < Test::Unit::TestCase
+ include Rake
+
+ def test_parse
+ Task.clear
+ loader = Rake::MakefileLoader.new
+ loader.load("test/data/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 ["g1", "g 2", "g 3", "g4"].sort, Task['g 0'].prerequisites.sort
+ assert_equal 7, Task.tasks.size
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/multitask_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/multitask_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/multitask_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,53 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'thread'
+require 'rake'
+
+######################################################################
+class TestMultiTask < Test::Unit::TestCase
+ include Rake
+
+ def setup
+ Task.clear
+ @runs = Array.new
+ @mutex = Mutex.new
+ end
+
+ def add_run(obj)
+ @mutex.synchronize do
+ @runs << obj
+ end
+ end
+
+ 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]
+ Task[:both].invoke
+ assert_equal 6, @runs.size
+ assert @runs.index("A0") < @runs.index("A1")
+ assert @runs.index("A1") < @runs.index("A2")
+ assert @runs.index("B0") < @runs.index("B1")
+ assert @runs.index("B1") < @runs.index("B2")
+ end
+
+ 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[:both].invoke
+ assert_equal 9, @runs.size
+ assert @runs.index("S0") < @runs.index("S1")
+ assert @runs.index("S1") < @runs.index("S2")
+ assert @runs.index("S2") < @runs.index("A0")
+ assert @runs.index("S2") < @runs.index("B0")
+ assert @runs.index("A0") < @runs.index("A1")
+ assert @runs.index("A1") < @runs.index("A2")
+ assert @runs.index("B0") < @runs.index("B1")
+ assert @runs.index("B1") < @runs.index("B2")
+ end
+end
+
+
Added: MacRuby/trunk/test/libs/rake/test/lib/namespace_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/namespace_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/namespace_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,55 @@
+#!/usr/bin/env ruby
+
+begin
+ require 'rubygems'
+rescue LoadError
+ # got no gems
+end
+
+require 'test/unit'
+require 'flexmock/test_unit'
+require 'rake'
+require 'test/rake_test_setup'
+
+class TestNameSpace < Test::Unit::TestCase
+ include TestMethods
+
+ class TM
+ include Rake::TaskManager
+ end
+
+ def test_namespace_creation
+ mgr = TM.new
+ ns = Rake::NameSpace.new(mgr, [])
+ assert_not_nil ns
+ end
+
+ def test_namespace_lookup
+ mgr = TM.new
+ ns = mgr.in_namespace("n") do
+ mgr.define_task(Rake::Task, "t")
+ end
+
+ assert_not_nil ns["t"]
+ assert_equal mgr["n:t"], ns["t"]
+ end
+
+ def test_namespace_reports_tasks_it_owns
+ mgr = TM.new
+ nns = nil
+ ns = mgr.in_namespace("n") do
+ mgr.define_task(Rake::Task, :x)
+ mgr.define_task(Rake::Task, :y)
+ nns = mgr.in_namespace("nn") do
+ mgr.define_task(Rake::Task, :z)
+ end
+ end
+ mgr.in_namespace("m") do
+ mgr.define_task(Rake::Task, :x)
+ 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}
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/package_task_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/package_task_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/package_task_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,118 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'rake/packagetask'
+require 'test/rake_test_setup'
+
+class TestPackageTask < Test::Unit::TestCase
+ include Rake
+ include TestMethods
+
+ def test_create
+ pkg = Rake::PackageTask.new("pkgr", "1.2.3") { |p|
+ p.package_files << "install.rb"
+ p.package_files.include(
+ '[A-Z]*',
+ 'bin/**/*',
+ 'lib/**/*.rb',
+ 'test/**/*.rb',
+ 'doc/**/*',
+ 'build/rubyapp.rb',
+ '*.blurb')
+ p.package_files.exclude(/\bCVS\b/)
+ p.package_files.exclude(/~$/)
+ p.package_dir = 'pkg'
+ p.need_tar = true
+ p.need_tar_gz = true
+ p.need_tar_bz2 = true
+ p.need_zip = true
+ }
+ assert_equal "pkg", pkg.package_dir
+ assert pkg.package_files.include?("bin/rake")
+ assert "pkgr", pkg.name
+ assert "1.2.3", pkg.version
+ assert Task[:package]
+ assert Task['pkg/pkgr-1.2.3.tgz']
+ assert Task['pkg/pkgr-1.2.3.tar.gz']
+ assert Task['pkg/pkgr-1.2.3.tar.bz2']
+ assert Task['pkg/pkgr-1.2.3.zip']
+ assert Task["pkg/pkgr-1.2.3"]
+ assert Task[:clobber_package]
+ assert Task[:repackage]
+ end
+
+ def test_missing_version
+ assert_exception(RuntimeError) {
+ pkg = Rake::PackageTask.new("pkgr") { |p| }
+ }
+ end
+
+ def test_no_version
+ pkg = Rake::PackageTask.new("pkgr", :noversion) { |p| }
+ assert "pkgr", pkg.send(:package_name)
+ end
+
+ def test_clone
+ pkg = Rake::PackageTask.new("x", :noversion)
+ p2 = pkg.clone
+ pkg.package_files << "y"
+ p2.package_files << "x"
+ assert_equal ["y"], pkg.package_files
+ assert_equal ["x"], p2.package_files
+ end
+end
+
+
+begin
+ require 'rubygems'
+ require 'rake/gempackagetask'
+rescue Exception
+ puts "WARNING: RubyGems not installed"
+end
+
+if ! defined?(Gem)
+ puts "WARNING: Unable to test GemPackaging ... requires RubyGems"
+else
+ class TestGemPackageTask < Test::Unit::TestCase
+ def test_gem_package
+ gem = Gem::Specification.new do |g|
+ g.name = "pkgr"
+ g.version = "1.2.3"
+ g.files = FileList["x"].resolve
+ end
+ pkg = Rake::GemPackageTask.new(gem) do |p|
+ p.package_files << "y"
+ end
+ assert_equal ["x", "y"], pkg.package_files
+ assert_equal "pkgr-1.2.3.gem", pkg.gem_file
+ end
+
+ def test_gem_package_with_current_platform
+ gem = Gem::Specification.new do |g|
+ g.name = "pkgr"
+ g.version = "1.2.3"
+ g.files = FileList["x"].resolve
+ g.platform = Gem::Platform::CURRENT
+ end
+ pkg = Rake::GemPackageTask.new(gem) do |p|
+ p.package_files << "y"
+ end
+ assert_equal ["x", "y"], pkg.package_files
+ assert_match(/^pkgr-1\.2\.3-(\S+)\.gem$/, pkg.gem_file)
+ end
+
+ def test_gem_package_with_ruby_platform
+ gem = Gem::Specification.new do |g|
+ g.name = "pkgr"
+ g.version = "1.2.3"
+ g.files = FileList["x"].resolve
+ g.platform = Gem::Platform::RUBY
+ end
+ pkg = Rake::GemPackageTask.new(gem) do |p|
+ p.package_files << "y"
+ end
+ assert_equal ["x", "y"], pkg.package_files
+ assert_equal "pkgr-1.2.3.gem", pkg.gem_file
+ end
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/pathmap_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/pathmap_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/pathmap_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,210 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'rake'
+
+# ====================================================================
+class TestPathMap < Test::Unit::TestCase
+ include TestMethods
+
+ def test_returns_self_with_no_args
+ assert_equal "abc.rb", "abc.rb".pathmap
+ end
+
+ def test_s_returns_file_separator
+ sep = File::ALT_SEPARATOR || File::SEPARATOR
+ assert_equal sep, "abc.rb".pathmap("%s")
+ assert_equal sep, "".pathmap("%s")
+ assert_equal "a#{sep}b", "a/b".pathmap("%d%s%f")
+ end
+
+ def test_f_returns_basename
+ assert_equal "abc.rb", "abc.rb".pathmap("%f")
+ assert_equal "abc.rb", "this/is/a/dir/abc.rb".pathmap("%f")
+ assert_equal "abc.rb", "/this/is/a/dir/abc.rb".pathmap("%f")
+ end
+
+ def test_n_returns_basename_without_extension
+ assert_equal "abc", "abc.rb".pathmap("%n")
+ assert_equal "abc", "abc".pathmap("%n")
+ assert_equal "abc", "this/is/a/dir/abc.rb".pathmap("%n")
+ assert_equal "abc", "/this/is/a/dir/abc.rb".pathmap("%n")
+ assert_equal "abc", "/this/is/a/dir/abc".pathmap("%n")
+ end
+
+ def test_d_returns_dirname
+ assert_equal ".", "abc.rb".pathmap("%d")
+ assert_equal "/", "/abc".pathmap("%d")
+ assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%d")
+ assert_equal "/this/is/a/dir", "/this/is/a/dir/abc.rb".pathmap("%d")
+ end
+
+ def test_9d_returns_partial_dirname
+ assert_equal "this/is", "this/is/a/dir/abc.rb".pathmap("%2d")
+ assert_equal "this", "this/is/a/dir/abc.rb".pathmap("%1d")
+ assert_equal ".", "this/is/a/dir/abc.rb".pathmap("%0d")
+ assert_equal "dir", "this/is/a/dir/abc.rb".pathmap("%-1d")
+ assert_equal "a/dir", "this/is/a/dir/abc.rb".pathmap("%-2d")
+ assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%100d")
+ assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%-100d")
+ end
+
+ def test_x_returns_extension
+ assert_equal "", "abc".pathmap("%x")
+ assert_equal ".rb", "abc.rb".pathmap("%x")
+ assert_equal ".rb", "abc.xyz.rb".pathmap("%x")
+ assert_equal "", ".depends".pathmap("%x")
+ assert_equal "", "dir/.depends".pathmap("%x")
+ end
+
+ def test_X_returns_everything_but_extension
+ assert_equal "abc", "abc".pathmap("%X")
+ assert_equal "abc", "abc.rb".pathmap("%X")
+ assert_equal "abc.xyz", "abc.xyz.rb".pathmap("%X")
+ assert_equal "ab.xyz", "ab.xyz.rb".pathmap("%X")
+ assert_equal "a.xyz", "a.xyz.rb".pathmap("%X")
+ assert_equal "abc", "abc.rb".pathmap("%X")
+ assert_equal "ab", "ab.rb".pathmap("%X")
+ assert_equal "a", "a.rb".pathmap("%X")
+ assert_equal ".depends", ".depends".pathmap("%X")
+ assert_equal "a/dir/.depends", "a/dir/.depends".pathmap("%X")
+ assert_equal "/.depends", "/.depends".pathmap("%X")
+ end
+
+ def test_p_returns_entire_pathname
+ assert_equal "abc.rb", "abc.rb".pathmap("%p")
+ assert_equal "this/is/a/dir/abc.rb", "this/is/a/dir/abc.rb".pathmap("%p")
+ assert_equal "/this/is/a/dir/abc.rb", "/this/is/a/dir/abc.rb".pathmap("%p")
+ end
+
+ def test_dash_returns_empty_string
+ assert_equal "", "abc.rb".pathmap("%-")
+ assert_equal "abc.rb", "abc.rb".pathmap("%X%-%x")
+ end
+
+ def test_percent_percent_returns_percent
+ assert_equal "a%b", "".pathmap("a%%b")
+ end
+
+ def test_undefined_percent_causes_error
+ ex = assert_exception(ArgumentError) {
+ "dir/abc.rb".pathmap("%z")
+ }
+ end
+
+ def test_pattern_returns_substitutions
+ assert_equal "bin/org/osb",
+ "src/org/osb/Xyz.java".pathmap("%{src,bin}d")
+ end
+
+ def test_pattern_can_use_backreferences
+ assert_equal "dir/hi/is", "dir/this/is".pathmap("%{t(hi)s,\\1}p")
+ end
+
+ def test_pattern_with_star_replacement_string_uses_block
+ assert_equal "src/ORG/osb",
+ "src/org/osb/Xyz.java".pathmap("%{/org,*}d") { |d| d.upcase }
+ assert_equal "Xyz.java",
+ "src/org/osb/Xyz.java".pathmap("%{.*,*}f") { |f| f.capitalize }
+ end
+
+ def test_pattern_with_no_replacement_nor_block_substitutes_empty_string
+ assert_equal "bc.rb", "abc.rb".pathmap("%{a}f")
+ end
+
+ def test_pattern_works_with_certain_valid_operators
+ assert_equal "dir/xbc.rb", "dir/abc.rb".pathmap("%{a,x}p")
+ assert_equal "d1r", "dir/abc.rb".pathmap("%{i,1}d")
+ assert_equal "xbc.rb", "dir/abc.rb".pathmap("%{a,x}f")
+ assert_equal ".Rb", "dir/abc.rb".pathmap("%{r,R}x")
+ assert_equal "xbc", "dir/abc.rb".pathmap("%{a,x}n")
+ end
+
+ def test_multiple_patterns
+ assert_equal "this/is/b/directory/abc.rb",
+ "this/is/a/dir/abc.rb".pathmap("%{a,b;dir,\\0ectory}p")
+ end
+
+ def test_partial_directory_selection_works_with_patterns
+ assert_equal "this/is/a/long",
+ "this/is/a/really/long/path/ok.rb".pathmap("%{/really/,/}5d")
+ end
+
+ def test_pattern_with_invalid_operator
+ ex = assert_exception(ArgumentError) do
+ "abc.xyz".pathmap("%{src,bin}z")
+ end
+ assert_match(/unknown.*pathmap.*spec.*z/i, ex.message)
+ end
+
+ def test_works_with_windows_separators
+ if File::ALT_SEPARATOR
+ assert_equal "abc", 'dir\abc.rb'.pathmap("%n")
+ assert_equal 'this\is\a\dir',
+ 'this\is\a\dir\abc.rb'.pathmap("%d")
+ end
+ end
+
+ def test_complex_patterns
+ sep = "".pathmap("%s")
+ assert_equal "dir/abc.rb", "dir/abc.rb".pathmap("%d/%n%x")
+ assert_equal "./abc.rb", "abc.rb".pathmap("%d/%n%x")
+ assert_equal "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")
+ assert_equal "src_work/bin/org/onstepback/proj/A.class",
+ "src_work/src/org/onstepback/proj/A.java".pathmap('%{\bsrc\b,bin}X.class')
+ assert_equal ".depends.bak", ".depends".pathmap("%X.bak")
+ assert_equal "d#{sep}a/b/c#{sep}file.txt", "a/b/c/d/file.txt".pathmap("%-1d%s%3d%s%f")
+ end
+end
+
+class TestPathMapExplode < Test::Unit::TestCase
+ def setup
+ String.class_eval { public :pathmap_explode }
+ end
+
+ def teardown
+ String.class_eval { protected :pathmap_explode }
+ 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
+ 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
+ end
+ end
+end
+
+class TestPathMapPartial < Test::Unit::TestCase
+ def test_pathmap_partial
+ @path = "1/2/file"
+ def @path.call(n)
+ pathmap_partial(n)
+ end
+ assert_equal("1", @path.call(1))
+ assert_equal("1/2", @path.call(2))
+ assert_equal("1/2", @path.call(3))
+ assert_equal(".", @path.call(0))
+ assert_equal("2", @path.call(-1))
+ assert_equal("1/2", @path.call(-2))
+ assert_equal("1/2", @path.call(-3))
+ end
+end
+
+class TestFileListPathMap < Test::Unit::TestCase
+ def test_file_list_supports_pathmap
+ assert_equal ['a', 'b'], FileList['dir/a.rb', 'dir/b.rb'].pathmap("%n")
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/pseudo_status_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/pseudo_status_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/pseudo_status_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'rake'
+
+require 'test/capture_stdout'
+require 'test/rake_test_setup'
+
+class PseudoStatusTest < Test::Unit::TestCase
+ def test_with_zero_exit_status
+ s = Rake::PseudoStatus.new
+ assert_equal 0, s.exitstatus
+ assert_equal 0, s.to_i
+ assert_equal 0, s >> 8
+ assert ! s.stopped?
+ assert s.exited?
+ end
+ def test_with_99_exit_status
+ s = Rake::PseudoStatus.new(99)
+ assert_equal 99, s.exitstatus
+ assert_equal 25344, s.to_i
+ assert_equal 99, s >> 8
+ assert ! s.stopped?
+ assert s.exited?
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/rake_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/rake_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/rake_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,41 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'rake'
+
+class TestRake < Test::Unit::TestCase
+ 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')
+ 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')
+ 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')
+ end
+ end
+
+ def alldirs(fn)
+ result = []
+ Rake.each_dir_parent(fn) { |d| result << d }
+ result
+ end
+
+ def test_can_override_application
+ old_app = Rake.application
+ fake_app = Object.new
+ Rake.application = fake_app
+ assert_equal fake_app, Rake.application
+ ensure
+ Rake.application = old_app
+ end
+
+ def test_original_dir_reports_current_dir
+ assert_equal Dir.pwd, Rake.original_dir
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/rdoc_task_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/rdoc_task_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/rdoc_task_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,88 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'rake/rdoctask'
+require 'test/rake_test_setup'
+
+class TestRDocTask < Test::Unit::TestCase
+ include Rake
+ include TestMethods
+
+ def setup
+ Task.clear
+ end
+
+ def test_tasks_creation
+ Rake::RDocTask.new
+ assert Task[:rdoc]
+ assert Task[:clobber_rdoc]
+ assert Task[:rerdoc]
+ end
+
+ def test_tasks_creation_with_custom_name_symbol
+ rd = Rake::RDocTask.new(:rdoc_dev)
+ assert Task[:rdoc_dev]
+ assert Task[:clobber_rdoc_dev]
+ assert Task[:rerdoc_dev]
+ assert_equal :rdoc_dev, rd.name
+ end
+
+ def test_tasks_creation_with_custom_name_string
+ rd = Rake::RDocTask.new("rdoc_dev")
+ assert Task[:rdoc_dev]
+ assert Task[:clobber_rdoc_dev]
+ assert Task[:rerdoc_dev]
+ assert_equal "rdoc_dev", rd.name
+ end
+
+ def test_tasks_creation_with_custom_name_hash
+ options = { :rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force" }
+ rd = Rake::RDocTask.new(options)
+ assert Task[:"rdoc"]
+ assert Task[:"rdoc:clean"]
+ assert Task[:"rdoc:force"]
+ assert_raises(RuntimeError) { Task[:clobber_rdoc] }
+ assert_equal options, rd.name
+ end
+
+ def test_tasks_creation_with_custom_name_hash_will_use_default_if_an_option_isnt_given
+ rd = Rake::RDocTask.new(:clobber_rdoc => "rdoc:clean")
+ assert Task[:rdoc]
+ assert Task[:"rdoc:clean"]
+ assert Task[:rerdoc]
+ end
+
+ def test_tasks_creation_with_custom_name_hash_raises_exception_if_invalid_option_given
+ assert_raises(ArgumentError) do
+ Rake::RDocTask.new(:foo => "bar")
+ end
+
+ begin
+ Rake::RDocTask.new(:foo => "bar")
+ rescue ArgumentError => e
+ assert_match(/foo/, e.message)
+ end
+ end
+
+ def test_inline_source_is_enabled_by_default
+ rd = Rake::RDocTask.new
+ assert rd.option_list.include?('--inline-source')
+ end
+
+ def test_inline_source_option_is_only_appended_if_option_not_already_given
+ rd = Rake::RDocTask.new
+ rd.options << '--inline-source'
+ assert_equal 1, rd.option_list.grep('--inline-source').size
+
+ rd = Rake::RDocTask.new
+ rd.options << '-S'
+ assert_equal 1, rd.option_list.grep('-S').size
+ assert_equal 0, rd.option_list.grep('--inline-source').size
+ end
+
+ def test_inline_source_option_can_be_disabled
+ rd = Rake::RDocTask.new
+ rd.inline_source = false
+ assert !rd.option_list.include?('--inline-source')
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/require_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/require_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/require_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,35 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'rake'
+require 'test/rake_test_setup'
+
+# ====================================================================
+class TestRequire < Test::Unit::TestCase
+ include TestMethods
+
+ def test_can_load_rake_library
+ app = Rake::Application.new
+ assert app.instance_eval {
+ rake_require("test2", ['test/data/rakelib'], [])
+ }
+ end
+
+ def test_wont_reload_rake_library
+ app = Rake::Application.new
+ assert ! app.instance_eval {
+ rake_require("test2", ['test/data/rakelib'], ['test2'])
+ }
+ end
+
+ def test_throws_error_if_library_not_found
+ app = Rake::Application.new
+ ex = assert_exception(LoadError) {
+ assert app.instance_eval {
+ rake_require("testx", ['test/data/rakelib'], [])
+ }
+ }
+ assert_match(/x/, ex.message)
+ end
+end
+
Added: MacRuby/trunk/test/libs/rake/test/lib/rules_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/rules_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/rules_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,349 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'fileutils'
+require 'rake'
+require 'test/filecreation'
+require 'test/rake_test_setup'
+
+######################################################################
+class TestRules < Test::Unit::TestCase
+ include Rake
+ include FileCreation
+ include TestMethods
+
+ SRCFILE = "testdata/abc.c"
+ SRCFILE2 = "testdata/xyz.c"
+ FTNFILE = "testdata/abc.f"
+ OBJFILE = "testdata/abc.o"
+ FOOFILE = "testdata/foo"
+ DOTFOOFILE = "testdata/.foo"
+
+ def setup
+ Task.clear
+ @runs = []
+ end
+
+ def teardown
+ FileList['testdata/*'].uniq.each do |f| rm_r(f, :verbose=>false) end
+ end
+
+ 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
+ t = Task[OBJFILE]
+ t.invoke
+ Task[OBJFILE].invoke
+ assert_equal [:F], @runs
+ end
+
+ 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
+ Task[OBJFILE].invoke
+ assert_equal [:F], @runs
+ end
+
+ def test_create_with_source
+ create_file(SRCFILE)
+ rule(/\.o$/ => ['.c']) do |t|
+ @runs << t.name
+ assert_equal OBJFILE, t.name
+ assert_equal SRCFILE, t.source
+ end
+ Task[OBJFILE].invoke
+ assert_equal [OBJFILE], @runs
+ end
+
+ def test_single_dependent
+ create_file(SRCFILE)
+ rule(/\.o$/ => '.c') do |t|
+ @runs << t.name
+ end
+ Task[OBJFILE].invoke
+ assert_equal [OBJFILE], @runs
+ end
+
+ def test_rule_can_be_created_by_string
+ create_file(SRCFILE)
+ rule '.o' => ['.c'] do |t|
+ @runs << t.name
+ end
+ Task[OBJFILE].invoke
+ assert_equal [OBJFILE], @runs
+ end
+
+ def test_rule_prereqs_can_be_created_by_string
+ create_file(SRCFILE)
+ rule '.o' => '.c' do |t|
+ @runs << t.name
+ end
+ Task[OBJFILE].invoke
+ assert_equal [OBJFILE], @runs
+ end
+
+ def test_plain_strings_as_dependents_refer_to_files
+ create_file(SRCFILE)
+ rule '.o' => SRCFILE do |t|
+ @runs << t.name
+ end
+ Task[OBJFILE].invoke
+ assert_equal [OBJFILE], @runs
+ end
+
+ def test_file_names_beginning_with_dot_can_be_tricked_into_refering_to_file
+ verbose(false) do
+ chdir("testdata") do
+ create_file('.foo')
+ rule '.o' => "./.foo" do |t|
+ @runs << t.name
+ end
+ Task[OBJFILE].invoke
+ assert_equal [OBJFILE], @runs
+ end
+ end
+ end
+
+ def test_file_names_beginning_with_dot_can_be_wrapped_in_lambda
+ verbose(false) do
+ chdir("testdata") do
+ create_file(".foo")
+ rule '.o' => lambda{".foo"} do |t|
+ @runs << "#{t.name} - #{t.source}"
+ end
+ Task[OBJFILE].invoke
+ assert_equal ["#{OBJFILE} - .foo"], @runs
+ end
+ end
+ end
+
+ def test_file_names_containing_percent_can_be_wrapped_in_lambda
+ verbose(false) do
+ chdir("testdata") do
+ create_file("foo%x")
+ rule '.o' => lambda{"foo%x"} do |t|
+ @runs << "#{t.name} - #{t.source}"
+ end
+ Task[OBJFILE].invoke
+ assert_equal ["#{OBJFILE} - foo%x"], @runs
+ end
+ end
+ end
+
+ def test_non_extension_rule_name_refers_to_file
+ verbose(false) do
+ chdir("testdata") do
+ create_file("abc.c")
+ rule "abc" => '.c' do |t|
+ @runs << t.name
+ end
+ Task["abc"].invoke
+ assert_equal ["abc"], @runs
+ end
+ end
+ end
+
+ def test_pathmap_automatically_applies_to_name
+ verbose(false) do
+ chdir("testdata") do
+ create_file("zzabc.c")
+ rule ".o" => 'zz%{x,a}n.c' do |t|
+ @runs << "#{t.name} - #{t.source}"
+ end
+ Task["xbc.o"].invoke
+ assert_equal ["xbc.o - zzabc.c"], @runs
+ end
+ end
+ end
+
+ def test_plain_strings_are_just_filenames
+ verbose(false) do
+ chdir("testdata") do
+ create_file("plainname")
+ rule ".o" => 'plainname' do |t|
+ @runs << "#{t.name} - #{t.source}"
+ end
+ Task["xbc.o"].invoke
+ assert_equal ["xbc.o - plainname"], @runs
+ end
+ end
+ end
+
+ def test_rule_runs_when_explicit_task_has_no_actions
+ create_file(SRCFILE)
+ create_file(SRCFILE2)
+ delete_file(OBJFILE)
+ rule '.o' => '.c' do |t|
+ @runs << t.source
+ end
+ file OBJFILE => [SRCFILE2]
+ Task[OBJFILE].invoke
+ assert_equal [SRCFILE], @runs
+ end
+
+ def test_close_matches_on_name_do_not_trigger_rule
+ create_file("testdata/x.c")
+ rule '.o' => ['.c'] do |t|
+ @runs << t.name
+ end
+ assert_exception(RuntimeError) { Task['testdata/x.obj'].invoke }
+ assert_exception(RuntimeError) { Task['testdata/x.xyo'].invoke }
+ end
+
+ def test_rule_rebuilds_obj_when_source_is_newer
+ create_timed_files(OBJFILE, SRCFILE)
+ rule(/\.o$/ => ['.c']) do
+ @runs << :RULE
+ end
+ Task[OBJFILE].invoke
+ assert_equal [:RULE], @runs
+ end
+
+ def test_rule_with_two_sources_runs_if_both_sources_are_present
+ create_timed_files(OBJFILE, SRCFILE, SRCFILE2)
+ rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
+ @runs << :RULE
+ end
+ Task[OBJFILE].invoke
+ assert_equal [:RULE], @runs
+ end
+
+ def test_rule_with_two_sources_but_one_missing_does_not_run
+ create_timed_files(OBJFILE, SRCFILE)
+ delete_file(SRCFILE2)
+ rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
+ @runs << :RULE
+ end
+ Task[OBJFILE].invoke
+ assert_equal [], @runs
+ end
+
+ def test_rule_with_two_sources_builds_both_sources
+ task 'x.aa'
+ task 'x.bb'
+ rule '.a' => '.aa' do
+ @runs << "A"
+ end
+ rule '.b' => '.bb' do
+ @runs << "B"
+ end
+ rule ".c" => ['.a', '.b'] do
+ @runs << "C"
+ end
+ Task["x.c"].invoke
+ assert_equal ["A", "B", "C"], @runs.sort
+ end
+
+ def test_second_rule_runs_when_first_rule_doesnt
+ create_timed_files(OBJFILE, SRCFILE)
+ delete_file(SRCFILE2)
+ rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
+ @runs << :RULE1
+ end
+ rule OBJFILE => [lambda{SRCFILE}] do
+ @runs << :RULE2
+ end
+ Task[OBJFILE].invoke
+ assert_equal [:RULE2], @runs
+ end
+
+ def test_second_rule_doest_run_if_first_triggers
+ create_timed_files(OBJFILE, SRCFILE, SRCFILE2)
+ rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
+ @runs << :RULE1
+ end
+ rule OBJFILE => [lambda{SRCFILE}] do
+ @runs << :RULE2
+ end
+ Task[OBJFILE].invoke
+ assert_equal [:RULE1], @runs
+ end
+
+ def test_second_rule_doest_run_if_first_triggers_with_reversed_rules
+ create_timed_files(OBJFILE, SRCFILE, SRCFILE2)
+ rule OBJFILE => [lambda{SRCFILE}] do
+ @runs << :RULE1
+ end
+ rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
+ @runs << :RULE2
+ end
+ Task[OBJFILE].invoke
+ assert_equal [:RULE1], @runs
+ end
+
+ def test_rule_with_proc_dependent_will_trigger
+ ran = false
+ mkdir_p("testdata/src/jw")
+ create_file("testdata/src/jw/X.java")
+ rule %r(classes/.*\.class) => [
+ proc { |fn| fn.pathmap("%{classes,testdata/src}d/%n.java") }
+ ] do |task|
+ assert_equal task.name, 'classes/jw/X.class'
+ assert_equal task.source, 'testdata/src/jw/X.java'
+ @runs << :RULE
+ end
+ Task['classes/jw/X.class'].invoke
+ assert_equal [:RULE], @runs
+ ensure
+ rm_r("testdata/src", :verbose=>false) rescue nil
+ end
+
+ def test_proc_returning_lists_are_flattened_into_prereqs
+ ran = false
+ mkdir_p("testdata/flatten")
+ create_file("testdata/flatten/a.txt")
+ task 'testdata/flatten/b.data' do |t|
+ ran = true
+ touch t.name, :verbose => false
+ end
+ rule '.html' =>
+ proc { |fn|
+ [
+ fn.ext("txt"),
+ "testdata/flatten/b.data"
+ ]
+ } do |task|
+ end
+ Task['testdata/flatten/a.html'].invoke
+ assert ran, "Should have triggered flattened dependency"
+ ensure
+ rm_r("testdata/flatten", :verbose=>false) rescue nil
+ end
+
+ def test_recursive_rules_will_work_as_long_as_they_terminate
+ actions = []
+ create_file("testdata/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
+ Task["testdata/abc.exe"].invoke
+ assert_equal ['y', 'c', 'o', 'exe'], actions
+ end
+
+ def test_recursive_rules_that_dont_terminate_will_overflow
+ create_file("testdata/a.a")
+ prev = 'a'
+ ('b'..'z').each do |letter|
+ rule ".#{letter}" => ".#{prev}" do |t| puts "#{t.name}" end
+ prev = letter
+ end
+ ex = assert_exception(Rake::RuleRecursionOverflowError) {
+ Task["testdata/a.z"].invoke
+ }
+ assert_match(/a\.z => testdata\/a.y/, ex.message)
+ end
+
+ def test_rules_with_bad_dependents_will_fail
+ rule "a" => [ 1 ] do |t| puts t.name end
+ assert_exception(RuntimeError) do Task['a'].invoke end
+ end
+
+end
+
Added: MacRuby/trunk/test/libs/rake/test/lib/task_arguments_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/task_arguments_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/task_arguments_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,89 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'rake'
+
+######################################################################
+class TestTaskArguments < Test::Unit::TestCase
+ def teardown
+ ENV.delete('rev')
+ ENV.delete('VER')
+ end
+
+ def test_empty_arg_list_is_empty
+ ta = Rake::TaskArguments.new([], [])
+ assert_equal({}, ta.to_hash)
+ end
+
+ 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)
+ 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
+ end
+
+ def test_enumerable_behavior
+ ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2 ,3])
+ assert_equal [10, 20, 30], ta.collect { |k,v| v * 10 }.sort
+ end
+
+ def test_named_args
+ ta = Rake::TaskArguments.new(["aa", "bb"], [1, 2])
+ assert_equal 1, ta.aa
+ assert_equal 1, ta[:aa]
+ assert_equal 1, ta["aa"]
+ assert_equal 2, ta.bb
+ assert_nil ta.cc
+ end
+
+ def test_args_knows_its_names
+ ta = Rake::TaskArguments.new(["aa", "bb"], [1, 2])
+ assert_equal ["aa", "bb"], ta.names
+ end
+
+ def test_extra_names_are_nil
+ ta = Rake::TaskArguments.new(["aa", "bb", "cc"], [1, 2])
+ assert_nil ta.cc
+ end
+
+ def test_args_can_reference_env_values
+ ta = Rake::TaskArguments.new(["aa"], [1])
+ ENV['rev'] = "1.2"
+ ENV['VER'] = "2.3"
+ assert_equal "1.2", ta.rev
+ assert_equal "2.3", 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)
+ assert_equal 1, child.p
+ assert_equal 1, child["p"]
+ assert_equal 1, child[:p]
+ assert_nil child.c
+ end
+
+ def test_child_hides_parent_arg_names
+ 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]
+ end
+
+ def test_default_arguements_that_dont_match_names_are_ignored
+ ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"])
+ ta.with_defaults({ "cc" => "default_val" })
+ assert_nil ta[:cc]
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/task_manager_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/task_manager_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/task_manager_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,173 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'rake'
+require 'test/rake_test_setup'
+
+class TaskManager
+ include Rake::TaskManager
+end
+
+class TestTaskManager < Test::Unit::TestCase
+ include TestMethods
+
+ def setup
+ @tm = TaskManager.new
+ end
+
+ def test_create_task_manager
+ assert_not_nil @tm
+ assert_equal [], @tm.tasks
+ end
+
+ def test_define_task
+ t = @tm.define_task(Rake::Task, :t)
+ assert_equal "t", t.name
+ assert_equal @tm, t.application
+ end
+
+ def test_name_lookup
+ t = @tm.define_task(Rake::Task, :t)
+ assert_equal t, @tm[:t]
+ end
+
+ def test_namespace_task_create
+ @tm.in_namespace("x") do
+ t = @tm.define_task(Rake::Task, :t)
+ assert_equal "x:t", t.name
+ end
+ assert_equal ["x:t"], @tm.tasks.collect { |t| t.name }
+ end
+
+ def test_anonymous_namespace
+ anon_ns = @tm.in_namespace(nil) do
+ t = @tm.define_task(Rake::Task, :t)
+ assert_equal "_anon_1:t", t.name
+ end
+ task = anon_ns[:t]
+ assert_equal "_anon_1:t", task.name
+ end
+
+ def test_create_filetask_in_namespace
+ @tm.in_namespace("x") do
+ t = @tm.define_task(Rake::FileTask, "fn")
+ assert_equal "fn", t.name
+ end
+ assert_equal ["fn"], @tm.tasks.collect { |t| t.name }
+ end
+
+ def test_namespace_yields_same_namespace_as_returned
+ yielded_namespace = nil
+ returned_namespace = @tm.in_namespace("x") do |ns|
+ yielded_namespace = ns
+ end
+ assert_equal returned_namespace, yielded_namespace
+ end
+
+ def test_name_lookup_with_implicit_file_tasks
+ t = @tm["README.rdoc"]
+ assert_equal "README.rdoc", t.name
+ assert Rake::FileTask === t
+ end
+
+ def test_name_lookup_with_nonexistent_task
+ assert_exception(RuntimeError) {
+ t = @tm["DOES NOT EXIST"]
+ }
+ end
+
+ def test_name_lookup_in_multiple_scopes
+ aa = nil
+ bb = nil
+ xx = @tm.define_task(Rake::Task, :xx)
+ top_z = @tm.define_task(Rake::Task, :z)
+ @tm.in_namespace("a") do
+ aa = @tm.define_task(Rake::Task, :aa)
+ mid_z = @tm.define_task(Rake::Task, :z)
+ @tm.in_namespace("b") do
+ bb = @tm.define_task(Rake::Task, :bb)
+ bot_z = @tm.define_task(Rake::Task, :z)
+
+ assert_equal ["a", "b"], @tm.current_scope
+
+ assert_equal bb, @tm["a:b:bb"]
+ assert_equal aa, @tm["a:aa"]
+ assert_equal xx, @tm["xx"]
+ assert_equal bot_z, @tm["z"]
+ assert_equal mid_z, @tm["^z"]
+ assert_equal top_z, @tm["^^z"]
+ assert_equal top_z, @tm["rake:z"]
+ end
+
+ assert_equal ["a"], @tm.current_scope
+
+ assert_equal bb, @tm["a:b:bb"]
+ assert_equal aa, @tm["a:aa"]
+ assert_equal xx, @tm["xx"]
+ assert_equal bb, @tm["b:bb"]
+ assert_equal aa, @tm["aa"]
+ assert_equal mid_z, @tm["z"]
+ assert_equal top_z, @tm["^z"]
+ assert_equal top_z, @tm["rake:z"]
+ end
+
+ assert_equal [], @tm.current_scope
+
+ assert_equal [], xx.scope
+ assert_equal ['a'], aa.scope
+ assert_equal ['a', 'b'], bb.scope
+ end
+
+ def test_lookup_with_explicit_scopes
+ t1, t2, t3, s = (0...4).collect { nil }
+ t1 = @tm.define_task(Rake::Task, :t)
+ @tm.in_namespace("a") do
+ t2 = @tm.define_task(Rake::Task, :t)
+ s = @tm.define_task(Rake::Task, :s)
+ @tm.in_namespace("b") do
+ t3 = @tm.define_task(Rake::Task, :t)
+ end
+ end
+ assert_equal t1, @tm[:t, []]
+ assert_equal t2, @tm[:t, ["a"]]
+ assert_equal t3, @tm[:t, ["a", "b"]]
+ assert_equal s, @tm[:s, ["a", "b"]]
+ assert_equal s, @tm[:s, ["a"]]
+ end
+
+ def test_correctly_scoped_prerequisites_are_invoked
+ values = []
+ @tm = Rake::Application.new
+ @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)
+ end
+
+ @tm["a:x"].invoke
+ assert_equal ["next z"], values
+ end
+
+end
+
+class TestTaskManagerArgumentResolution < Test::Unit::TestCase
+ 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, [:a, :b], []], task(:t, :a, :b)
+ assert_equal [:t, [], [:x]], task(:t, :needs => :x)
+ assert_equal [:t, [:a, :b], [:x]], task(:t, :a, :b, :needs => :x)
+ assert_equal [:t, [:a, :b], [:x, :y]], task(:t, :a, :b, :needs => [: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])
+ end
+
+ def task(*args)
+ tm = TaskManager.new
+ tm.resolve_args(args)
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/task_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/task_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/task_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,376 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'fileutils'
+require 'rake'
+require 'test/filecreation'
+require 'test/capture_stdout'
+require 'test/rake_test_setup'
+
+######################################################################
+class TestTask < Test::Unit::TestCase
+ include CaptureStdout
+ include Rake
+ include TestMethods
+
+ def setup
+ Task.clear
+ end
+
+ def test_create
+ arg = nil
+ t = task(:name) { |task| arg = task; 1234 }
+ assert_equal "name", t.name
+ assert_equal [], t.prerequisites
+ assert t.needed?
+ t.execute(0)
+ assert_equal t, arg
+ assert_nil t.source
+ assert_equal [], t.sources
+ assert_equal 1, t.locations.size
+ assert_match(/#{Regexp.quote(__FILE__)}/, t.locations.first)
+ end
+
+ def test_inspect
+ t = task(:foo, :needs => [:bar, :baz])
+ assert_equal "<Rake::Task foo => [bar, baz]>", t.inspect
+ end
+
+ def test_invoke
+ runlist = []
+ t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
+ t2 = task(:t2) { |t| runlist << t.name }
+ t3 = task(:t3) { |t| runlist << t.name }
+ assert_equal ["t2", "t3"], t1.prerequisites
+ t1.invoke
+ assert_equal ["t2", "t3", "t1"], runlist
+ end
+
+ def test_invoke_with_circular_dependencies
+ runlist = []
+ 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_exception RuntimeError do
+ t1.invoke
+ end
+ assert_match(/circular dependency/i, ex.message)
+ assert_match(/t1 => t2 => t1/, ex.message)
+ end
+
+ def test_dry_run_prevents_actions
+ Rake.application.options.dryrun = true
+ runlist = []
+ t1 = task(:t1) { |t| runlist << t.name; 3321 }
+ out = capture_stdout { t1.invoke }
+ assert_match(/execute .*t1/i, out)
+ assert_match(/dry run/i, out)
+ assert_no_match(/invoke/i, out)
+ assert_equal [], runlist
+ ensure
+ Rake.application.options.dryrun = false
+ end
+
+ def test_tasks_can_be_traced
+ Rake.application.options.trace = true
+ t1 = task(:t1)
+ out = capture_stdout {
+ t1.invoke
+ }
+ assert_match(/invoke t1/i, out)
+ assert_match(/execute t1/i, out)
+ ensure
+ Rake.application.options.trace = false
+ end
+
+ def test_no_double_invoke
+ runlist = []
+ t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
+ t2 = task(:t2 => [:t3]) { |t| runlist << t.name }
+ t3 = task(:t3) { |t| runlist << t.name }
+ t1.invoke
+ assert_equal ["t3", "t2", "t1"], runlist
+ end
+
+ def test_can_double_invoke_with_reenable
+ runlist = []
+ t1 = task(:t1) { |t| runlist << t.name }
+ t1.invoke
+ t1.reenable
+ t1.invoke
+ assert_equal ["t1", "t1"], runlist
+ end
+
+ def test_clear
+ t = task("t" => "a") { }
+ t.clear
+ assert t.prerequisites.empty?, "prerequisites should be empty"
+ assert t.actions.empty?, "actions should be empty"
+ end
+
+ def test_clear_prerequisites
+ t = task("t" => ["a", "b"])
+ assert_equal ['a', 'b'], t.prerequisites
+ t.clear_prerequisites
+ assert_equal [], t.prerequisites
+ end
+
+ def test_clear_actions
+ t = task("t") { }
+ t.clear_actions
+ assert t.actions.empty?, "actions should be empty"
+ end
+
+ def test_find
+ task :tfind
+ assert_equal "tfind", Task[:tfind].name
+ ex = assert_exception(RuntimeError) { Task[:leaves] }
+ assert_equal "Don't know how to build task 'leaves'", ex.message
+ end
+
+ def test_defined
+ assert ! Task.task_defined?(:a)
+ task :a
+ assert Task.task_defined?(:a)
+ end
+
+ def test_multi_invocations
+ runs = []
+ p = proc do |t| runs << t.name end
+ task({:t1=>[:t2,:t3]}, &p)
+ task({:t2=>[:t3]}, &p)
+ task(:t3, &p)
+ Task[:t1].invoke
+ assert_equal ["t1", "t2", "t3"], runs.sort
+ end
+
+ def test_task_list
+ task :t2
+ task :t1 => [:t2]
+ assert_equal ["t1", "t2"], Task.tasks.collect {|t| t.name}
+ end
+
+ def test_task_gives_name_on_to_s
+ task :abc
+ assert_equal "abc", Task[:abc].to_s
+ end
+
+ def test_symbols_can_be_prerequisites
+ task :a => :b
+ assert_equal ["b"], Task[:a].prerequisites
+ end
+
+ def test_strings_can_be_prerequisites
+ task :a => "b"
+ assert_equal ["b"], Task[:a].prerequisites
+ end
+
+ def test_arrays_can_be_prerequisites
+ 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")
+ assert_equal ["b", "c"], Task[:a].prerequisites
+ end
+
+ def test_investigation_output
+ t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
+ task(:t2)
+ task(:t3)
+ out = t1.investigation
+ assert_match(/class:\s*Rake::Task/, out)
+ assert_match(/needed:\s*true/, out)
+ assert_match(/pre-requisites:\s*--t[23]/, out)
+ end
+
+
+ def test_extended_comments
+ desc %{
+ This is a comment.
+
+ And this is the extended comment.
+ name -- Name of task to execute.
+ rev -- Software revision to use.
+ }
+ t = task(:t, :name, :rev)
+ assert_equal "[name,rev]", t.arg_description
+ assert_equal "This is a comment.", t.comment
+ assert_match(/^\s*name -- Name/, t.full_comment)
+ assert_match(/^\s*rev -- Software/, t.full_comment)
+ assert_match(/\A\s*This is a comment\.$/, t.full_comment)
+ end
+
+ def test_multiple_comments
+ desc "line one"
+ t = task(:t)
+ desc "line two"
+ task(:t)
+ assert_equal "line one / line two", t.comment
+ end
+
+ def test_settable_comments
+ t = task(:t)
+ t.comment = "HI"
+ assert_equal "HI", t.comment
+ end
+end
+
+######################################################################
+class TestTaskWithArguments < Test::Unit::TestCase
+ include CaptureStdout
+ include Rake
+ include TestMethods
+
+ def setup
+ Task.clear
+ end
+
+ def test_no_args_given
+ t = task :t
+ assert_equal [], t.arg_names
+ end
+
+ def test_args_given
+ t = task :t, :a, :b
+ assert_equal [:a, :b], t.arg_names
+ end
+
+ def test_name_and_needs
+ t = task(:t => [:pre])
+ assert_equal "t", t.name
+ assert_equal [], t.arg_names
+ assert_equal ["pre"], t.prerequisites
+ end
+
+ def test_name_and_explicit_needs
+ t = task(:t, :needs => [:pre])
+ assert_equal "t", t.name
+ assert_equal [], t.arg_names
+ assert_equal ["pre"], t.prerequisites
+ end
+
+ def test_name_args_and_explicit_needs
+ t = task(:t, :x, :y, :needs => [:pre])
+ assert_equal "t", t.name
+ assert_equal [:x, :y], t.arg_names
+ assert_equal ["pre"], t.prerequisites
+ end
+
+ def test_illegal_keys_in_task_name_hash
+ assert_exception RuntimeError do
+ t = task(:t, :x, :y => 1, :needs => [:pre])
+ end
+ end
+
+ def test_arg_list_is_empty_if_no_args_given
+ t = task(:t) { |tt, args| assert_equal({}, args.to_hash) }
+ t.invoke(1, 2, 3)
+ end
+
+ 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 1, args[:a]
+ assert_equal 2, args[:b]
+ assert_equal 3, args[:c]
+ assert_equal 1, args.a
+ assert_equal 2, args.b
+ assert_equal 3, args.c
+ end
+ t.invoke(1, 2, 3)
+ end
+
+ def test_actions_of_various_arity_are_ok_with_args
+ notes = []
+ t = task(:t, :x) do
+ notes << :a
+ end
+ t.enhance do | |
+ notes << :b
+ end
+ t.enhance do |task|
+ notes << :c
+ assert_kind_of Task, task
+ end
+ t.enhance do |t2, args|
+ notes << :d
+ assert_equal t, t2
+ assert_equal({:x => 1}, args.to_hash)
+ end
+ assert_nothing_raised do t.invoke(1) end
+ assert_equal [:a, :b, :c, :d], notes
+ end
+
+ def test_arguments_are_passed_to_block
+ t = task(:t, :a, :b) { |tt, args|
+ assert_equal( { :a => 1, :b => 2 }, args.to_hash )
+ }
+ t.invoke(1, 2)
+ end
+
+ def test_extra_parameters_are_ignored
+ t = task(:t, :a) { |tt, args|
+ assert_equal 1, args.a
+ assert_nil args.b
+ }
+ t.invoke(1, 2)
+ end
+
+ def test_arguments_are_passed_to_all_blocks
+ counter = 0
+ t = task :t, :a
+ task :t do |tt, args|
+ assert_equal 1, args.a
+ counter += 1
+ end
+ task :t do |tt, args|
+ assert_equal 1, args.a
+ counter += 1
+ end
+ t.invoke(1)
+ assert_equal 2, counter
+ end
+
+ def test_block_with_no_parameters_is_ok
+ t = task(:t) { }
+ t.invoke(1, 2)
+ end
+
+ def test_name_with_args
+ desc "T"
+ t = task(:tt, :a, :b)
+ assert_equal "tt", t.name
+ assert_equal "T", t.comment
+ assert_equal "[a,b]", t.arg_description
+ assert_equal "tt[a,b]", t.name_with_args
+ assert_equal [:a, :b],t.arg_names
+ end
+
+ def test_named_args_are_passed_to_prereqs
+ value = nil
+ pre = task(:pre, :rev) { |t, args| value = args.rev }
+ t = task(:t, :name, :rev, :needs => [:pre])
+ t.invoke("bill", "1.2")
+ assert_equal "1.2", value
+ end
+
+ def test_args_not_passed_if_no_prereq_names
+ pre = task(:pre) { |t, args|
+ assert_equal({}, args.to_hash)
+ assert_equal "bill", args.name
+ }
+ t = task(:t, :name, :rev, :needs => [:pre])
+ t.invoke("bill", "1.2")
+ end
+
+ def test_args_not_passed_if_no_arg_names
+ pre = task(:pre, :rev) { |t, args|
+ assert_equal({}, args.to_hash)
+ }
+ t = task(:t, :needs => [:pre])
+ t.invoke("bill", "1.2")
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/tasklib_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/tasklib_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/tasklib_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,12 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'rake/tasklib'
+
+
+class TestTaskLib < Test::Unit::TestCase
+ def test_paste
+ tl = Rake::TaskLib.new
+ assert_equal :ab, tl.paste(:a, :b)
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/test_task_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/test_task_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/test_task_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,77 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'rake/testtask'
+
+class TestTestTask < Test::Unit::TestCase
+ include Rake
+ include TestMethods
+
+ def setup
+ Task.clear
+ ENV.delete('TEST')
+ end
+
+ def teardown
+ FileUtils.rm_rf("testdata")
+ end
+
+ def test_no_task
+ assert ! Task.task_defined?(:test)
+ end
+
+ def test_defaults
+ tt = Rake::TestTask.new do |t| end
+ assert_not_nil tt
+ assert_equal :test, tt.name
+ assert_equal ['lib'], tt.libs
+ assert_equal 'test/test*.rb', tt.pattern
+ assert_equal false, tt.verbose
+ assert Task.task_defined?(:test)
+ end
+
+ def test_non_defaults
+ tt = Rake::TestTask.new(:example) do |t|
+ t.libs = ['src', 'ext']
+ t.pattern = 'test/tc_*.rb'
+ t.verbose = true
+ end
+ assert_not_nil tt
+ assert_equal :example, tt.name
+ assert_equal ['src', 'ext'], tt.libs
+ assert_equal 'test/tc_*.rb', tt.pattern
+ assert_equal true, tt.verbose
+ assert Task.task_defined?(:example)
+ end
+
+ def test_pattern
+ tt = Rake::TestTask.new do |t|
+ t.pattern = '*.rb'
+ end
+ assert_equal ['*.rb'], tt.file_list.to_a
+ end
+
+ def test_env_test
+ ENV['TEST'] = 'testfile.rb'
+ tt = Rake::TestTask.new do |t|
+ t.pattern = '*'
+ end
+ assert_equal ["testfile.rb"], tt.file_list.to_a
+ end
+
+ def test_test_files
+ tt = Rake::TestTask.new do |t|
+ t.test_files = FileList['a.rb', 'b.rb']
+ end
+ assert_equal ["a.rb", 'b.rb'], tt.file_list.to_a
+ end
+
+ def test_both_pattern_and_test_files
+ tt = Rake::TestTask.new do |t|
+ t.test_files = FileList['a.rb', 'b.rb']
+ t.pattern = '*.rb'
+ end
+ assert_equal ['a.rb', 'b.rb', '*.rb'], tt.file_list.to_a
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/testtask_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/testtask_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/testtask_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,49 @@
+require 'test/test_helper'
+require 'rake/testtask'
+
+class TestTaskTest < Test::Unit::TestCase
+ def test_direct_run_has_quoted_paths
+ test_task = Rake::TestTask.new(:tx) do |t|
+ t.loader = :direct
+ end
+ assert_match(/-e ".*"/, test_task.run_code)
+ end
+
+ def test_testrb_run_has_quoted_paths_on_ruby_182
+ test_task = Rake::TestTask.new(:tx) do |t|
+ t.loader = :testrb
+ end
+ flexmock(test_task).should_receive(:ruby_version).and_return('1.8.2')
+ assert_match(/^-S testrb +".*"$/, test_task.run_code)
+ end
+
+ def test_testrb_run_has_quoted_paths_on_ruby_186
+ test_task = Rake::TestTask.new(:tx) do |t|
+ t.loader = :testrb
+ end
+ flexmock(test_task).should_receive(:ruby_version).and_return('1.8.6')
+ assert_match(/^-S testrb +$/, test_task.run_code)
+ end
+
+ def test_rake_run_has_quoted_paths
+ test_task = Rake::TestTask.new(:tx) do |t|
+ t.loader = :rake
+ end
+ assert_match(/".*"/, test_task.run_code)
+ end
+
+ def test_nested_libs_will_be_flattened
+ test_task = Rake::TestTask.new(:tx) do |t|
+ t.libs << ["A", "B"]
+ end
+ sep = File::PATH_SEPARATOR
+ assert_match(/lib#{sep}A#{sep}B/, test_task.ruby_opts_string)
+ end
+
+ def test_empty_lib_path_implies_no_dash_I_option
+ test_task = Rake::TestTask.new(:tx) do |t|
+ t.libs = []
+ end
+ assert_no_match(/-I/, test_task.ruby_opts_string)
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/top_level_functions_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/top_level_functions_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/top_level_functions_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,86 @@
+#!/usr/bin/env ruby
+
+begin
+ require 'rubygems'
+rescue LoadError
+ # got no gems
+end
+
+require 'test/unit'
+require 'flexmock/test_unit'
+require 'test/capture_stdout'
+require 'test/rake_test_setup'
+require 'rake'
+
+class TestTopLevelFunctions < Test::Unit::TestCase
+ include CaptureStdout
+ include TestMethods
+
+ def setup
+ super
+ @app = Rake.application
+ Rake.application = flexmock("app")
+ end
+
+ def teardown
+ Rake.application = @app
+ super
+ end
+
+ def test_namespace
+ Rake.application.should_receive(:in_namespace).with("xyz", any).once
+ namespace "xyz" do end
+ end
+
+ def test_import
+ Rake.application.should_receive(:add_import).with("x").once.ordered
+ Rake.application.should_receive(:add_import).with("y").once.ordered
+ Rake.application.should_receive(:add_import).with("z").once.ordered
+ import('x', 'y', 'z')
+ end
+
+ def test_when_writing
+ out = capture_stdout do
+ when_writing("NOTWRITING") do
+ puts "WRITING"
+ end
+ end
+ assert_equal "WRITING\n", out
+ end
+
+ def test_when_not_writing
+ RakeFileUtils.nowrite_flag = true
+ out = capture_stdout do
+ when_writing("NOTWRITING") do
+ puts "WRITING"
+ end
+ end
+ assert_equal "DRYRUN: NOTWRITING\n", out
+ ensure
+ RakeFileUtils.nowrite_flag = false
+ end
+
+ def test_missing_constants_task
+ Rake.application.should_receive(:const_warning).with(:Task).once
+ Object.const_missing(:Task)
+ end
+
+ def test_missing_constants_file_task
+ Rake.application.should_receive(:const_warning).with(:FileTask).once
+ Object.const_missing(:FileTask)
+ end
+
+ def test_missing_constants_file_creation_task
+ Rake.application.should_receive(:const_warning).with(:FileCreationTask).once
+ Object.const_missing(:FileCreationTask)
+ end
+
+ def test_missing_constants_rake_app
+ Rake.application.should_receive(:const_warning).with(:RakeApp).once
+ Object.const_missing(:RakeApp)
+ end
+
+ def test_missing_other_constant
+ assert_exception(NameError) do Object.const_missing(:Xyz) end
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/lib/win32_test.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/lib/win32_test.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/lib/win32_test.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,72 @@
+#!/usr/bin/env ruby
+
+require 'test/unit'
+require 'test/rake_test_setup'
+require 'test/in_environment'
+
+require 'rake'
+
+class TestWin32 < Test::Unit::TestCase
+ include InEnvironment
+ include TestMethods
+
+ Win32 = Rake::Win32
+
+ def test_win32_system_dir_uses_home_if_defined
+ in_environment('RAKE_SYSTEM' => nil, 'HOME' => 'C:\\HP') do
+ assert_equal "C:/HP/Rake", Win32.win32_system_dir
+ end
+ end
+
+ def test_win32_system_dir_uses_homedrive_homepath_when_no_home_defined
+ in_environment(
+ 'RAKE_SYSTEM' => nil,
+ 'HOME' => nil,
+ 'HOMEDRIVE' => "C:",
+ 'HOMEPATH' => "\\HP"
+ ) do
+ assert_equal "C:/HP/Rake", Win32.win32_system_dir
+ end
+ end
+
+ def test_win32_system_dir_uses_appdata_when_no_home_or_home_combo
+ in_environment(
+ 'RAKE_SYSTEM' => nil,
+ 'HOME' => nil,
+ 'HOMEDRIVE' => nil,
+ 'HOMEPATH' => nil,
+ 'APPDATA' => "C:\\Documents and Settings\\HP\\Application Data"
+ ) do
+ assert_equal "C:/Documents and Settings/HP/Application Data/Rake", Win32.win32_system_dir
+ end
+ end
+
+ def test_win32_system_dir_fallback_to_userprofile_otherwise
+ in_environment(
+ 'RAKE_SYSTEM' => nil,
+ 'HOME' => nil,
+ 'HOMEDRIVE' => nil,
+ 'HOMEPATH' => nil,
+ 'APPDATA' => nil,
+ 'USERPROFILE' => "C:\\Documents and Settings\\HP"
+ ) do
+ assert_equal "C:/Documents and Settings/HP/Rake", Win32.win32_system_dir
+ end
+ end
+
+ def test_win32_system_dir_nil_of_no_env_vars
+ in_environment(
+ 'RAKE_SYSTEM' => nil,
+ 'HOME' => nil,
+ 'HOMEDRIVE' => nil,
+ "HOMEPATH" => nil,
+ 'APPDATA' => nil,
+ "USERPROFILE" => nil
+ ) do
+ assert_exception(Rake::Win32::Win32HomeError) do
+ Win32.win32_system_dir
+ end
+ end
+ end
+
+end
Added: MacRuby/trunk/test/libs/rake/test/rake_test_setup.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/rake_test_setup.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/rake_test_setup.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,24 @@
+# Common setup for all test files.
+
+begin
+ require 'rubygems'
+ gem 'flexmock'
+rescue LoadError
+ # got no gems
+end
+
+require 'flexmock/test_unit'
+
+if RUBY_VERSION >= "1.9.0"
+ class Test::Unit::TestCase
+# def passed?
+# true
+# end
+ end
+end
+
+module TestMethods
+ def assert_exception(ex, msg=nil, &block)
+ assert_raise(ex, msg, &block)
+ end
+end
Added: MacRuby/trunk/test/libs/rake/test/reqfile.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/reqfile.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/reqfile.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,3 @@
+# For --require testing
+
+TESTING_REQUIRE << 1
Added: MacRuby/trunk/test/libs/rake/test/reqfile2.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/reqfile2.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/reqfile2.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,3 @@
+# For --require testing
+
+TESTING_REQUIRE << 2
Added: MacRuby/trunk/test/libs/rake/test/reqfile3.rake
===================================================================
--- MacRuby/trunk/test/libs/rake/test/reqfile3.rake (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/reqfile3.rake 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,3 @@
+# For --require testing
+
+TESTING_REQUIRE << 3
Added: MacRuby/trunk/test/libs/rake/test/shellcommand.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/shellcommand.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/shellcommand.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+
+exit((ARGV[0] || "0").to_i)
Property changes on: MacRuby/trunk/test/libs/rake/test/shellcommand.rb
___________________________________________________________________
Added: svn:executable
+ *
Added: MacRuby/trunk/test/libs/rake/test/test_helper.rb
===================================================================
--- MacRuby/trunk/test/libs/rake/test/test_helper.rb (rev 0)
+++ MacRuby/trunk/test/libs/rake/test/test_helper.rb 2009-09-14 17:15:13 UTC (rev 2551)
@@ -0,0 +1,13 @@
+begin
+ require 'rubygems'
+rescue LoadError => ex
+ # No rubygems available
+end
+require 'test/unit'
+require 'flexmock/test_unit'
+
+require 'rake'
+
+class Test::Unit::TestCase
+ include Rake::DSL
+end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090914/2f465634/attachment-0001.html>
More information about the macruby-changes
mailing list