Ticket 2297 - rake stats clearly labels functional and unit tests

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2373 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper
2005-09-27 22:09:21 +00:00
parent fcd0133f69
commit ec019d7bc1
2 changed files with 14 additions and 11 deletions

View File

@@ -1,4 +1,7 @@
class CodeStatistics
TEST_TYPES = ['Unit tests', 'Functional tests']
def initialize(*pairs)
@pairs = pairs
@statistics = calculate_statistics
@@ -55,13 +58,13 @@ class CodeStatistics
def calculate_code
code_loc = 0
@statistics.each { |k, v| code_loc += v['codelines'] unless ['Units', 'Functionals'].include? k }
@statistics.each { |k, v| code_loc += v['codelines'] unless TEST_TYPES.include? k }
code_loc
end
def calculate_tests
test_loc = 0
@statistics.each { |k, v| test_loc += v['codelines'] if ['Units', 'Functionals'].include? k }
@statistics.each { |k, v| test_loc += v['codelines'] if TEST_TYPES.include? k }
test_loc
end
@@ -79,7 +82,7 @@ class CodeStatistics
m_over_c = (statistics["methods"] / statistics["classes"]) rescue m_over_c = 0
loc_over_m = (statistics["codelines"] / statistics["methods"]) - 2 rescue loc_over_m = 0
start = if ['Units', 'Functionals'].include? name
start = if TEST_TYPES.include? name
"| #{name.ljust(18)} "
else
"| #{name.ljust(20)} "

View File

@@ -1,12 +1,12 @@
STATS_DIRECTORIES = [
%w(Helpers app/helpers),
%w(Controllers app/controllers),
%w(APIs app/apis),
%w(Components components),
%w(Functionals test/functional),
%w(Models app/models),
%w(Units test/unit),
%w(Libraries lib/)
%w(Helpers app/helpers),
%w(Controllers app/controllers),
%w(APIs app/apis),
%w(Components components),
%w(Functional\ tests test/functional),
%w(Models app/models),
%w(Unit\ tests test/unit),
%w(Libraries lib/)
].collect { |name, dir| [ name, "#{RAILS_ROOT}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
desc "Report code statistics (KLOCs, etc) from the application"