C0 code coverage information
Generated on Wed Oct 07 08:34:06 -0700 2009 with rcov 0.8.2.1
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/ant'
20 require 'buildr/java/tests'
21
22
23 module Buildr::Scala
24 # Scala::Check is available when using Scala::Test or Scala::Specs
25 module Check
26 VERSION = '1.5'
27
28 class << self
29 def version
30 Buildr.settings.build['scala.check'] || VERSION
31 end
32
33 def dependencies
34 ["org.scala-tools.testing:scalacheck:jar:#{version}"]
35 end
36
37 private
38 def const_missing(const)
39 return super unless const == :REQUIRES # TODO: remove in 1.5
40 Buildr.application.deprecated "Please use Scala::Check.dependencies/.version instead of ScalaCheck::REQUIRES/VERSION"
41 dependencies
42 end
43 end
44 end
45
46
47 # ScalaTest framework, the default test framework for Scala tests.
48 #
49 # Support the following options:
50 # * :properties -- Hash of system properties available to the test case.
51 # * :environment -- Hash of environment variables available to the test case.
52 # * :java_args -- Arguments passed as is to the JVM.
53 class ScalaTest < Buildr::TestFramework::Java
54
55 VERSION = '0.9.5'
56
57 class << self
58 def version
59 Buildr.settings.build['scala.test'] || VERSION
60 end
61
62 def dependencies
63 ["org.scala-tools.testing:scalatest:jar:#{version}"] + Check.dependencies +
64 JMock.dependencies + JUnit.dependencies
65 end
66
67 def applies_to?(project) #:nodoc:
68 !Dir[project.path_to(:source, :test, :scala, '**/*.scala')].empty?
69 end
70
71 private
72 def const_missing(const)
73 return super unless const == :REQUIRES # TODO: remove in 1.5
74 Buildr.application.deprecated "Please use Scala::Test.dependencies/.version instead of ScalaTest::REQUIRES/VERSION"
75 dependencies
76 end
77 end
78
79 # annotation-based group inclusion
80 attr_accessor :group_includes
81
82 # annotation-based group exclusion
83 attr_accessor :group_excludes
84
85 def initialize(test_task, options)
86 super
87 @group_includes = []
88 @group_excludes = []
89 end
90
91 def tests(dependencies) #:nodoc:
92 filter_classes(dependencies, :interfaces => %w{org.scalatest.Suite})
93 end
94
95 def run(scalatest, dependencies) #:nodoc:
96 mkpath task.report_to.to_s
97 success = []
98
99 reporter_options = 'TFGBSAR' # testSucceeded, testFailed, testIgnored, suiteAborted, runStopped, runAborted, runCompleted
100 scalatest.each do |suite|
101 info "ScalaTest #{suite.inspect}"
102 # Use Ant to execute the ScalaTest task, gives us performance and reporting.
103 reportFile = File.join(task.report_to.to_s, "TEST-#{suite}.txt")
104 taskdef = Buildr.artifacts(self.class.dependencies).each(&:invoke).map(&:to_s)
105 Buildr.ant('scalatest') do |ant|
106 ant.taskdef :name=>'scalatest', :classname=>'org.scalatest.tools.ScalaTestTask',
107 :classpath=>taskdef.join(File::PATH_SEPARATOR)
108 ant.scalatest :runpath=>dependencies.join(File::PATH_SEPARATOR) do
109 ant.suite :classname=>suite
110 ant.reporter :type=>'stdout', :config=>reporter_options
111 ant.reporter :type=>'file', :filename=> reportFile, :config=>reporter_options
112 # TODO: This should be name=>value pairs!
113 #ant.includes group_includes.join(" ") if group_includes
114 #ant.excludes group_excludes.join(" ") if group_excludes
115 (options[:properties] || []).each { |name, value| ant.property :name=>name, :value=>value }
116 end
117 end
118
119 # Parse for failures, errors, etc.
120 # This is a bit of a pain right now because ScalaTest doesn't flush its
121 # output synchronously before the Ant test finishes so we have to loop
122 # and wait for an indication that the test run was completed.
123 failed = false
124 completed = false
125 wait = 0
126 while (!completed) do
127 File.open(reportFile, "r") do |input|
128 while (line = input.gets) do
129 failed = (line =~ /(TESTS? FAILED -)|(RUN STOPPED)|(RUN ABORTED)/) unless failed
130 completed |= (line =~ /Run completed\./)
131 break if (failed)
132 end
133 end
134 wait += 1
135 break if (failed || wait > 10)
136 unless completed
137 sleep(1)
138 end
139 end
140 success << suite if (completed && !failed)
141 end
142
143 success
144 end # run
145
146 end # ScalaTest
147
148 end
149
150
151 # Backwards compatibility stuff. Remove in 1.5.
152 module Buildr
153 ScalaCheck = Scala::Check
154 ScalaTest = Scala::ScalaTest
155 end
156
157 Buildr::TestFramework << Buildr::Scala::ScalaTest
Generated using the rcov code coverage analysis tool for Ruby
version 0.8.2.1.