Skip to content

feat(test): Miscellaneous improvements to test_tasks.js#6615

Merged
cpcallen merged 3 commits into
RaspberryPiFoundation:developfrom
cpcallen:improve-test-tasks
Nov 16, 2022
Merged

feat(test): Miscellaneous improvements to test_tasks.js#6615
cpcallen merged 3 commits into
RaspberryPiFoundation:developfrom
cpcallen:improve-test-tasks

Conversation

@cpcallen

Copy link
Copy Markdown
Collaborator

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide
  • I ran npm run format and npm run lint

The details

Proposed Changes

  • feat: Modify runTestBlock so that it can run any async task, not just ones that return a Promise, by using the async-done package (part of Gulp, and already an indirect dependency) to detect task completion. Celebrate by renaming it to runTestTask.
  • Create a Tester class to encapsulate the runTestTask, reportTestResult and runAll functions.
  • Remove the --silent flag from npm scripts so as not to suppress syntax error in gulpfiles.
  • Have the test task invoke the buildAdvancedCompilationTest task (via onlyBuildAdvancedCompilationTest, to skip already-run prerequisites) directly, rather than by running npm.

Reason for Changes

  • Generally cleaner code.
  • Remove npm scripts that aren't intended to be used by humans.

@cpcallen cpcallen requested a review from a team as a code owner November 11, 2022 18:09
@github-actions github-actions Bot added PR: feature Adds a feature and removed PR: feature Adds a feature labels Nov 11, 2022
@BeksOmega BeksOmega requested review from BeksOmega and removed request for rachel-fenichel November 14, 2022 18:15

@BeksOmega BeksOmega 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.

Slightly confused about the decision to make a Tester class. Otherwise generally LGTM, but want to understand that before approving.

const ANSI_RESET = '\x1b[0m';

let failerCount = 0;
class Tester {

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.

What's the advantage of encapsulating these in a class?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Mainly just to remove the failerCount global variable, and allow us to also count successes without adding a second global.

Comment thread package.json
Modify runTestBlock so that it can run any async task, not just
ones that return a Promise, by using the async-done package
(part of Gulp, and already an indirect dependency) to detect
task completion.

Celebrate by renaming it to runTestTask.
- Create Tester class to encapsulate the runTestTask,
  and reportTestResult and runAll functions.

- Remove the unnecessary id parameter from runTestTask (code was
  already using the .name of the task function object).

- Remove --silent flag from npm scripts so as not to suppress
  syntax error in gulpfiles.
Have the test task invoke the buildAdvancedCompilationTest
(via onlyBuildAdvancedCompilationTest, to skip already-run
prerequisites) directly, rather than by running npm.
@cpcallen

Copy link
Copy Markdown
Collaborator Author

There were merge conflicts, and it seems like I forgot a needed require from test_tasks.js (did I not test this locally? I'm sure I did, and yet…) so I did a rebase and force-push.

Just awaiting approval, assuming you think my justification for the Tester class is sufficient.

@cpcallen cpcallen merged commit 54670d5 into RaspberryPiFoundation:develop Nov 16, 2022
@cpcallen cpcallen deleted the improve-test-tasks branch November 16, 2022 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants