spec/git-autobisect_spec.rb in git-autobisect-0.1.1 vs spec/git-autobisect_spec.rb in git-autobisect-0.2.0

- old
+ new

@@ -14,12 +14,12 @@ def current_commit run "git log --oneline | head -1" end - def add_irrelevant_commit(name) - run "touch #{name} && git add #{name} && git commit -m 'added #{name}'" + def add_irrelevant_commit(name="b") + run "echo #{rand} >> #{name} && git add #{name} && git commit -m 'added #{name}'" end def remove_a run "git rm a && git commit -m 'remove a'" end @@ -28,11 +28,11 @@ Dir.chdir ROOT end describe "basics" do it "shows its usage without arguments" do - autobisect("").should include("Usage") + autobisect("", :fail => true).should include("Usage") end it "shows its usage with -h" do autobisect("-h").should include("Usage") end @@ -56,26 +56,51 @@ Dir.chdir "spec/tmp" run "git init && touch a && git add a && git commit -m 'added a'" end it "stops when the first commit works" do - autobisect("'test 1'", :fail => true).should include("Current commit is not broken") + autobisect("'test 1'", :fail => true).should include("HEAD is not broken") end it "stops when no commit works" do autobisect("test", :fail => true).should include("No good commit found") end + context "--max" do + let(:command){ "'test -e a' --max 5" } + + it "finds if a commit works inside of max range" do + remove_a + 3.times{ add_irrelevant_commit } + autobisect(command).should_not include("No good commit found") + end + + it "stops when no commit works inside of max range" do + remove_a + 5.times{ add_irrelevant_commit } + autobisect(command, :fail => true).should include("No good commit found") + end + end + it "finds the first broken commit for 1 commit" do remove_a result = autobisect("'test -e a'") - result.should include("bisect run success") + result.should_not include("bisect run") result.should =~ /is the first bad commit.*remove a/m end + it "finds the first broken commit for multiple commits" do + remove_a + result = autobisect("'test -e a'") + result.should_not include("bisect run success") + result.should =~ /is the first bad commit.*remove a/m + end + it "can run a complex command" do + 10.times{ add_irrelevant_commit } remove_a + 10.times{ add_irrelevant_commit } result = autobisect("'sleep 0.01 && test -e a'") result.should include("bisect run success") result.should =~ /is the first bad commit.*remove a/m end @@ -124,11 +149,10 @@ it "does not run test too often" do result = autobisect("'echo a >> count && test -e a'") result.should include("bisect run success") result.should include("added e") - result.should_not include("added d") - File.read('count').count('a').should == 6 + File.read('count').count('a').should == 4 end end end end