bisect

package
v0.0.0-...-00ab8b8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Basic = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Start a git bisect to find a bad commit",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.
			NewBranch("mybranch").
			CreateNCommits(10)
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.AppState.GitLogShowGraph = "never"
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		markCommitAsBad := func() {
			t.Views().Commits().
				Press(keys.Commits.ViewBisectOptions)

			t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as bad`)).Confirm()
		}

		markCommitAsGood := func() {
			t.Views().Commits().
				Press(keys.Commits.ViewBisectOptions)

			t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as good`)).Confirm()
		}

		t.Views().Commits().
			Focus().
			SelectedLine(Contains("CI commit 10")).
			NavigateToLine(Contains("CI commit 09")).
			Tap(func() {
				markCommitAsBad()

				t.Views().Information().Content(Contains("Bisecting"))
			}).
			SelectedLine(Contains("<-- bad")).
			NavigateToLine(Contains("CI commit 02")).
			Tap(markCommitAsGood).
			TopLines(Contains("CI commit 10")).
			SelectedLine(Contains("CI commit 05").Contains("<-- current")).
			Tap(markCommitAsBad).
			SelectedLine(Contains("CI commit 04").Contains("<-- current")).
			Tap(func() {
				markCommitAsGood()

				t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit 05.*Do you want to reset")).Confirm()
			}).
			IsFocused().
			Content(Contains("CI commit 04"))

		t.Views().Information().Content(DoesNotContain("Bisecting"))
	},
})
View Source
var ChooseTerms = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Start a git bisect by choosing 'broken/fixed' as bisect terms",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.
			NewBranch("mybranch").
			CreateNCommits(10)
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.AppState.GitLogShowGraph = "never"
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		markCommitAsFixed := func() {
			t.Views().Commits().
				Press(keys.Commits.ViewBisectOptions)

			t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as fixed`)).Confirm()
		}

		markCommitAsBroken := func() {
			t.Views().Commits().
				Press(keys.Commits.ViewBisectOptions)

			t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as broken`)).Confirm()
		}

		t.Views().Commits().
			Focus().
			SelectedLine(Contains("CI commit 10")).
			Press(keys.Commits.ViewBisectOptions).
			Tap(func() {
				t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(Contains("Choose bisect terms")).Confirm()
				t.ExpectPopup().Prompt().Title(Equals("Term for old/good commit:")).Type("broken").Confirm()
				t.ExpectPopup().Prompt().Title(Equals("Term for new/bad commit:")).Type("fixed").Confirm()
			}).
			NavigateToLine(Contains("CI commit 09")).
			Tap(markCommitAsFixed).
			SelectedLine(Contains("<-- fixed")).
			NavigateToLine(Contains("CI commit 02")).
			Tap(markCommitAsBroken).
			Lines(
				Contains("CI commit 10").DoesNotContain("<--"),
				Contains("CI commit 09").Contains("<-- fixed"),
				Contains("CI commit 08").DoesNotContain("<--"),
				Contains("CI commit 07").DoesNotContain("<--"),
				Contains("CI commit 06").DoesNotContain("<--"),
				Contains("CI commit 05").Contains("<-- current").IsSelected(),
				Contains("CI commit 04").DoesNotContain("<--"),
				Contains("CI commit 03").DoesNotContain("<--"),
				Contains("CI commit 02").Contains("<-- broken"),
				Contains("CI commit 01").DoesNotContain("<--"),
			).
			Tap(markCommitAsFixed).
			SelectedLine(Contains("CI commit 04").Contains("<-- current")).
			Tap(func() {
				markCommitAsBroken()

				t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit 05.*Do you want to reset")).Confirm()
			}).
			IsFocused().
			Content(Contains("CI commit 04"))

		t.Views().Information().Content(DoesNotContain("Bisecting"))
	},
})
View Source
var FromOtherBranch = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Opening lazygit when bisect has been started from another branch. There's an issue where we don't reselect the current branch if we mark the current branch as bad so this test side-steps that problem",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.
			EmptyCommit("only commit on master").
			NewBranch("other").
			CreateNCommits(10).
			Checkout("master").
			StartBisect("other~2", "other~5")
	},
	SetupConfig: func(cfg *config.AppConfig) {},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Information().Content(Contains("Bisecting"))

		t.Views().Commits().
			Focus().
			TopLines(
				MatchesRegexp(`<-- bad.*commit 08`),
				MatchesRegexp(`<-- current.*commit 07`),
				MatchesRegexp(`\?.*commit 06`),
				MatchesRegexp(`<-- good.*commit 05`),
			).
			SelectNextItem().
			Press(keys.Commits.ViewBisectOptions).
			Tap(func() {
				t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as good`)).Confirm()

				t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit 08.*Do you want to reset")).Confirm()

				t.Views().Information().Content(DoesNotContain("Bisecting"))
			}).
			Lines(
				Contains("only commit on master"),
			)
	},
})
View Source
var Skip = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Start a git bisect and skip a few commits (selected or current)",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.
			CreateNCommits(10)
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.AppState.GitLogShowGraph = "never"
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().
			Focus().
			SelectedLine(Contains("commit 10")).
			Press(keys.Commits.ViewBisectOptions).
			Tap(func() {
				t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as bad`)).Confirm()
			}).
			NavigateToLine(Contains("commit 01")).
			Press(keys.Commits.ViewBisectOptions).
			Tap(func() {
				t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as good`)).Confirm()
				t.Views().Information().Content(Contains("Bisecting"))
			}).
			Lines(
				Contains("CI commit 10").Contains("<-- bad"),
				Contains("CI commit 09").DoesNotContain("<--"),
				Contains("CI commit 08").DoesNotContain("<--"),
				Contains("CI commit 07").DoesNotContain("<--"),
				Contains("CI commit 06").DoesNotContain("<--"),
				Contains("CI commit 05").Contains("<-- current").IsSelected(),
				Contains("CI commit 04").DoesNotContain("<--"),
				Contains("CI commit 03").DoesNotContain("<--"),
				Contains("CI commit 02").DoesNotContain("<--"),
				Contains("CI commit 01").Contains("<-- good"),
			).
			Press(keys.Commits.ViewBisectOptions).
			Tap(func() {
				t.ExpectPopup().Menu().Title(Equals("Bisect")).
					Lines(
						Contains("b Mark current commit").Contains("as bad"),
						Contains("g Mark current commit").Contains("as good"),
						Contains("s Skip current commit"),
						Contains("r Reset bisect"),
						Contains("Cancel"),
					).
					Select(Contains("Skip current commit")).Confirm()
			}).
			Lines(
				Contains("CI commit 10").Contains("<-- bad"),
				Contains("CI commit 09").DoesNotContain("<--"),
				Contains("CI commit 08").DoesNotContain("<--"),
				Contains("CI commit 07").DoesNotContain("<--"),
				Contains("CI commit 06").Contains("<-- current").IsSelected(),
				Contains("CI commit 05").Contains("<-- skipped"),
				Contains("CI commit 04").DoesNotContain("<--"),
				Contains("CI commit 03").DoesNotContain("<--"),
				Contains("CI commit 02").DoesNotContain("<--"),
				Contains("CI commit 01").Contains("<-- good"),
			).
			NavigateToLine(Contains("commit 07")).
			Press(keys.Commits.ViewBisectOptions).
			Tap(func() {
				t.ExpectPopup().Menu().Title(Equals("Bisect")).
					Lines(
						Contains("b Mark current commit").Contains("as bad"),
						Contains("g Mark current commit").Contains("as good"),
						Contains("s Skip current commit"),
						Contains("S Skip selected commit"),
						Contains("r Reset bisect"),
						Contains("Cancel"),
					).
					Select(Contains("Skip selected commit")).Confirm()
			}).
			SelectedLine(Contains("CI commit 07").Contains("<-- skipped"))
	},
})

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL