Skip to content

Don't use file system for custom spoken form tests#2638

Closed
AndreasArvidsson wants to merge 4 commits intomainfrom
defaultSpokeInFormsOnTest
Closed

Don't use file system for custom spoken form tests#2638
AndreasArvidsson wants to merge 4 commits intomainfrom
defaultSpokeInFormsOnTest

Conversation

@AndreasArvidsson
Copy link
Member

@AndreasArvidsson AndreasArvidsson commented Aug 5, 2024

#2538

This should help with the ci tests failing on mac

Checklist

  • [/] I have added tests
  • [/] I have updated the docs and cheatsheet
  • [/] I have not broken the cheatsheet

@AndreasArvidsson AndreasArvidsson requested a review from a team as a code owner August 5, 2024 11:52
@AndreasArvidsson AndreasArvidsson marked this pull request as draft August 5, 2024 12:11
@AndreasArvidsson AndreasArvidsson linked an issue Aug 5, 2024 that may be closed by this pull request
@pokey
Copy link
Member

pokey commented Aug 5, 2024

No you'd need to create a new class that you use for mocking. Then you return that class in test helpers and tell it what custom spoken forms should be rather than using file system

@AndreasArvidsson
Copy link
Member Author

No you'd need to create a new class that you use for mocking. Then you return that class in test helpers and tell it what custom spoken forms should be rather than using file system

I understood that, but that tests now are writing to the file system so we need to do a bit more than just create a new class. We also need to update the tests and then comes the question are we just now testing our mocks?

@pokey
Copy link
Member

pokey commented Aug 5, 2024

No I don't think so. The class we're stubbing out is quite small so I think all the custom spoken forms machinery that sits atop it is worth testing

Tbh if you're looking for a really quick fix you could just disable these tests for Mac for now. I think I'd either do that or do the full approach I mention above

@AndreasArvidsson
Copy link
Member Author

I will have a look at it when I have some spare time

@AndreasArvidsson AndreasArvidsson marked this pull request as ready for review August 6, 2024 09:52

async getSpokenFormEntries(): Promise<SpokenFormEntry[]> {
if (this.entries == null) {
throw new NeedsInitialTalonUpdateError("FakeTalonSpokenForms");
Copy link
Member Author

@AndreasArvidsson AndreasArvidsson Aug 6, 2024

Choose a reason for hiding this comment

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

This is what the file system based implementation does if the json file doesn't exist. The custom spoken form implementation has a special case for this error where it defaults to spoken forms without showing a error.

const regex = "[a-zA-Z]+";

const spokenFormJsonContents = {
version: 0,
Copy link
Member Author

Choose a reason for hiding this comment

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

The version is only used by the file system implementation

const parseTreeApi = await getParseTreeApi();

const { vscodeIDE, hats, fileSystem } = await createVscodeIde(context);
const isTesting = vscodeIDE.runMode === "test";
Copy link
Member Author

Choose a reason for hiding this comment

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

We're doing this exact check in multiple places I think storing it to a variable increases readability

@AndreasArvidsson
Copy link
Member Author

Updated with fake spoken forms

Copy link
Member

@phillco phillco left a comment

Choose a reason for hiding this comment

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

Since the sleep seems to be the thing that fixes the issue, let's split that into a smaller we can land right away, and the change in memory files as a separate we can discuss separately/later

@AndreasArvidsson
Copy link
Member Author

Separate pull request with just the sleep
#2645

@AndreasArvidsson AndreasArvidsson marked this pull request as draft August 6, 2024 17:26
@AndreasArvidsson AndreasArvidsson changed the title Don't use custom spoken forms on test Don't use file system for custom spoken form tests Aug 6, 2024
@AndreasArvidsson
Copy link
Member Author

Closing this

@AndreasArvidsson AndreasArvidsson deleted the defaultSpokeInFormsOnTest branch November 18, 2024 07:37
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.

macOS tests sometimes temporarily fail on CI

3 participants