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

Chore: Refactor CLIEngine tests (refs #13481) #13709

Merged
merged 5 commits into from Oct 9, 2020

Conversation

nzakas
Copy link
Member

@nzakas nzakas commented Sep 22, 2020

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[x] Other, please explain:

Refactored a test

What changes did you make? (Give an overview)

I removed the in-memory file system from the CLIEngine tests and replaced it with an actual filesystem. This is important for working on simple config because the in-memory filesystem does all kinds of complicated things to "fake" a filesystem, and it's impossible to reuse that to test that simple config doesn't break anything.

This change keeps all of the tests working the exact same way they did previously, only with an actual filesystem. That will allow me to eventually start using exports from @eslint/eslintrc inside CLIEngine and tell if I broke anything.

I'll need to do the same for the rest of the places in the tests where in-memory filesystems are used, so this is the first of a few such refactors.

Is there anything you'd like reviewers to focus on?

Anything obvious look out of place?

@nzakas nzakas added core Relates to ESLint's core APIs and features accepted There is consensus among the team that this change meets the criteria for inclusion chore This change is not user-facing labels Sep 22, 2020
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

Looks good, I left some questions.

tests/lib/cli-engine/cli-engine.js Outdated Show resolved Hide resolved
tests/lib/cli-engine/cli-engine.js Outdated Show resolved Hide resolved
tests/lib/cli-engine/cli-engine.js Show resolved Hide resolved
tests/lib/cli-engine/cli-engine.js Show resolved Hide resolved
tests/lib/cli-engine/cli-engine.js Show resolved Hide resolved
@nzakas
Copy link
Member Author

nzakas commented Sep 28, 2020

Feedback addressed.

Copy link
Member

@btmills btmills left a comment

Choose a reason for hiding this comment

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

I saw two inconsistencies in your beforeEach/afterEach patterns. Not sure if that falls under the category of looking out of place, so I'll leave it to you to decide how much you care that they all follow the same pattern.

I left a code suggestion for a .skip that will demonstrate the broken ../.eslintrc.json not being cleaned up after its test. Hopefully that's enough to help you diagnose. Once that's resolved, LGTM.


Helpful tip for future reviewers: updating the your comparison view settings to ignore whitespace will shave a few hundred lines off the diff.

tests/lib/cli-engine/cli-engine.js Outdated Show resolved Hide resolved
tests/lib/cli-engine/cli-engine.js Outdated Show resolved Hide resolved
tests/lib/cli-engine/cli-engine.js Show resolved Hide resolved
@nzakas
Copy link
Member Author

nzakas commented Oct 7, 2020

Updated to:

  1. Explicitly delete the ../.eslintrc.json file in the one block where that's used.
  2. Normalize the beforeEach/afterEach patterns. Note that in cases where cleanup is being overwritten inside a test case, I needed to use afterEach(() => cleanup()) instead of afterEach(cleanup) because the latter evaluates cleanup immediately (resulting in undefined) and the former evaluates cleanup at the time it executes.

Copy link
Member

@btmills btmills left a comment

Choose a reason for hiding this comment

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

Works for me! LGTM

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

Just two small notes. LGTM if you think there's no need to fix those at the moment.

tests/lib/cli-engine/cli-engine.js Show resolved Hide resolved
tests/lib/cli-engine/cli-engine.js Outdated Show resolved Hide resolved
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@mdjermanovic mdjermanovic merged commit 23e966f into master Oct 9, 2020
@mdjermanovic mdjermanovic deleted the simple-config-step-2 branch October 9, 2020 16:30
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Apr 8, 2021
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Apr 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion chore This change is not user-facing core Relates to ESLint's core APIs and features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants