Permalink
Browse files

more test suite reorganization

  • Loading branch information...
1 parent fe7891e commit 7ca4fb15ccfce589b847db26b80a3eabb7b4c795 Aaron J. Bedra committed Jun 23, 2008
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -0,0 +1,17 @@
+def d(x)
+ 4*x
+end
+
+def a
+ b 10
+end
+
+def b(x)
+ x*10
+end
+
+def c(x)
+ 3*x
+end
+
+a()
@@ -2,7 +2,7 @@
class TestCallSiteAnalyzer < Test::Unit::TestCase
- sample_file = File.join(File.dirname(__FILE__), "sample_03.rb")
+ sample_file = File.join(File.dirname(__FILE__), "assets/sample_03.rb")
load sample_file
def setup
@@ -59,21 +59,21 @@ def test_return_values_when_no_match
def test_basic_defsite_recording
@a.run_hooked{ @o.f1 }
- verify_defsite_equal(["./test/sample_03.rb", 3],
+ verify_defsite_equal(["./test/assets/sample_03.rb", 3],
@a.defsite("Rcov::Test::Temporary::Sample03", "f1"))
- verify_defsite_equal(["./test/sample_03.rb", 7],
+ verify_defsite_equal(["./test/assets/sample_03.rb", 7],
@a.defsite("Rcov::Test::Temporary::Sample03", "f2"))
- verify_defsite_equal(["./test/sample_03.rb", 7],
+ verify_defsite_equal(["./test/assets/sample_03.rb", 7],
@a.defsite("Rcov::Test::Temporary::Sample03#f2"))
end
def test_basic_callsite_recording
@a.run_hooked{ @o.f1 }
assert(@a.analyzed_classes.include?("Rcov::Test::Temporary::Sample03"))
assert_equal(%w[f1 f2], @a.analyzed_methods("Rcov::Test::Temporary::Sample03"))
- verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1, "./test/sample_03.rb", 4]] => 10},
+ verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1, "./test/assets/sample_03.rb", 4]] => 10},
@a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
- verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1, "./test/sample_03.rb", 4]] => 10},
+ verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1, "./test/assets/sample_03.rb", 4]] => 10},
@a.callsites("Rcov::Test::Temporary::Sample03#f2"))
#verify_callsites_equal({["./test/sample_03.rb:4:in `f1'"] => 10},
# @a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
@@ -86,13 +86,13 @@ def test_basic_callsite_recording_API
assert(@a.analyzed_classes.include?("Rcov::Test::Temporary::Sample03"))
assert_equal(%w[f1 f2], @a.analyzed_methods("Rcov::Test::Temporary::Sample03"))
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
- "./test/sample_03.rb", 4]] => 10},
+ "./test/assets/sample_03.rb", 4]] => 10},
@a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
- verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1, "./test/sample_03.rb", 4]] => 10},
+ verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1, "./test/assets/sample_03.rb", 4]] => 10},
@a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
callsites = @a.callsites("Rcov::Test::Temporary::Sample03", "f2")
callsite = callsites.keys[0]
- assert_equal("./test/sample_03.rb", callsite.file)
+ assert_equal("./test/assets/sample_03.rb", callsite.file)
assert_equal(4, callsite.line)
assert_equal(:f1, callsite.calling_method)
end
@@ -103,10 +103,10 @@ def test_basic_callsite_recording_with_singleton_classes
assert(@a.analyzed_classes.include?("#<Class:Rcov::Test::Temporary::Sample03>"))
assert_equal(%w[g1 g2], @a.analyzed_methods("#<Class:Rcov::Test::Temporary::Sample03>"))
verify_callsites_equal({[[class << Rcov::Test::Temporary::Sample03; self end,
- :g1, "./test/sample_03.rb", 15]] => 10},
+ :g1, "./test/assets/sample_03.rb", 15]] => 10},
@a.callsites("Rcov::Test::Temporary::Sample03.g2"))
verify_callsites_equal({[[class << Rcov::Test::Temporary::Sample03; self end,
- :g1, "./test/sample_03.rb", 15]] => 10},
+ :g1, "./test/assets/sample_03.rb", 15]] => 10},
@a.callsites("#<Class:Rcov::Test::Temporary::Sample03>","g2"))
end
@@ -116,22 +116,22 @@ def test_differential_callsite_recording
assert(@a.analyzed_classes.include?("Rcov::Test::Temporary::Sample03"))
assert_equal(%w[f1 f2], @a.analyzed_methods("Rcov::Test::Temporary::Sample03"))
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
- "./test/sample_03.rb", 4]] => 10},
+ "./test/assets/sample_03.rb", 4]] => 10},
@a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
@a.run_hooked{ @o.f1 }
assert(@a.analyzed_classes.include?("Rcov::Test::Temporary::Sample03"))
assert_equal(%w[f1 f2], @a.analyzed_methods("Rcov::Test::Temporary::Sample03"))
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
- "./test/sample_03.rb", 4]] => 20},
+ "./test/assets/sample_03.rb", 4]] => 20},
@a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
@a.run_hooked{ @o.f3 }
assert_equal(%w[f1 f2 f3], @a.analyzed_methods("Rcov::Test::Temporary::Sample03"))
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
- "./test/sample_03.rb", 4]] => 120,
+ "./test/assets/sample_03.rb", 4]] => 120,
[[Rcov::Test::Temporary::Sample03, :f3,
- "./test/sample_03.rb", 11]]=>100 },
+ "./test/assets/sample_03.rb", 11]]=>100 },
@a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
end
@@ -144,7 +144,7 @@ def test_reset
assert(@a.analyzed_classes.include?("Rcov::Test::Temporary::Sample03"))
assert_equal(%w[f1 f2], @a.analyzed_methods("Rcov::Test::Temporary::Sample03"))
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
- "./test/sample_03.rb", 4]] => 10},
+ "./test/assets/sample_03.rb", 4]] => 10},
@a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
end
@@ -157,27 +157,27 @@ def test_nested_callsite_recording
assert(b.analyzed_classes.include?("Rcov::Test::Temporary::Sample03"))
assert_equal(%w[f1 f2], b.analyzed_methods("Rcov::Test::Temporary::Sample03"))
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
- "./test/sample_03.rb", 4]] => 10},
+ "./test/assets/sample_03.rb", 4]] => 10},
b.callsites("Rcov::Test::Temporary::Sample03", "f2"))
@o.f1
assert_equal(%w[f1 f2], b.analyzed_methods("Rcov::Test::Temporary::Sample03"))
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
- "./test/sample_03.rb", 4]] => 10},
+ "./test/assets/sample_03.rb", 4]] => 10},
b.callsites("Rcov::Test::Temporary::Sample03", "f2"))
assert(a.analyzed_classes.include?("Rcov::Test::Temporary::Sample03"))
assert_equal(%w[f1 f2], a.analyzed_methods("Rcov::Test::Temporary::Sample03"))
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
- "./test/sample_03.rb", 4]] => 20},
+ "./test/assets/sample_03.rb", 4]] => 20},
a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
end
b.run_hooked{ @o.f3 }
assert_equal(%w[f1 f2 f3], b.analyzed_methods("Rcov::Test::Temporary::Sample03"))
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
- "./test/sample_03.rb", 4]] => 110,
+ "./test/assets/sample_03.rb", 4]] => 110,
[[Rcov::Test::Temporary::Sample03, :f3,
- "./test/sample_03.rb", 11]]=>100 },
+ "./test/assets/sample_03.rb", 11]]=>100 },
b.callsites("Rcov::Test::Temporary::Sample03", "f2"))
end
@@ -37,7 +37,7 @@ def test_analyzed_files_no_analysis
end
def test_raw_coverage_info
- sample_file = File.join(File.dirname(__FILE__), "sample_01.rb")
+ sample_file = File.join(File.dirname(__FILE__), "assets/sample_01.rb")
lines = File.readlines(sample_file)
analyzer = Rcov::CodeCoverageAnalyzer.new
analyzer.run_hooked{ load sample_file }
@@ -81,7 +81,7 @@ def test_script_lines_workaround_no_false_positives
end
def test_differential_coverage_data
- sample_file = File.join(File.dirname(__FILE__), "sample_01.rb")
+ sample_file = File.join(File.dirname(__FILE__), "assets/sample_01.rb")
lines = File.readlines(sample_file)
analyzer = Rcov::CodeCoverageAnalyzer.new
analyzer.run_hooked{ load sample_file }
@@ -90,7 +90,7 @@ def test_differential_coverage_data
analyzer.reset
- sample_file = File.join(File.dirname(__FILE__), "sample_02.rb")
+ sample_file = File.join(File.dirname(__FILE__), "assets/sample_02.rb")
analyzer.run_hooked{ load sample_file }
line_info, cov_info, count_info = analyzer.data(sample_file)
assert_equal([8, 1, 0, 0, 0], count_info)
@@ -125,7 +125,7 @@ def test_nested_analyzer_blocks
a1 = Rcov::CodeCoverageAnalyzer.new
a2 = Rcov::CodeCoverageAnalyzer.new
- sample_file = File.join(File.dirname(__FILE__), "sample_02.rb")
+ sample_file = File.join(File.dirname(__FILE__), "assets/sample_02.rb")
load sample_file
a1.run_hooked do
@@ -158,7 +158,7 @@ def test_nested_analyzer_blocks
def test_reset
a1 = Rcov::CodeCoverageAnalyzer.new
- sample_file = File.join(File.dirname(__FILE__), "sample_02.rb")
+ sample_file = File.join(File.dirname(__FILE__), "assets/sample_02.rb")
load sample_file
a1.run_hooked do
@@ -1,7 +1,7 @@
================================================================================
-sample_05.rb
+assets/sample_05.rb
================================================================================
-sample_05.rb:2: 4*x
-sample_05.rb:3:end
-sample_05.rb:14: 3*x
-sample_05.rb:15:end
+assets/sample_05.rb:2: 4*x
+assets/sample_05.rb:3:end
+assets/sample_05.rb:14: 3*x
+assets/sample_05.rb:15:end
@@ -1,11 +1,11 @@
================================================================================
-!!!!! Uncovered code introduced in sample_05.rb
+!!!!! Uncovered code introduced in assets/sample_05.rb
-sample_05.rb-1-def d(x)
-sample_05.rb:2: 4*x
-sample_05.rb:3:end
-sample_05.rb-4-
-sample_05.rb-5-def a
-sample_05.rb-6- b 10
-sample_05.rb-7-end
+assets/sample_05.rb-1-def d(x)
+assets/sample_05.rb:2: 4*x
+assets/sample_05.rb:3:end
+assets/sample_05.rb-4-
+assets/sample_05.rb-5-def a
+assets/sample_05.rb-6- b 10
+assets/sample_05.rb-7-end
@@ -1,5 +1,5 @@
================================================================================
-sample_05.rb
+assets/sample_05.rb
================================================================================
-sample_05.rb:10: 3*x
-sample_05.rb:11:end
+assets/sample_05.rb:10: 3*x
+assets/sample_05.rb:11:end
@@ -1,8 +1,8 @@
================================================================================
-!!!!! Uncovered code introduced in sample_05.rb
+!!!!! Uncovered code introduced in assets/sample_05.rb
-### sample_05.rb:1
+### assets/sample_05.rb:1
def d(x)
!! 4*x
!! end
@@ -1,8 +1,8 @@
================================================================================
-!!!!! Uncovered code introduced in sample_05.rb
+!!!!! Uncovered code introduced in assets/sample_05.rb
-### sample_05.rb:1
+### assets/sample_05.rb:1
def d(x)
 4*x
end
@@ -1,10 +1,10 @@
================================================================================
-sample_03.rb
+assets/sample_03.rb
================================================================================
-sample_03.rb:15: 10.times{ g2 }
-sample_03.rb:16: end
-sample_03.rb:19: # safe from here ...
-sample_03.rb:20:end end end end
+assets/sample_03.rb:15: 10.times{ g2 }
+assets/sample_03.rb:16: end
+assets/sample_03.rb:19: # safe from here ...
+assets/sample_03.rb:20:end end end end
================================================================================
-sample_04.rb
+assets/sample_04.rb
================================================================================
View
@@ -38,7 +38,7 @@ def with_testdir(&block)
Dir.chdir(@@dir, &block)
end
- def run_rcov(opts, script="sample_04.rb", opts_tail="")
+ def run_rcov(opts, script="assets/sample_04.rb", opts_tail="")
rcov = @@dir+"../bin/rcov"
ruby_opts = "-I../lib:../ext/rcovrt"
with_testdir do
@@ -49,49 +49,46 @@ def run_rcov(opts, script="sample_04.rb", opts_tail="")
def test_annotation
run_rcov("-a") do
- cmp "sample_04_rb.rb"
- cmp "sample_03_rb.rb"
+ cmp "../assets/sample_04.rb"
+ cmp "../assets/sample_03.rb"
end
end
@@selection = "--include-file=sample --exclude=rcov"
def test_text_gcc
run_rcov("--gcc #{@@selection}",
- "sample_04.rb",
+ "assets/sample_04.rb",
"> actual_coverage/gcc-text.out") do
cmp "gcc-text.out"
end
end
def test_diff
- with_testdir { FileUtils.cp "sample_05-old.rb", "sample_05.rb" }
- run_rcov("--no-html --gcc #{@@selection} --save=coverage.info", "sample_05.rb",
+ with_testdir { FileUtils.cp "assets/sample_05-old.rb", "assets/sample_05.rb" }
+ run_rcov("--no-html --gcc #{@@selection} --save=coverage.info", "assets/sample_05.rb",
"> actual_coverage/diff-gcc-original.out") do
cmp "diff-gcc-original.out"
end
- with_testdir { FileUtils.cp "sample_05-new.rb", "sample_05.rb" }
- run_rcov("--no-html -D --gcc #{@@selection}", "sample_05.rb",
+ with_testdir { FileUtils.cp "assets/sample_05-new.rb", "assets/sample_05.rb" }
+ run_rcov("--no-html -D --gcc #{@@selection}", "assets/sample_05.rb",
"> actual_coverage/diff-gcc-diff.out") do
cmp "diff-gcc-diff.out"
end
- run_rcov("--no-html -D #{@@selection}", "sample_05.rb",
+ run_rcov("--no-html -D #{@@selection}", "assets/sample_05.rb",
"> actual_coverage/diff.out") do
cmp "diff.out"
end
- run_rcov("--no-html --no-color -D #{@@selection}", "sample_05.rb",
+ run_rcov("--no-html --no-color -D #{@@selection}", "assets/sample_05.rb",
"> actual_coverage/diff-no-color.out") do
cmp "diff-no-color.out"
end
- run_rcov("--no-html --gcc #{@@selection}", "sample_05.rb",
+ run_rcov("--no-html --gcc #{@@selection}", "assets/sample_05.rb",
"> actual_coverage/diff-gcc-all.out") do
cmp "diff-gcc-all.out"
end
-
-
end
-
end

0 comments on commit 7ca4fb1

Please sign in to comment.