Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a specific issue within the Crashlytics sourcemap upload unit tests. The primary goal is to ensure the reliability of these tests by accurately simulating the execution environment, particularly concerning the current working directory, and updating the expected file path patterns to reflect these changes. This ensures the tests correctly validate the functionality of finding and uploading mapping files. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request modifies a test for Crashlytics sourcemap upload, specifically for finding and uploading mapping files in the current directory. The change involves temporarily altering the current working directory (process.chdir) for the duration of the test. The reviewer identified a potential issue where the original working directory might not be restored if an error occurs during the test, which could lead to test flakiness. A try...finally block was suggested to ensure the current working directory is always reset.
| const originalCwd = process.cwd(); | ||
| process.chdir("src/test"); | ||
| await command.runner()(undefined, { app: "test-app" }); | ||
| const uploadedFiles = gcsMock.uploadObject | ||
| .getCalls() | ||
| .map((call) => call.args[0].file) | ||
| .sort(); | ||
| expect(uploadedFiles[0]).to.match( | ||
| /test-app-.*-src-test-fixtures-mapping-files-mock_mapping\.js\.map\.zip/, | ||
| /test-app-.*-fixtures-mapping-files-mock_mapping\.js\.map\.zip/, | ||
| ); | ||
| expect(uploadedFiles[1]).to.match( | ||
| /test-app-.*-src-test-fixtures-mapping-files-subdir-subdir_mock_mapping\.js\.map\.zip/, | ||
| /test-app-.*-fixtures-mapping-files-subdir-subdir_mock_mapping\.js\.map\.zip/, | ||
| ); | ||
| expect(uploadedFiles[2]).to.match( | ||
| /test-app-.*-src-test-fixtures-mapping-files-with-js-main\.js\.map\.zip/, | ||
| /test-app-.*-fixtures-mapping-files-with-js-main\.js\.map\.zip/, | ||
| ); | ||
| expect(uploadedFiles[3]).to.match( | ||
| /test-app-.*-src-test-fixtures-mapping-files-with-js-other\.js\.map\.zip/, | ||
| /test-app-.*-fixtures-mapping-files-with-js-other\.js\.map\.zip/, | ||
| ); | ||
| process.chdir(originalCwd); |
There was a problem hiding this comment.
While changing the current working directory fixes the test, it introduces a potential for test flakiness. If command.runner() or any of the assertions throw an error, process.chdir(originalCwd) will not be executed. This would leave the CWD changed, which could affect other tests in the suite.
To ensure the CWD is always restored, it's best practice to wrap the test logic in a try...finally block.
const originalCwd = process.cwd();
try {
process.chdir("src/test");
await command.runner()(undefined, { app: "test-app" });
const uploadedFiles = gcsMock.uploadObject
.getCalls()
.map((call) => call.args[0].file)
.sort();
expect(uploadedFiles[0]).to.match(
/test-app-.*-fixtures-mapping-files-mock_mapping\.js\.map\.zip/,
);
expect(uploadedFiles[1]).to.match(
/test-app-.*-fixtures-mapping-files-subdir-subdir_mock_mapping\.js\.map\.zip/,
);
expect(uploadedFiles[2]).to.match(
/test-app-.*-fixtures-mapping-files-with-js-main\.js\.map\.zip/,
);
expect(uploadedFiles[3]).to.match(
/test-app-.*-fixtures-mapping-files-with-js-other\.js\.map\.zip/,
);
} finally {
process.chdir(originalCwd);
}
Description
Fix unit tests for crashlytics:sourcemap:upload