Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libgit2: Testing managed and unmanaged transport #745

Closed
pjbgf opened this issue May 29, 2022 · 2 comments
Closed

libgit2: Testing managed and unmanaged transport #745

pjbgf opened this issue May 29, 2022 · 2 comments
Labels
area/git Git related issues and pull requests area/testing Testing related issues and pull requests

Comments

@pjbgf
Copy link
Member

pjbgf commented May 29, 2022

Given that managed.InitManagedTransport is an unreversible operation, and that we want to support both unmanaged and managed transport for at least a minor release, we might want to run tests against both when that makes sense, and skip when a specific test is transport sensitive.

Something around the lines of:

func TestMain(m *testing.M) {
	// execute test against unmanaged transport
	code := m.Run()
	if code != 0 {
		os.Exit(code)
	}
	managed.InitManagedTransport(logr.Discard())

	// execute test against managed transport
	code = m.Run()
	os.Exit(code)
}

func TestManaged_something(t *testing.T) {
	if !managed.Enabled() {
		t.Skip()
	}

	// Managed only tests...
}

func TestUnmanaged_something(t *testing.T) {
	if managed.Enabled() {
		t.Skip()
	}

	// Unmanaged only tests...
}

func TestBoth_something(t *testing.T) {
	// Test supported for both managed and unmanaged...
}

Potential follow-up of #744, #727 and #718.

@pjbgf pjbgf added area/testing Testing related issues and pull requests area/git Git related issues and pull requests labels May 29, 2022
@aryan9600
Copy link
Member

#746 addresses the same issue in a different way. Instead of using a TestMain and skipping tests, when required it places all the tests in different files strategically, leveraging the fact that golang runs tests in a package based on an alphabetical order of the file names in the package. This lets us run all the tests using unmanaged transports prior to any other tests, letting us test both managed and unmanaged transports.

@pjbgf
Copy link
Member Author

pjbgf commented Jun 10, 2022

Closed by #777

@pjbgf pjbgf closed this as completed Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/git Git related issues and pull requests area/testing Testing related issues and pull requests
Projects
Status: Done
Development

No branches or pull requests

2 participants