Skip to content

test(vcs): Fix local find_base_sha test#2908

Merged
chromy merged 1 commit intomasterfrom
2025-11-04-fix-local-test
Nov 4, 2025
Merged

test(vcs): Fix local find_base_sha test#2908
chromy merged 1 commit intomasterfrom
2025-11-04-fix-local-test

Conversation

@chromy
Copy link
Copy Markdown
Contributor

@chromy chromy commented Nov 4, 2025

The following test:

// Test without GITHUB_EVENT_PATH
std::env::remove_var("GITHUB_EVENT_PATH");
let result = find_base_sha("orgin");
assert!(result.is_err());

can't really work well both in CI and locally.

Locally there will (almost) always be a merge-base between the local HEAD and the default
merge branch. In GitHub CI there will almost never be a merge-base which is why we need
to inspect GITHUB_EVENT_PATH sometimes in the first place.

For now replace that with:

// Test without GITHUB_EVENT_PATH
std::env::remove_var("GITHUB_EVENT_PATH");
let result = find_base_sha("no_such_branch");
assert!(result.is_err());

Which tests a different code path which should fail on both.

@chromy chromy requested review from a team and szokeasaurusrex as code owners November 4, 2025 13:19
Copy link
Copy Markdown
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still in progress? If yes, please mark as draft; otherwise, please add a PR description, since I am unsure what this change's purpose is

Copy link
Copy Markdown
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm — Please consider renaming the PR to "test(vcs): ..." as this is only changing test code (that change should also make the Danger CI failure go away, as changelog is not required for "test" changes; you might need to manually retrigger the Danger check)

Comment thread src/utils/vcs.rs
// Test without GITHUB_EVENT_PATH
std::env::remove_var("GITHUB_EVENT_PATH");
let result = find_base_sha("origin");
let result = find_base_sha("no_such_remote");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, so this test will pass locally as long as the user hasn't configured a no_such_remote git remote?

Def agree with what you wrote on Slack that this is not ideal. Would be nice to make the tests not depend on local git state, but this is fine as a workaround I suppose

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep exactly

@chromy chromy changed the title fix(vcs): Fix local find_base_sha test test(vcs): Fix local find_base_sha test Nov 4, 2025
@chromy
Copy link
Copy Markdown
Contributor Author

chromy commented Nov 4, 2025

lgtm — Please consider renaming the PR to "test(vcs): ..." as this is only changing test code (that change should also make the Danger CI failure go away, as changelog is not required for "test" changes; you might need to manually retrigger the Danger check)

Thanks done!

@chromy chromy merged commit bec709e into master Nov 4, 2025
45 of 47 checks passed
@chromy chromy deleted the 2025-11-04-fix-local-test branch November 4, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants