craigmarksmith-rake 0.8.3.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. data/CHANGES +427 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README +196 -0
  4. data/Rakefile +416 -0
  5. data/TODO +20 -0
  6. data/bin/rake +31 -0
  7. data/doc/command_line_usage.rdoc +102 -0
  8. data/doc/example/Rakefile1 +38 -0
  9. data/doc/example/Rakefile2 +35 -0
  10. data/doc/example/a.c +6 -0
  11. data/doc/example/b.c +6 -0
  12. data/doc/example/main.c +11 -0
  13. data/doc/glossary.rdoc +51 -0
  14. data/doc/jamis.rb +591 -0
  15. data/doc/proto_rake.rdoc +127 -0
  16. data/doc/rake.1.gz +0 -0
  17. data/doc/rakefile.rdoc +534 -0
  18. data/doc/rational.rdoc +151 -0
  19. data/doc/release_notes/rake-0.4.14.rdoc +23 -0
  20. data/doc/release_notes/rake-0.4.15.rdoc +35 -0
  21. data/doc/release_notes/rake-0.5.0.rdoc +53 -0
  22. data/doc/release_notes/rake-0.5.3.rdoc +78 -0
  23. data/doc/release_notes/rake-0.5.4.rdoc +46 -0
  24. data/doc/release_notes/rake-0.6.0.rdoc +141 -0
  25. data/doc/release_notes/rake-0.7.0.rdoc +119 -0
  26. data/doc/release_notes/rake-0.7.1.rdoc +59 -0
  27. data/doc/release_notes/rake-0.7.2.rdoc +121 -0
  28. data/doc/release_notes/rake-0.7.3.rdoc +47 -0
  29. data/doc/release_notes/rake-0.8.0.rdoc +114 -0
  30. data/doc/release_notes/rake-0.8.2.rdoc +165 -0
  31. data/doc/release_notes/rake-0.8.3.rdoc +112 -0
  32. data/doc/release_notes/rake-0.8.4.rdoc +147 -0
  33. data/install.rb +88 -0
  34. data/lib/rake/classic_namespace.rb +8 -0
  35. data/lib/rake/clean.rb +33 -0
  36. data/lib/rake/contrib/compositepublisher.rb +24 -0
  37. data/lib/rake/contrib/ftptools.rb +153 -0
  38. data/lib/rake/contrib/publisher.rb +75 -0
  39. data/lib/rake/contrib/rubyforgepublisher.rb +18 -0
  40. data/lib/rake/contrib/sshpublisher.rb +47 -0
  41. data/lib/rake/contrib/sys.rb +209 -0
  42. data/lib/rake/gempackagetask.rb +97 -0
  43. data/lib/rake/loaders/makefile.rb +42 -0
  44. data/lib/rake/packagetask.rb +184 -0
  45. data/lib/rake/rake_test_loader.rb +5 -0
  46. data/lib/rake/rdoctask.rb +209 -0
  47. data/lib/rake/ruby182_test_unit_fix.rb +23 -0
  48. data/lib/rake/runtest.rb +23 -0
  49. data/lib/rake/tasklib.rb +23 -0
  50. data/lib/rake/testtask.rb +161 -0
  51. data/lib/rake/win32.rb +55 -0
  52. data/lib/rake.rb +2519 -0
  53. data/test/capture_stdout.rb +26 -0
  54. data/test/check_expansion.rb +5 -0
  55. data/test/contrib/test_sys.rb +47 -0
  56. data/test/data/chains/Rakefile +15 -0
  57. data/test/data/default/Rakefile +19 -0
  58. data/test/data/dryrun/Rakefile +22 -0
  59. data/test/data/file_creation_task/Rakefile +33 -0
  60. data/test/data/imports/Rakefile +19 -0
  61. data/test/data/imports/deps.mf +1 -0
  62. data/test/data/multidesc/Rakefile +17 -0
  63. data/test/data/namespace/Rakefile +57 -0
  64. data/test/data/rakelib/test1.rb +3 -0
  65. data/test/data/rbext/rakefile.rb +3 -0
  66. data/test/data/sample.mf +14 -0
  67. data/test/data/statusreturn/Rakefile +8 -0
  68. data/test/data/unittest/Rakefile +1 -0
  69. data/test/filecreation.rb +32 -0
  70. data/test/functional.rb +15 -0
  71. data/test/in_environment.rb +30 -0
  72. data/test/rake_test_setup.rb +24 -0
  73. data/test/reqfile.rb +3 -0
  74. data/test/reqfile2.rb +3 -0
  75. data/test/session_functional.rb +339 -0
  76. data/test/shellcommand.rb +3 -0
  77. data/test/test_application.rb +690 -0
  78. data/test/test_clean.rb +14 -0
  79. data/test/test_definitions.rb +85 -0
  80. data/test/test_earlytime.rb +35 -0
  81. data/test/test_extension.rb +63 -0
  82. data/test/test_file_creation_task.rb +62 -0
  83. data/test/test_file_task.rb +143 -0
  84. data/test/test_filelist.rb +623 -0
  85. data/test/test_fileutils.rb +251 -0
  86. data/test/test_ftp.rb +59 -0
  87. data/test/test_invocation_chain.rb +81 -0
  88. data/test/test_makefile_loader.rb +26 -0
  89. data/test/test_multitask.rb +45 -0
  90. data/test/test_namespace.rb +55 -0
  91. data/test/test_package_task.rb +118 -0
  92. data/test/test_pathmap.rb +210 -0
  93. data/test/test_rake.rb +41 -0
  94. data/test/test_rdoc_task.rb +88 -0
  95. data/test/test_require.rb +35 -0
  96. data/test/test_rules.rb +349 -0
  97. data/test/test_task_arguments.rb +89 -0
  98. data/test/test_task_manager.rb +173 -0
  99. data/test/test_tasklib.rb +12 -0
  100. data/test/test_tasks.rb +374 -0
  101. data/test/test_test_task.rb +77 -0
  102. data/test/test_top_level_functions.rb +86 -0
  103. data/test/test_win32.rb +72 -0
  104. metadata +186 -0
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'stringio'
4
+
5
+ # Mix-in for capturing standard output.
6
+ module CaptureStdout
7
+ def capture_stdout
8
+ s = StringIO.new
9
+ oldstdout = $stdout
10
+ $stdout = s
11
+ yield
12
+ s.string
13
+ ensure
14
+ $stdout = oldstdout
15
+ end
16
+
17
+ def capture_stderr
18
+ s = StringIO.new
19
+ oldstderr = $stderr
20
+ $stderr = s
21
+ yield
22
+ s.string
23
+ ensure
24
+ $stderr = oldstderr
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ if ARGV[0] != ARGV[1]
2
+ exit 1
3
+ else
4
+ exit 0
5
+ end
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'test/filecreation'
5
+ require 'rake/contrib/sys'
6
+
7
+ class TestSys < Test::Unit::TestCase
8
+ include FileCreation
9
+
10
+ # def test_delete
11
+ # create_file("testdata/a")
12
+ # Sys.delete_all("testdata/a")
13
+ # assert ! File.exist?("testdata/a")
14
+ # end
15
+
16
+ # def test_copy
17
+ # create_file("testdata/a")
18
+ # Sys.copy("testdata/a", "testdata/b")
19
+ # assert File.exist?("testdata/b")
20
+ # end
21
+
22
+ # def test_for_files
23
+ # test_files = ["testdata/a.pl", "testdata/c.pl", "testdata/b.rb"]
24
+ # test_files.each { |fn| create_file(fn) }
25
+ # list = []
26
+ # Sys.for_files("testdata/*.pl", "testdata/*.rb") { |fn|
27
+ # list << fn
28
+ # }
29
+ # assert_equal test_files.sort, list.sort
30
+ # end
31
+
32
+ # def test_indir
33
+ # here = Dir.pwd
34
+ # Sys.makedirs("testdata/dir")
35
+ # assert_equal "#{here}/testdata/dir", Sys.indir("testdata/dir") { Dir.pwd }
36
+ # assert_equal here, Dir.pwd
37
+ # end
38
+
39
+ def test_split_all
40
+ assert_equal ['a'], Sys.split_all('a')
41
+ assert_equal ['..'], Sys.split_all('..')
42
+ assert_equal ['/'], Sys.split_all('/')
43
+ assert_equal ['a', 'b'], Sys.split_all('a/b')
44
+ assert_equal ['/', 'a', 'b'], Sys.split_all('/a/b')
45
+ assert_equal ['..', 'a', 'b'], Sys.split_all('../a/b')
46
+ end
47
+ end
@@ -0,0 +1,15 @@
1
+ # -*- ruby -*-
2
+
3
+ task :default => "play.app"
4
+
5
+ file "play.scpt" => "base" do |t|
6
+ cp t.prerequisites.first, t.name
7
+ end
8
+
9
+ rule ".app" => ".scpt" do |t|
10
+ cp t.source, t.name
11
+ end
12
+
13
+ file 'base' do
14
+ touch 'base'
15
+ end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if ENV['TESTTOPSCOPE']
4
+ puts "TOPSCOPE"
5
+ end
6
+
7
+ task :default do
8
+ puts "DEFAULT"
9
+ end
10
+
11
+ task :other => [:default] do
12
+ puts "OTHER"
13
+ end
14
+
15
+ task :task_scope do
16
+ if ENV['TESTTASKSCOPE']
17
+ puts "TASKSCOPE"
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ #
2
+
3
+ task :default => ["temp_main"]
4
+
5
+ file "temp_main" => [:all_apps] do touch "temp_main" end
6
+
7
+ task :all_apps => [:one, :two]
8
+ task :one => ["temp_one"]
9
+ task :two => ["temp_two"]
10
+
11
+ file "temp_one" do |t|
12
+ touch "temp_one"
13
+ end
14
+ file "temp_two" do |t|
15
+ touch "temp_two"
16
+ end
17
+
18
+ task :clean do
19
+ ["temp_one", "temp_two", "temp_main"].each do |file|
20
+ rm_f file
21
+ end
22
+ end
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ N = 2
4
+
5
+ task :default => :run
6
+
7
+ BUILD_DIR = 'build'
8
+ task :clean do
9
+ rm_rf 'build'
10
+ rm_rf 'src'
11
+ end
12
+
13
+ task :run
14
+
15
+ TARGET_DIR = 'build/copies'
16
+
17
+ FileList['src/*'].each do |src|
18
+ directory TARGET_DIR
19
+ target = File.join TARGET_DIR, File.basename(src)
20
+ file target => [src, TARGET_DIR] do
21
+ cp src, target
22
+ # sleep 3 if src !~ /foo#{N-1}$/ # I'm commenting out this sleep, it doesn't seem to do anything.
23
+ end
24
+ task :run => target
25
+ end
26
+
27
+ task :prep => :clean do
28
+ mkdir_p 'src'
29
+ N.times do |n|
30
+ puts "DBG: Touching src/foo#{n}"
31
+ touch "src/foo#{n}"
32
+ end
33
+ end
@@ -0,0 +1,19 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rake/loaders/makefile'
4
+
5
+ task :default
6
+
7
+ task :other do
8
+ puts "OTHER"
9
+ end
10
+
11
+ file "dynamic_deps" do |t|
12
+ open(t.name, "w") do |f| f.puts "puts 'DYNAMIC'" end
13
+ end
14
+
15
+ import "dynamic_deps"
16
+ import "static_deps"
17
+ import "static_deps"
18
+ import "deps.mf"
19
+ puts "FIRST"
@@ -0,0 +1 @@
1
+ default: other
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ task :b
4
+
5
+ desc "A"
6
+ task :a
7
+
8
+ desc "B"
9
+ task :b
10
+
11
+ desc "A2"
12
+ task :a
13
+
14
+ task :c
15
+
16
+ desc "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
17
+ task :d
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ desc "copy"
4
+ task :copy do
5
+ puts "COPY"
6
+ end
7
+
8
+ namespace "nest" do
9
+ desc "nest copy"
10
+ task :copy do
11
+ puts "NEST COPY"
12
+ end
13
+ task :xx => :copy
14
+ end
15
+
16
+ anon_ns = namespace do
17
+ desc "anonymous copy task"
18
+ task :copy do
19
+ puts "ANON COPY"
20
+ end
21
+ end
22
+
23
+ desc "Top level task to run the anonymous version of copy"
24
+ task :anon => anon_ns[:copy]
25
+
26
+ namespace "very" do
27
+ namespace "nested" do
28
+ task "run" => "rake:copy"
29
+ end
30
+ end
31
+
32
+ namespace "a" do
33
+ desc "Run task in the 'a' namespace"
34
+ task "run" do
35
+ puts "IN A"
36
+ end
37
+ end
38
+
39
+ namespace "b" do
40
+ desc "Run task in the 'b' namespace"
41
+ task "run" => "a:run" do
42
+ puts "IN B"
43
+ end
44
+ end
45
+
46
+ namespace "file1" do
47
+ file "xyz.rb" do
48
+ puts "XYZ1"
49
+ end
50
+ end
51
+
52
+ namespace "file2" do
53
+ file "xyz.rb" do
54
+ puts "XYZ2"
55
+ end
56
+ end
57
+
@@ -0,0 +1,3 @@
1
+ task :default do
2
+ puts "TEST1"
3
+ end
@@ -0,0 +1,3 @@
1
+ task :default do
2
+ puts "OK"
3
+ end
@@ -0,0 +1,14 @@
1
+ # Comments
2
+ a: a1 a2 a3 a4
3
+ b: b1 b2 b3 \
4
+ b4 b5 b6\
5
+ # Mid: Comment
6
+ b7
7
+
8
+ a : a5 a6 a7
9
+ c: c1
10
+ d: d1 d2 \
11
+
12
+ e f : e1 f1
13
+
14
+ g\ 0: g1 g\ 2 g\ 3 g4
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ task :exit5 do
4
+ exit(5)
5
+ end
6
+
7
+ task :normal do
8
+ end
@@ -0,0 +1 @@
1
+ # Empty Rakefile for Unit Test
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module FileCreation
4
+ OLDFILE = "testdata/old"
5
+ NEWFILE = "testdata/new"
6
+
7
+ def create_timed_files(oldfile, *newfiles)
8
+ return if File.exist?(oldfile) && newfiles.all? { |newfile| File.exist?(newfile) }
9
+ old_time = create_file(oldfile)
10
+ newfiles.each do |newfile|
11
+ while create_file(newfile) <= old_time
12
+ sleep(0.1)
13
+ File.delete(newfile) rescue nil
14
+ end
15
+ end
16
+ end
17
+
18
+ def create_dir(dirname)
19
+ FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
20
+ File.stat(dirname).mtime
21
+ end
22
+
23
+ def create_file(name)
24
+ create_dir(File.dirname(name))
25
+ FileUtils.touch(name) unless File.exist?(name)
26
+ File.stat(name).mtime
27
+ end
28
+
29
+ def delete_file(name)
30
+ File.delete(name) rescue nil
31
+ end
32
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ require 'rubygems'
5
+ gem 'session'
6
+ require 'session'
7
+ rescue LoadError
8
+ puts "UNABLE TO RUN FUNCTIONAL TESTS"
9
+ puts "No Session Found (gem install session)"
10
+ end
11
+
12
+ if defined?(Session)
13
+ puts "RUNNING WITH SESSIONS"
14
+ require 'test/session_functional'
15
+ end
@@ -0,0 +1,30 @@
1
+ module InEnvironment
2
+ private
3
+
4
+ # Create an environment for a test. At the completion of the yielded
5
+ # block, the environment is restored to its original conditions.
6
+ def in_environment(settings)
7
+ original_settings = set_env(settings)
8
+ yield
9
+ ensure
10
+ set_env(original_settings)
11
+ end
12
+
13
+ # Set the environment according to the settings hash.
14
+ def set_env(settings) # :nodoc:
15
+ result = {}
16
+ settings.each do |k, v|
17
+ result[k] = ENV[k]
18
+ if k == 'PWD'
19
+ result[k] = Dir.pwd
20
+ Dir.chdir(v)
21
+ elsif v.nil?
22
+ ENV.delete(k)
23
+ else
24
+ ENV[k] = v
25
+ end
26
+ end
27
+ result
28
+ end
29
+
30
+ end
@@ -0,0 +1,24 @@
1
+ # Common setup for all test files.
2
+
3
+ begin
4
+ require 'rubygems'
5
+ gem 'flexmock'
6
+ rescue LoadError
7
+ # got no gems
8
+ end
9
+
10
+ require 'flexmock/test_unit'
11
+
12
+ if RUBY_VERSION >= "1.9.0"
13
+ class Test::Unit::TestCase
14
+ # def passed?
15
+ # true
16
+ # end
17
+ end
18
+ end
19
+
20
+ module TestMethods
21
+ def assert_exception(ex, msg=nil, &block)
22
+ assert_raise(ex, msg, &block)
23
+ end
24
+ end
data/test/reqfile.rb ADDED
@@ -0,0 +1,3 @@
1
+ # For --require testing
2
+
3
+ TESTING_REQUIRE << 1
data/test/reqfile2.rb ADDED
@@ -0,0 +1,3 @@
1
+ # For --require testing
2
+
3
+ TESTING_REQUIRE << 2
@@ -0,0 +1,339 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ require 'rubygems'
5
+ rescue LoadError => ex
6
+ end
7
+ require 'test/unit'
8
+ require 'fileutils'
9
+ require 'session'
10
+ require 'test/in_environment'
11
+ require 'test/rake_test_setup'
12
+
13
+ # Version 2.1.9 of session has a bug where the @debug instance
14
+ # variable is not initialized, causing warning messages. This snippet
15
+ # of code fixes that problem.
16
+ module Session
17
+ class AbstractSession
18
+ alias old_initialize initialize
19
+ def initialize(*args)
20
+ @debug = nil
21
+ old_initialize(*args)
22
+ end
23
+ end
24
+ end
25
+
26
+ class FunctionalTest < Test::Unit::TestCase
27
+ include InEnvironment
28
+ include TestMethods
29
+
30
+ RUBY_COMMAND = 'ruby'
31
+
32
+ def setup
33
+ @rake_path = File.expand_path("bin/rake")
34
+ lib_path = File.expand_path("lib")
35
+ @ruby_options = "-I#{lib_path} -I."
36
+ @verbose = ! ENV['VERBOSE'].nil?
37
+ if @verbose
38
+ puts
39
+ puts
40
+ puts "--------------------------------------------------------------------"
41
+ puts name
42
+ puts "--------------------------------------------------------------------"
43
+ end
44
+ end
45
+
46
+ def test_rake_default
47
+ Dir.chdir("test/data/default") do rake end
48
+ assert_match(/^DEFAULT$/, @out)
49
+ assert_status
50
+ end
51
+
52
+ def test_rake_error_on_bad_task
53
+ Dir.chdir("test/data/default") do rake "xyz" end
54
+ assert_match(/rake aborted/, @err)
55
+ assert_status(1)
56
+ end
57
+
58
+ def test_env_availabe_at_top_scope
59
+ Dir.chdir("test/data/default") do rake "TESTTOPSCOPE=1" end
60
+ assert_match(/^TOPSCOPE$/, @out)
61
+ assert_status
62
+ end
63
+
64
+ def test_env_availabe_at_task_scope
65
+ Dir.chdir("test/data/default") do rake "TESTTASKSCOPE=1 task_scope" end
66
+ assert_match(/^TASKSCOPE$/, @out)
67
+ assert_status
68
+ end
69
+
70
+ def test_multi_desc
71
+ in_environment(
72
+ 'RAKE_COLUMNS' => "80",
73
+ "PWD" => "test/data/multidesc"
74
+ ) do
75
+ rake "-T"
76
+ end
77
+ assert_match %r{^rake a *# A / A2 *$}, @out
78
+ assert_match %r{^rake b *# B *$}, @out
79
+ assert_no_match %r{^rake c}, @out
80
+ assert_match %r{^rake d *# x{65}\.\.\.$}, @out
81
+ end
82
+
83
+ def test_long_description
84
+ in_environment("PWD" => "test/data/multidesc") do
85
+ rake "--describe"
86
+ end
87
+ assert_match %r{^rake a\n *A / A2 *$}m, @out
88
+ assert_match %r{^rake b\n *B *$}m, @out
89
+ assert_match %r{^rake d\n *x{80}}m, @out
90
+ assert_no_match %r{^rake c\n}m, @out
91
+ end
92
+
93
+ def test_rbext
94
+ in_environment("PWD" => "test/data/rbext") do
95
+ rake "-N"
96
+ end
97
+ assert_match %r{^OK$}, @out
98
+ end
99
+
100
+ def test_system
101
+ in_environment('RAKE_SYSTEM' => 'test/data/sys') do
102
+ rake '-g', "sys1"
103
+ end
104
+ assert_match %r{^SYS1}, @out
105
+ end
106
+
107
+ def test_system_excludes_rakelib_files_too
108
+ in_environment('RAKE_SYSTEM' => 'test/data/sys') do
109
+ rake '-g', "sys1", '-T', 'extra'
110
+ end
111
+ assert_no_match %r{extra:extra}, @out
112
+ end
113
+
114
+ def test_by_default_rakelib_files_are_include
115
+ in_environment('RAKE_SYSTEM' => 'test/data/sys') do
116
+ rake '-T', 'extra'
117
+ end
118
+ assert_match %r{extra:extra}, @out
119
+ end
120
+
121
+ def test_implicit_system
122
+ in_environment('RAKE_SYSTEM' => File.expand_path('test/data/sys'), "PWD" => "/") do
123
+ rake "sys1", "--trace"
124
+ end
125
+ assert_match %r{^SYS1}, @out
126
+ end
127
+
128
+ def test_no_system
129
+ in_environment('RAKE_SYSTEM' => 'test/data/sys') do
130
+ rake '-G', "sys1"
131
+ end
132
+ assert_match %r{^Don't know how to build task}, @err # emacs wart: '
133
+ end
134
+
135
+ def test_nosearch_with_rakefile_uses_local_rakefile
136
+ in_environment("PWD" => "test/data/default") do
137
+ rake "--nosearch"
138
+ end
139
+ assert_match %r{^DEFAULT}, @out
140
+ end
141
+
142
+ def test_nosearch_without_rakefile_finds_system
143
+ in_environment(
144
+ "PWD" => "test/data/nosearch",
145
+ "RAKE_SYSTEM" => File.expand_path("test/data/sys")
146
+ ) do
147
+ rake "--nosearch", "sys1"
148
+ end
149
+ assert_match %r{^SYS1}, @out
150
+ end
151
+
152
+ def test_nosearch_without_rakefile_and_no_system_fails
153
+ in_environment("PWD" => "test/data/nosearch", "RAKE_SYSTEM" => "not_exist") do
154
+ rake "--nosearch"
155
+ end
156
+ assert_match %r{^No Rakefile found}, @err
157
+ end
158
+
159
+ def test_dry_run
160
+ in_environment("PWD" => "test/data/default") do rake "-n", "other" end
161
+ assert_match %r{Execute \(dry run\) default}, @out
162
+ assert_match %r{Execute \(dry run\) other}, @out
163
+ assert_no_match %r{DEFAULT}, @out
164
+ assert_no_match %r{OTHER}, @out
165
+ end
166
+
167
+ # Test for the trace/dry_run bug found by Brian Chandler
168
+ def test_dry_run_bug
169
+ in_environment("PWD" => "test/data/dryrun") do
170
+ rake
171
+ end
172
+ FileUtils.rm_f "test/data/dryrun/temp_one"
173
+ in_environment("PWD" => "test/data/dryrun") do
174
+ rake "--dry-run"
175
+ end
176
+ assert_no_match(/No such file/, @out)
177
+ assert_status
178
+ end
179
+
180
+ # Test for the trace/dry_run bug found by Brian Chandler
181
+ def test_trace_bug
182
+ in_environment("PWD" => "test/data/dryrun") do
183
+ rake
184
+ end
185
+ FileUtils.rm_f "test/data/dryrun/temp_one"
186
+ in_environment("PWD" => "test/data/dryrun") do
187
+ rake "--trace"
188
+ end
189
+ assert_no_match(/No such file/, @out)
190
+ assert_status
191
+ end
192
+
193
+ def test_imports
194
+ open("test/data/imports/static_deps", "w") do |f|
195
+ f.puts 'puts "STATIC"'
196
+ end
197
+ FileUtils.rm_f "test/data/imports/dynamic_deps"
198
+ in_environment("PWD" => "test/data/imports") do
199
+ rake
200
+ end
201
+ assert File.exist?("test/data/imports/dynamic_deps"),
202
+ "'dynamic_deps' file should exist"
203
+ assert_match(/^FIRST$\s+^DYNAMIC$\s+^STATIC$\s+^OTHER$/, @out)
204
+ assert_status
205
+ FileUtils.rm_f "test/data/imports/dynamic_deps"
206
+ FileUtils.rm_f "test/data/imports/static_deps"
207
+ end
208
+
209
+ def test_rules_chaining_to_file_task
210
+ remove_chaining_files
211
+ in_environment("PWD" => "test/data/chains") do
212
+ rake
213
+ end
214
+ assert File.exist?("test/data/chains/play.app"),
215
+ "'play.app' file should exist"
216
+ assert_status
217
+ remove_chaining_files
218
+ end
219
+
220
+ def test_file_creation_task
221
+ in_environment("PWD" => "test/data/file_creation_task") do
222
+ rake "prep"
223
+ rake "run"
224
+ rake "run"
225
+ end
226
+ assert(@err !~ /^cp src/, "Should not recopy data")
227
+ end
228
+
229
+ def test_dash_f_with_no_arg_foils_rakefile_lookup
230
+ rake "-I test/data/rakelib -rtest1 -f"
231
+ assert_match(/^TEST1$/, @out)
232
+ end
233
+
234
+ def test_dot_rake_files_can_be_loaded_with_dash_r
235
+ rake "-I test/data/rakelib -rtest2 -f"
236
+ assert_match(/^TEST2$/, @out)
237
+ end
238
+
239
+ def test_can_invoke_task_in_toplevel_namespace
240
+ in_environment("PWD" => "test/data/namespace") do
241
+ rake "copy"
242
+ end
243
+ assert_match(/^COPY$/, @out)
244
+ end
245
+
246
+ def test_can_invoke_task_in_nested_namespace
247
+ in_environment("PWD" => "test/data/namespace") do
248
+ rake "nest:copy"
249
+ assert_match(/^NEST COPY$/, @out)
250
+ end
251
+ end
252
+
253
+ def test_tasks_can_reference_task_in_same_namespace
254
+ in_environment("PWD" => "test/data/namespace") do
255
+ rake "nest:xx"
256
+ assert_match(/^NEST COPY$/m, @out)
257
+ end
258
+ end
259
+
260
+ def test_tasks_can_reference_task_in_other_namespaces
261
+ in_environment("PWD" => "test/data/namespace") do
262
+ rake "b:run"
263
+ assert_match(/^IN A\nIN B$/m, @out)
264
+ end
265
+ end
266
+
267
+ def test_anonymous_tasks_can_be_invoked_indirectly
268
+ in_environment("PWD" => "test/data/namespace") do
269
+ rake "anon"
270
+ assert_match(/^ANON COPY$/m, @out)
271
+ end
272
+ end
273
+
274
+ def test_rake_namespace_refers_to_toplevel
275
+ in_environment("PWD" => "test/data/namespace") do
276
+ rake "very:nested:run"
277
+ assert_match(/^COPY$/m, @out)
278
+ end
279
+ end
280
+
281
+ def test_file_task_are_not_scoped_by_namespaces
282
+ in_environment("PWD" => "test/data/namespace") do
283
+ rake "xyz.rb"
284
+ assert_match(/^XYZ1\nXYZ2$/m, @out)
285
+ end
286
+ end
287
+
288
+ def test_rake_returns_status_error_values
289
+ in_environment("PWD" => "test/data/statusreturn") do
290
+ rake "exit5"
291
+ assert_status(5)
292
+ end
293
+ end
294
+
295
+ def test_rake_returns_no_status_error_on_normal_exit
296
+ in_environment("PWD" => "test/data/statusreturn") do
297
+ rake "normal"
298
+ assert_status(0)
299
+ end
300
+ end
301
+
302
+ private
303
+
304
+ def remove_chaining_files
305
+ %w(play.scpt play.app base).each do |fn|
306
+ FileUtils.rm_f File.join("test/data/chains", fn)
307
+ end
308
+ end
309
+
310
+ class << self
311
+ def format_command
312
+ @format_command ||= lambda { |ruby_options, rake_path, options|
313
+ "ruby #{ruby_options} #{rake_path} #{options}"
314
+ }
315
+ end
316
+
317
+ def format_command=(fmt_command)
318
+ @format_command = fmt_command
319
+ end
320
+ end
321
+
322
+ def rake(*option_list)
323
+ options = option_list.join(' ')
324
+ shell = Session::Shell.new
325
+ command = self.class.format_command[@ruby_options, @rake_path, options]
326
+ puts "COMMAND: [#{command}]" if @verbose
327
+ @out, @err = shell.execute command
328
+ @status = shell.exit_status
329
+ puts "STATUS: [#{@status}]" if @verbose
330
+ puts "OUTPUT: [#{@out}]" if @verbose
331
+ puts "ERROR: [#{@err}]" if @verbose
332
+ puts "PWD: [#{Dir.pwd}]" if @verbose
333
+ shell.close
334
+ end
335
+
336
+ def assert_status(expected_status=0)
337
+ assert_equal expected_status, @status
338
+ end
339
+ end