Skip to content

Bun fix the unit tests 4 - #9379

Draft
danieljbruce wants to merge 4 commits into
mainfrom
bun-fix-the-unit-tests-4
Draft

danieljbruce wants to merge 4 commits into
mainfrom
bun-fix-the-unit-tests-4

Conversation

@danieljbruce

Copy link
Copy Markdown
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for running tests with Bun in the core/paginator package, including adding a Bun configuration, a test shim, and updating Jest configurations and test files to use bun:test imports. It also modifies CI scripts to handle Bun test execution and conditional test triggers. Feedback on the changes highlights two key issues: first, returning a promise when a callback is provided in src/index.ts can lead to unhandled promise rejections if the callback throws an error; second, reordering the conditional checks in run_conditional_tests.sh bypasses the skip logic for core packages during non-core triggers, unnecessarily wasting CI resources.

Comment on lines +241 to 244
return promise.then(
results => callback(null, results, query, ...otherArgs),
(err: Error) => callback(err),
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Returning the promise when a callback is provided can lead to unhandled promise rejections if the callback throws an error. Since callers using callbacks do not typically catch returned promises, any synchronous error thrown inside the callback will reject the returned promise and go unhandled. Use the void operator to discard the promise instead of returning it. Additionally, avoid wrapping the callback in an arrow function for the error case to prevent unnecessary closure allocations.

Suggested change
return promise.then(
results => callback(null, results, query, ...otherArgs),
(err: Error) => callback(err),
);
void promise.then(
results => callback(null, results, query, ...otherArgs),
callback,
);
References
  1. Avoid wrapping methods in arrow functions for default cases to prevent unnecessary closure allocations and extra call stack frames.

Comment on lines +223 to 230
elif [[ "${TEST_TYPE}" == "lint" ]] || [[ "${TEST_TYPE}" == "units" ]]; then
echo "change detected in ${d} for ${TEST_TYPE} test"
should_test=true
elif [[ "${d}" == core/packages/* ]] || [[ "${d}" == core/dev-packages/* ]]; then
echo "skipping core package ${d} in non-core trigger"
elif [[ "${TEST_TYPE}" == "system" ]] || [[ "${TEST_TYPE}" == "lint" ]] || [[ "${TEST_TYPE}" == "units" ]]; then
elif [[ "${TEST_TYPE}" == "system" ]]; then
echo "change detected in ${d} for ${TEST_TYPE} test"
should_test=true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Placing the lint and units test checks above the core package skip check bypasses the skip logic for those test types in non-core triggers. This will cause core packages to run unit and lint tests unnecessarily during non-core trigger builds, wasting CI resources. Keep the core package skip check at the top of the conditional block.

Suggested change
elif [[ "${TEST_TYPE}" == "lint" ]] || [[ "${TEST_TYPE}" == "units" ]]; then
echo "change detected in ${d} for ${TEST_TYPE} test"
should_test=true
elif [[ "${d}" == core/packages/* ]] || [[ "${d}" == core/dev-packages/* ]]; then
echo "skipping core package ${d} in non-core trigger"
elif [[ "${TEST_TYPE}" == "system" ]] || [[ "${TEST_TYPE}" == "lint" ]] || [[ "${TEST_TYPE}" == "units" ]]; then
elif [[ "${TEST_TYPE}" == "system" ]]; then
echo "change detected in ${d} for ${TEST_TYPE} test"
should_test=true
elif [[ "${d}" == core/packages/* ]] || [[ "${d}" == core/dev-packages/* ]]; then
echo "skipping core package ${d} in non-core trigger"
elif [[ "${TEST_TYPE}" == "system" ]] || [[ "${TEST_TYPE}" == "lint" ]] || [[ "${TEST_TYPE}" == "units" ]]; then
echo "change detected in ${d} for ${TEST_TYPE} test"
should_test=true

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.

1 participant