Permalink
Browse files

* Use srand to generate reproducible data sets.

  • Loading branch information...
1 parent 0aa9b3f commit 7f0e146ed89b9ff3ab64f1e1289cba573389fdc1 @donv donv committed Nov 9, 2012
View
12 test/gruff_test_case.rb
@@ -10,10 +10,12 @@
TEST_OUTPUT_DIR = File.dirname(__FILE__) + "/output"
FileUtils.mkdir_p(TEST_OUTPUT_DIR)
+FileUtils.rm_f Dir[TEST_OUTPUT_DIR + '/*']
class GruffTestCase < Test::Unit::TestCase
def setup
+ srand 42
@datasets = [
[:Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]],
[:Charles, [80, 54, 67, 54, 68, 70, 90, 95]],
@@ -82,7 +84,15 @@ def graph_sized(filename, sizes=['', 400])
end
def write_test_file(graph, filename)
- graph.write([TEST_OUTPUT_DIR, filename].join("/"))
+ testfilename = [TEST_OUTPUT_DIR, filename].join("/")
+ basefilename = filename.split('.')[0..-2].join('.')
+ extension = filename.slice(/\..*$/)
+ counter = 0
+ while File.exists? testfilename
+ counter += 1
+ testfilename = [TEST_OUTPUT_DIR, basefilename].join("/") + "-#{counter}#{extension}"
+ end
+ graph.write(testfilename)
end
##
View
BIN test/output/accum_bar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/area_many.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/area_many_areas_small.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/area_tiny.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/enhancements-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/enhancements.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/line_many.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/line_many_lines_small.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/line_tiny.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/net_dots_tiny.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/net_many.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/net_many_nets_small.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/pie_simple.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN test/output/scatter_many.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
1 test/test_accumulator_bar.rb
@@ -5,6 +5,7 @@ class TestGruffAccumulatorBar < GruffTestCase
# TODO Delete old output files once when starting tests
def setup
+ super
@datasets = [
(1..20).to_a.map { rand(10) }
]
View
4 test/test_area.rb
@@ -5,6 +5,7 @@
class TestGruffArea < GruffTestCase
def setup
+ super
@datasets = [
[:Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]],
[:Charles, [80, 54, 67, 54, 68, 70, 90, 95]],
@@ -22,8 +23,7 @@ def setup
5 => '6/12',
6 => '6/21',
7 => '6/28',
- }
-
+ }
end
def test_area_graph
View
1 test/test_bar.rb
@@ -7,6 +7,7 @@ class TestGruffBar < GruffTestCase
# TODO Delete old output files once when starting tests
def setup
+ super
@datasets = [
[:Jimmy, [25, 36, 86, 39]],
[:Charles, [80, 54, 67, 54]],
View
3 test/test_line.rb
@@ -3,9 +3,6 @@
require File.dirname(__FILE__) + "/gruff_test_case"
class TestGruffLine < GruffTestCase
-
- # TODO Delete old output files once when starting tests
-
def test_should_render_with_transparent_theme
g = Gruff::Line.new(400)
g.title = "Transparent Background"
View
3 test/test_net.rb
@@ -5,6 +5,7 @@
class TestGruffNet < GruffTestCase
def setup
+ super
@datasets = [
[:Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]],
[:Charles, [80, 54, 67, 54, 68, 70, 90, 95]],
@@ -23,7 +24,7 @@ def setup
5 => '6/12',
6 => '6/21',
7 => '6/28',
- }
+ }
end
def test_net_small_values
View
2 test/test_scatter.rb
@@ -230,4 +230,4 @@ def setup_all_neg(size=800)
return g
end
-end # end GruffTestCase
+end # end GruffTestCase

0 comments on commit 7f0e146

Please sign in to comment.