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

Refactor tests, improve logging #45

Merged
merged 7 commits into from
Feb 16, 2024
Merged

Refactor tests, improve logging #45

merged 7 commits into from
Feb 16, 2024

Conversation

farshidtz
Copy link
Member

Closes #33

Use new util functions from canonical/matter-snap-testing#11

@farshidtz farshidtz changed the title Refactor tests Refactor tests, improve logging Feb 14, 2024
@farshidtz farshidtz marked this pull request as ready for review February 14, 2024 16:46
if err != nil {
t.Fatalf("Error starting application: %s\n", err)
}
func TestAllClustersApp(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function's purpose is to test the commission and control function of the chip-tool. AllClustersApp is only a helper snap here, rather than the main purpose. How about updating the function name to something such as TestCommissionAndControl()?

Copy link
Member Author

@farshidtz farshidtz Feb 15, 2024

Choose a reason for hiding this comment

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

I agree. However, the full test do end up having meaningful names:

--- PASS: TestAllClustersApp (3.34s)
    --- PASS: TestAllClustersApp/Commission (0.98s)
    --- PASS: TestAllClustersApp/Control (1.35s)

An accurate parent test function name could be TestCommissionAndControlAllClustersApp because it is testing commission and control of that app rather than some mocked generic target. But that is a very long name and mostly redundant when combined with subtest names.

})
}

func waitForLogMessage(t *testing.T, logPath, expectedMsg string, since time.Time) {
Copy link
Contributor

Choose a reason for hiding this comment

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

To distinguish this function from utils.WaitForLogMessage():

Suggested change
func waitForLogMessage(t *testing.T, logPath, expectedMsg string, since time.Time) {
func waitForLocalLogFileMessage(t *testing.T, logPath, expectedMsg string, since time.Time) {

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 function signatures are distinct, and this doesn't wait for a "local log file message". I'd keep this name unless there is a better suggestion.

@farshidtz farshidtz requested a review from locnnil February 15, 2024 20:18
Copy link
Contributor

@locnnil locnnil left a comment

Choose a reason for hiding this comment

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

The environment variables used on this test suite are undocumented. They are mainly realted to matter-snap-testing, but would be good to add a reference link once this issue was solved:
canonical/matter-snap-testing#14

Copy link
Contributor

@locnnil locnnil left a comment

Choose a reason for hiding this comment

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

Despite the minor suggestions, everything looks good!

tests/snap_test.go Outdated Show resolved Hide resolved
tests/snap_test.go Outdated Show resolved Hide resolved
tests/snap_test.go Show resolved Hide resolved
@farshidtz
Copy link
Member Author

The environment variables used on this test suite are undocumented. They are mainly realted to matter-snap-testing, but would be good to add a reference link once this issue was solved:
canonical/matter-snap-testing#14

Thanks for pointing this out. However, these aren't related to changes made in this PR. I'm going to create a separate issue.

Copy link
Contributor

@locnnil locnnil left a comment

Choose a reason for hiding this comment

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

Everything looks good! Thank you!

@farshidtz farshidtz merged commit 5488416 into main Feb 16, 2024
2 checks passed
@farshidtz farshidtz deleted the refactor-tests branch February 16, 2024 14:06
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.

Standard output of the Chip Tool command not in test artifacts
3 participants