require_relative "./helpers" describe BigBench::Executor do before(:each) do Dir.chdir File.dirname(__FILE__) end it "should run a local test with trackings" do argv = ["local", "tests/local.rb"] BigBench::Executor::Executable.start(argv) BigBench.benchmarks.size.should == 2 BigBench.benchmarks.each{ |benchmark| benchmark.runs.should == 1 } File.exist?(BigBench.config.output).should be_true File.open(BigBench.config.output) do |file| file.each_line{ |json| JSON.parse(json).is_a?(Hash).should be_true } end File.delete BigBench.config.output end it "should run a bot test" do argv = ["bots", "tests/local.rb"] BigBench::Executor::Executable.start(argv) BigBench.benchmarks.size.should == 2 BigBench.benchmarks.each{ |benchmark| benchmark.runs.should == 0 } File.exist?(BigBench.config.output).should be_true File.open(BigBench.config.output) do |file| file.each_line{ |json| JSON.parse(json).is_a?(Hash).should be_true } end File.delete BigBench.config.output end it "should show the help file" do argv = ["help"] lambda{ BigBench::Executor::Executable.start(argv) }.should_not raise_exception File.exists?("../lib/bigbench/help/executor.txt").should be_true end it "should reset everything" do BigBench::Store.setup!("http://localhost:6379").should be_true BigBench::Store.test = "something" argv = ["reset"] BigBench::Executor::Executable.start(argv) BigBench.benchmarks.size.should == 0 BigBench::Store.test.should be_nil end it "should re-run the post processors from a receipt" do argv = ["process", "tests/with_post_processor.rb"] BigBench::Executor::Executable.start(argv) BigBench.benchmarks.size.should == 1 BigBench.benchmarks.each{ |benchmark| benchmark.runs.should == 0 } File.exist?(BigBench.config.output).should be_true File.open(BigBench.config.output) do |file| file.each_line{ |json| JSON.parse(json).is_a?(Hash).should be_true } end BigBench.post_processors.each{ |processor| processor.runs.should == 1 } end it "should run a single post processor for a single test" do argv = ["process", "tests/with_post_processor.rb", "statistics"] BigBench::Executor::Executable.start(argv) BigBench.benchmarks.size.should == 1 BigBench.benchmarks.each{ |benchmark| benchmark.runs.should == 0 } File.exist?(BigBench.config.output).should be_true File.open(BigBench.config.output) do |file| file.each_line{ |json| JSON.parse(json).is_a?(Hash).should be_true } end BigBench.post_processors.size.should == 1 BigBench.post_processors.first.runs.should == 1 end it "should generate a new testfile", :generate do Dir.chdir "tmp" File.exists?("new_test.rb").should be_false argv = ["generate", "new_test"] BigBench::Executor::Executable.start(argv) File.exists?("new_test.rb").should be_true FileUtils.rm "new_test.rb" end end