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

NF: Move instrumented test functions #17419

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

Arthur-Milchior
Copy link
Member

This PR move some code so that it can easily be reused. Multiple PR are going to be based on them, and use the method the current PR introduce.

Copy link
Member

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

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

no issue with the extraction though it's not completely NF is it? (deck with unique name, one pressBack went away?)

structurally they are not test objects though, should be in testutils I think (sibling directory)

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Nov 11, 2024
@Arthur-Milchior
Copy link
Member Author

DeckWithUniqueName does not create a change in behavior. It is exactly the same behavior that the one that existed before this commit. It creates a deck based on the timestamp. The only difference being that now it generates the timestamp itself. This remove code duplication as many methods gave the same string as paramater.

One back press indeed went away. Given that the method was used only in disabled test, I'd still argue that it's NF. I can remove the NF if you want. In any case, the second back press was the cause of the failure, so it had to be removed. Otherwise the method was not usable.
Indeed, the second back press, closed the deck picker, thus closed ankidroid, which caused the test failure

@Arthur-Milchior
Copy link
Member Author

I admit that it's not clear to me what is inside /anki, what is inside utils, testutils, test, an dialogs.
If we have any specific rules, I'd love if we could write them down. Probably in README.md files in each directory, or at least in the anki/ directory

@Arthur-Milchior Arthur-Milchior added Needs Review and removed Needs Author Reply Waiting for a reply from the original author labels Nov 11, 2024
@mikehardy
Copy link
Member

mikehardy commented Nov 11, 2024

Not sure on rules in all cases, but in this case test/ should have actual tests, and things just used by tests are in utils/ (or some utils dir, testutils/ seems used here already) because they are more like test utilities - at least that's where I think they should go

I'm okay with those mostly-maybe-not-quite-NF changes, especially based on your comments

@mikehardy mikehardy added the Needs Second Approval Has one approval, one more approval to merge label Nov 11, 2024
Some functions in Reviewer Test were actually about DeckPicker or
StudyOption

I move them so that they become easier to find out and reuse.

I also introduce some utility function to remove some code
duplication.

I expect to use those functions to repair tests in the deck picker
test suite, and create deck option tests.

The only actual difference is that createDeckWithCard now neds with a
single `pressBack`. The second one was closing ankidroid, and thus
causing the test to fail.
Let's consider the case where you want to test every second during 2
seconds. And the test takes .1 second.

Then the first test starts at 0 second, halts at .1 second, and sleep
until 1.1 second. The second run starts at 1.1 seconds, runs until 1.2
seconds, and the thread sleep until 2.2 seconds. Then there is no more
run, as the 2 seconds limit is done.

I expect in this case the developer wanted to run the test thrice, and
actually test at or after 2 seconds. This change ensure it. It also
remove the last useless sleep.
@Arthur-Milchior
Copy link
Member Author

I added a second commit @mikehardy. Because I believe the function as implemented was not exactly what a developer might expect while using it.

Copy link
Member

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

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

the second commit does seem like an improvement, thanks

Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

Cheers

@david-allison david-allison added this pull request to the merge queue Nov 12, 2024
Merged via the queue into ankidroid:main with commit f4b0826 Nov 12, 2024
9 checks passed
@github-actions github-actions bot added this to the 2.20 Release milestone Nov 12, 2024
@github-actions github-actions bot removed Needs Review Needs Second Approval Has one approval, one more approval to merge labels Nov 12, 2024
@Arthur-Milchior Arthur-Milchior deleted the deckpicker_util branch November 12, 2024 22:18
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.

3 participants