diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-11 21:35:01 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-11 21:35:01 +0000 |
commit | 9cadc95b28da1cf6ca8f802292d12cc96a4f2c2d (patch) | |
tree | 73280968d3426b31c5d0b9da1d3e558aa6f9fcb9 /test/rake/test_rake_rules.rb | |
parent | 52c1331763d8b9b8d6362987e6f8847b65ed7f57 (diff) | |
download | ruby-9cadc95b28da1cf6ca8f802292d12cc96a4f2c2d.tar.gz |
* NEWS (with all sufficient information):
* lib/rake: Update to rake 10.1.0
* bin/rake: ditto.
* test/rake: ditto.
* NEWS: Update NEWS to include rake 10.1.0 and links to release notes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rake/test_rake_rules.rb')
-rw-r--r-- | test/rake/test_rake_rules.rb | 65 |
1 files changed, 50 insertions, 15 deletions
diff --git a/test/rake/test_rake_rules.rb b/test/rake/test_rake_rules.rb index 664aa983e5..376b99889c 100644 --- a/test/rake/test_rake_rules.rb +++ b/test/rake/test_rake_rules.rb @@ -102,7 +102,7 @@ class TestRakeRules < Rake::TestCase verbose(false) do create_file(".foo") - rule '.o' => lambda{".foo"} do |t| + rule '.o' => lambda { ".foo" } do |t| @runs << "#{t.name} - #{t.source}" end Task[OBJFILE].invoke @@ -113,7 +113,7 @@ class TestRakeRules < Rake::TestCase def test_file_names_containing_percent_can_be_wrapped_in_lambda verbose(false) do create_file("foo%x") - rule '.o' => lambda{"foo%x"} do |t| + rule '.o' => lambda { "foo%x" } do |t| @runs << "#{t.name} - #{t.source}" end Task[OBJFILE].invoke @@ -186,7 +186,7 @@ class TestRakeRules < Rake::TestCase 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 + rule OBJFILE => [lambda { SRCFILE }, lambda { SRCFILE2 }] do @runs << :RULE end Task[OBJFILE].invoke @@ -196,7 +196,7 @@ class TestRakeRules < Rake::TestCase 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 + rule OBJFILE => [lambda { SRCFILE }, lambda { SRCFILE2 }] do @runs << :RULE end Task[OBJFILE].invoke @@ -222,10 +222,10 @@ class TestRakeRules < Rake::TestCase def test_second_rule_runs_when_first_rule_doesnt create_timed_files(OBJFILE, SRCFILE) delete_file(SRCFILE2) - rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do + rule OBJFILE => [lambda { SRCFILE }, lambda { SRCFILE2 }] do @runs << :RULE1 end - rule OBJFILE => [lambda{SRCFILE}] do + rule OBJFILE => [lambda { SRCFILE }] do @runs << :RULE2 end Task[OBJFILE].invoke @@ -234,10 +234,10 @@ class TestRakeRules < Rake::TestCase def test_second_rule_doest_run_if_first_triggers create_timed_files(OBJFILE, SRCFILE, SRCFILE2) - rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do + rule OBJFILE => [lambda { SRCFILE }, lambda { SRCFILE2 }] do @runs << :RULE1 end - rule OBJFILE => [lambda{SRCFILE}] do + rule OBJFILE => [lambda { SRCFILE }] do @runs << :RULE2 end Task[OBJFILE].invoke @@ -246,10 +246,10 @@ class TestRakeRules < Rake::TestCase def test_second_rule_doest_run_if_first_triggers_with_reversed_rules create_timed_files(OBJFILE, SRCFILE, SRCFILE2) - rule OBJFILE => [lambda{SRCFILE}] do + rule OBJFILE => [lambda { SRCFILE }] do @runs << :RULE1 end - rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do + rule OBJFILE => [lambda { SRCFILE }, lambda { SRCFILE2 }] do @runs << :RULE2 end Task[OBJFILE].invoke @@ -298,9 +298,9 @@ class TestRakeRules < Rake::TestCase actions = [] create_file("abc.xml") rule '.y' => '.xml' do actions << 'y' end - rule '.c' => '.y' do actions << 'c' end - rule '.o' => '.c' do actions << 'o' end - rule '.exe' => '.o' do actions << 'exe' end + rule '.c' => '.y' do actions << 'c'end + rule '.o' => '.c' do actions << 'o'end + rule '.exe' => '.o' do actions << 'exe'end Task["abc.exe"].invoke assert_equal ['y', 'c', 'o', 'exe'], actions end @@ -319,9 +319,44 @@ class TestRakeRules < Rake::TestCase end def test_rules_with_bad_dependents_will_fail - rule "a" => [ 1 ] do |t| puts t.name end + rule "a" => [1] do |t| puts t.name end assert_raises(RuntimeError) do Task['a'].invoke end end -end + def test_string_rule_with_args + delete_file(OBJFILE) + create_file(SRCFILE) + rule '.o', [:a] => SRCFILE do |t, args| + assert_equal 'arg', args.a + end + Task[OBJFILE].invoke('arg') + end + def test_regex_rule_with_args + delete_file(OBJFILE) + create_file(SRCFILE) + rule(/.o$/, [:a] => SRCFILE) do |t, args| + assert_equal 'arg', args.a + end + Task[OBJFILE].invoke('arg') + end + + def test_string_rule_with_args_and_lambda_prereq + delete_file(OBJFILE) + create_file(SRCFILE) + rule '.o', [:a] => [lambda{SRCFILE}]do |t, args| + assert_equal 'arg', args.a + end + Task[OBJFILE].invoke('arg') + end + + def test_regex_rule_with_args_and_lambda_prereq + delete_file(OBJFILE) + create_file(SRCFILE) + rule(/.o$/, [:a] => [lambda{SRCFILE}]) do |t, args| + assert_equal 'arg', args.a + end + Task[OBJFILE].invoke('arg') + end + +end |