summaryrefslogtreecommitdiff
path: root/test/rake/test_rake_application_options.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-15 21:59:37 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-15 21:59:37 +0000
commit9c66bad9f3d522d50d4a45ef8a3a92abbf93229f (patch)
tree8fc1ae219e41bdd711442b1d35149da4f45dfa8a /test/rake/test_rake_application_options.rb
parentbfc95c6e1639edc909338ef4d20d990caf6f630e (diff)
* lib/rake*: Updated to rake 0.9.3
* test/rake*: ditto * bin/rake: ditto * NEWS: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rake/test_rake_application_options.rb')
-rw-r--r--test/rake/test_rake_application_options.rb118
1 files changed, 114 insertions, 4 deletions
diff --git a/test/rake/test_rake_application_options.rb b/test/rake/test_rake_application_options.rb
index c1471f443e..004b8ef3ac 100644
--- a/test/rake/test_rake_application_options.rb
+++ b/test/rake/test_rake_application_options.rb
@@ -29,10 +29,12 @@ class TestRakeApplicationOptions < Rake::TestCase
def test_default_options
opts = command_line
+ assert_nil opts.backtrace
assert_nil opts.classic_namespace
assert_nil opts.dryrun
assert_nil opts.ignore_system
assert_nil opts.load_system
+ assert_nil opts.always_multitask
assert_nil opts.nosearch
assert_equal ['rakelib'], opts.rakelib
assert_nil opts.show_prereqs
@@ -40,6 +42,7 @@ class TestRakeApplicationOptions < Rake::TestCase
assert_nil opts.show_tasks
assert_nil opts.silent
assert_nil opts.trace
+ assert_nil opts.thread_pool_size
assert_equal ['rakelib'], opts.rakelib
assert ! Rake::FileUtilsExt.verbose_flag
assert ! Rake::FileUtilsExt.nowrite_flag
@@ -110,6 +113,18 @@ class TestRakeApplicationOptions < Rake::TestCase
assert_equal :exit, @exit
end
+ def test_jobs
+ flags(['--jobs', '4'], ['-j', '4']) do |opts|
+ assert_equal 4, opts.thread_pool_size
+ end
+ flags(['--jobs', 'asdas'], ['-j', 'asdas']) do |opts|
+ assert_equal 2, opts.thread_pool_size
+ end
+ flags('--jobs', '-j') do |opts|
+ assert_equal 2, opts.thread_pool_size
+ end
+ end
+
def test_libdir
flags(['--libdir', 'xx'], ['-I', 'xx'], ['-Ixx']) do |opts|
$:.include?('xx')
@@ -118,6 +133,12 @@ class TestRakeApplicationOptions < Rake::TestCase
$:.delete('xx')
end
+ def test_multitask
+ flags('--multitask', '-m') do |opts|
+ assert_equal opts.always_multitask, true
+ end
+ end
+
def test_rakefile
flags(['--rakefile', 'RF'], ['--rakefile=RF'], ['-f', 'RF'], ['-fRF']) do |opts|
assert_equal ['RF'], @app.instance_eval { @rakefiles }
@@ -125,7 +146,8 @@ class TestRakeApplicationOptions < Rake::TestCase
end
def test_rakelib
- flags(['--rakelibdir', 'A:B:C'], ['--rakelibdir=A:B:C'], ['-R', 'A:B:C'], ['-RA:B:C']) do |opts|
+ dirs = %w(A B C).join(File::PATH_SEPARATOR)
+ flags(['--rakelibdir', dirs], ["--rakelibdir=#{dirs}"], ['-R', dirs], ["-R#{dirs}"]) do |opts|
assert_equal ['A', 'B', 'C'], opts.rakelib
end
end
@@ -197,12 +219,76 @@ class TestRakeApplicationOptions < Rake::TestCase
def test_trace
flags('--trace', '-t') do |opts|
- assert opts.trace
+ assert opts.trace, "should enable trace option"
+ assert opts.backtrace, "should enabled backtrace option"
+ assert_equal $stderr, opts.trace_output
+ assert Rake::FileUtilsExt.verbose_flag
+ assert ! Rake::FileUtilsExt.nowrite_flag
+ end
+ end
+
+ def test_trace_with_stdout
+ flags('--trace=stdout', '-tstdout', '-t stdout') do |opts|
+ assert opts.trace, "should enable trace option"
+ assert opts.backtrace, "should enabled backtrace option"
+ assert_equal $stdout, opts.trace_output
assert Rake::FileUtilsExt.verbose_flag
assert ! Rake::FileUtilsExt.nowrite_flag
end
end
+ def test_trace_with_stderr
+ flags('--trace=stderr', '-tstderr', '-t stderr') do |opts|
+ assert opts.trace, "should enable trace option"
+ assert opts.backtrace, "should enabled backtrace option"
+ assert_equal $stderr, opts.trace_output
+ assert Rake::FileUtilsExt.verbose_flag
+ assert ! Rake::FileUtilsExt.nowrite_flag
+ end
+ end
+
+ def test_trace_with_error
+ ex = assert_raises(Rake::CommandLineOptionError) do
+ flags('--trace=xyzzy') do |opts| end
+ end
+ assert_match(/un(known|recognized).*\btrace\b.*xyzzy/i, ex.message)
+ end
+
+
+ def test_backtrace
+ flags('--backtrace') do |opts|
+ assert opts.backtrace, "should enable backtrace option"
+ assert_equal $stderr, opts.trace_output
+ assert ! opts.trace, "should not enable trace option"
+ assert ! Rake::FileUtilsExt.verbose_flag
+ end
+ end
+
+ def test_backtrace_with_stdout
+ flags('--backtrace=stdout') do |opts|
+ assert opts.backtrace, "should enable backtrace option"
+ assert_equal $stdout, opts.trace_output
+ assert ! opts.trace, "should not enable trace option"
+ assert ! Rake::FileUtilsExt.verbose_flag
+ end
+ end
+
+ def test_backtrace_with_stderr
+ flags('--backtrace=stderr') do |opts|
+ assert opts.backtrace, "should enable backtrace option"
+ assert_equal $stderr, opts.trace_output
+ assert ! opts.trace, "should not enable trace option"
+ assert ! Rake::FileUtilsExt.verbose_flag
+ end
+ end
+
+ def test_backtrace_with_error
+ ex = assert_raises(Rake::CommandLineOptionError) do
+ flags('--backtrace=xyzzy') do |opts| end
+ end
+ assert_match(/un(known|recognized).*\bbacktrace\b.*xyzzy/i, ex.message)
+ end
+
def test_trace_rules
flags('--rules') do |opts|
assert opts.trace_rules
@@ -213,10 +299,17 @@ class TestRakeApplicationOptions < Rake::TestCase
flags('--tasks', '-T') do |opts|
assert_equal :tasks, opts.show_tasks
assert_equal(//.to_s, opts.show_task_pattern.to_s)
+ assert_equal nil, opts.show_all_tasks
end
flags(['--tasks', 'xyz'], ['-Txyz']) do |opts|
assert_equal :tasks, opts.show_tasks
assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s)
+ assert_equal nil, opts.show_all_tasks
+ end
+ flags(['--tasks', 'xyz', '--comments']) do |opts|
+ assert_equal :tasks, opts.show_tasks
+ assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s)
+ assert_equal false, opts.show_all_tasks
end
end
@@ -224,10 +317,17 @@ class TestRakeApplicationOptions < Rake::TestCase
flags('--where', '-W') do |opts|
assert_equal :lines, opts.show_tasks
assert_equal(//.to_s, opts.show_task_pattern.to_s)
+ assert_equal true, opts.show_all_tasks
end
flags(['--where', 'xyz'], ['-Wxyz']) do |opts|
assert_equal :lines, opts.show_tasks
assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s)
+ assert_equal true, opts.show_all_tasks
+ end
+ flags(['--where', 'xyz', '--comments'], ['-Wxyz', '--comments']) do |opts|
+ assert_equal :lines, opts.show_tasks
+ assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s)
+ assert_equal false, opts.show_all_tasks
end
end
@@ -268,7 +368,7 @@ class TestRakeApplicationOptions < Rake::TestCase
assert_equal opts.trace, $trace
assert_equal opts.dryrun, $dryrun
assert_equal opts.silent, $silent
- end
+ end
end
assert_match(/deprecated/, err)
@@ -308,6 +408,17 @@ class TestRakeApplicationOptions < Rake::TestCase
assert '12', ENV['TESTKEY']
end
+ def test_rake_explicit_task_library
+ Rake.add_rakelib 'app/task', 'other'
+
+ libs = Rake.application.options.rakelib
+
+ assert libs.include?("app/task")
+ assert libs.include?("other")
+ end
+
+ private
+
def flags(*sets)
sets.each do |set|
ARGV.clear
@@ -332,4 +443,3 @@ class TestRakeApplicationOptions < Rake::TestCase
@app.options
end
end
-