lib/java/test.rb in buildr-1.1.0 vs lib/java/test.rb in buildr-1.1.1

- old
+ new

@@ -96,15 +96,19 @@ self end private + def test_finding_pattern() + "*{Test,TestCase,Suite,TestSuite}" + end + def test_cases() unless @cases @cases = @paths.map do |path| base = Pathname.new(path.to_s) - FileList["#{path}/**/*.class"]. + FileList["#{path}/**/#{test_finding_pattern}.class"]. map { |file| Pathname.new(file).relative_path_from(base).to_s.ext("").gsub(File::SEPARATOR, ".") }. select { |name| @include.any? { |pattern| File.fnmatch(pattern, name) } }. reject { |name| @exclude.any? { |pattern| File.fnmatch(pattern, name) } } end.flatten.sort end @@ -316,12 +320,21 @@ # This rule takes a suffix and runs that test case in the current project. For example; # rake test:MyTest # will run the test case class com.example.MyTest, if found in the current project. rule /^test:.*$/ do |task| test = task.name.scan(/test:(.*)/)[0][0] + # Glob if no glob pattern used. test = "*#{test}*" unless test =~ /\*/ - Project.local_projects.map { |project| project.test }. - each { |task| task.junit.instance_eval { @include = [test] ; @exclude.clear } }.each(&:invoke) + if test =~ /\{.+\}/ + # Unfortunately, fnmatch doesn't do {foo,bar}, so we have to expand those ourselves. + tests = test[/\{.+\}/][1...-1].split(",").map { |name| test.sub(/\{.+\}/, name) } + else + tests = [test] + end + # Since the test case may reside in a sub-project, we need to set the include/exclude pattern on + # all sub-projects, but only invoke test on the local project. + Project.projects.each { |project| project.test.junit.instance_eval { @include = tests ; @exclude.clear } } + Project.local_projects.each { |project| project.test.invoke } end class Options