| Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
|---|---|---|---|---|
| lib/buildr/scala/bdd.rb | 131 | 86 | 35.11%
|
40.70%
|
Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.
1 # Licensed to the Apache Software Foundation (ASF) under one or more |
2 # contributor license agreements. See the NOTICE file distributed with this |
3 # work for additional information regarding copyright ownership. The ASF |
4 # licenses this file to you under the Apache License, Version 2.0 (the |
5 # "License"); you may not use this file except in compliance with the License. |
6 # You may obtain a copy of the License at |
7 # |
8 # http://www.apache.org/licenses/LICENSE-2.0 |
9 # |
10 # Unless required by applicable law or agreed to in writing, software |
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
13 # License for the specific language governing permissions and limitations under |
14 # the License. |
15 |
16 |
17 require 'buildr/core/build' |
18 require 'buildr/core/compile' |
19 require 'buildr/java/bdd' |
20 require 'buildr/scala/tests' |
21 |
22 module Buildr::Scala |
23 |
24 # Specs is a Scala based BDD framework. |
25 # To use in your project: |
26 # |
27 # test.using :specs |
28 # |
29 # This framework will search in your project for: |
30 # src/spec/scala/**/*.scala |
31 class Specs < Buildr::TestFramework::JavaBDD |
32 @lang = :scala |
33 @bdd_dir = :spec |
34 |
35 VERSION = case |
36 when Buildr::Scala.version?("2.8.0") |
37 '1.6.5' |
38 when Buildr::Scala.version?("2.8.1") |
39 '1.6.8' |
40 else |
41 '1.6.8' |
42 end |
43 |
44 |
45 class << self |
46 def version |
47 custom = Buildr.settings.build['scala.specs'] |
48 (custom =~ /:/) ? Buildr.artifact(custom).version : VERSION |
49 end |
50 |
51 def specs |
52 custom = Buildr.settings.build['scala.specs'] |
53 [ (custom =~ /:/) ? custom : "org.scala-tools.testing:#{artifact}:jar:#{version}" ] |
54 end |
55 |
56 def artifact |
57 Buildr.settings.build['scala.specs.artifact'] || "specs_#{Buildr::Scala.version_without_build}" |
58 end |
59 |
60 def dependencies |
61 unless @dependencies |
62 super |
63 # Add utility classes (e.g. SpecsSingletonRunner) and other dependencies |
64 @dependencies |= [ File.join(File.dirname(__FILE__)) ] + specs + |
65 Check.dependencies + JUnit.dependencies + Scalac.dependencies |
66 end |
67 @dependencies |
68 end |
69 |
70 def applies_to?(project) #:nodoc: |
71 !Dir[project.path_to(:source, bdd_dir, lang, '**/*.scala')].empty? |
72 end |
73 |
74 private |
75 def const_missing(const) |
76 return super unless const == :REQUIRES # TODO: remove in 1.5 |
77 Buildr.application.deprecated "Please use Scala::Specs.dependencies/.version instead of ScalaSpecs::REQUIRES/VERSION" |
78 dependencies |
79 end |
80 end |
81 |
82 def initialize(task, options) #:nodoc: |
83 super |
84 |
85 specs = task.project.path_to(:source, :spec, :scala) |
86 task.compile.from specs if File.directory?(specs) |
87 |
88 resources = task.project.path_to(:source, :spec, :resources) |
89 task.resources.from resources if File.directory?(resources) |
90 end |
91 |
92 def tests(dependencies) |
93 candidates = filter_classes(dependencies, :interfaces => ['org.specs.Specification']) |
94 |
95 Java.load # Java is already loaded, but just in case |
96 |
97 filter = Java.org.apache.buildr.JavaTestFilter.new(dependencies.to_java(Java.java.lang.String)) |
98 filter.add_fields ['MODULE$'].to_java(Java.java.lang.String) |
99 filter.filter(candidates.to_java(Java.java.lang.String)).map { |s| s[0..(s.size - 2)] } |
100 end |
101 |
102 def run(specs, dependencies) #:nodoc: |
103 cmd_options = { :properties => options[:properties], |
104 :java_args => options[:java_args], |
105 :classpath => dependencies, |
106 :name => false } |
107 |
108 runner = 'org.apache.buildr.SpecsSingletonRunner' |
109 specs.inject [] do |passed, spec| |
110 begin |
111 unless Util.win_os? |
112 Java::Commands.java(runner, task.compile.target.to_s, '-c', spec + '$', cmd_options) |
113 else |
114 Java::Commands.java(runner, task.compile.target.to_s, spec + '$', cmd_options) |
115 end |
116 rescue => e |
117 passed |
118 else |
119 passed << spec |
120 end |
121 end |
122 end |
123 end |
124 end |
125 |
126 # Backwards compatibility stuff. Remove in 1.5. |
127 module Buildr |
128 ScalaSpecs = Scala::Specs |
129 end |
130 |
131 Buildr::TestFramework << Buildr::Scala::Specs |
Generated on 2011-07-06 23:35:38 -0700 with rcov 0.9.8