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

Run all tests in a suite in a single script. #10

Merged
merged 4 commits into from
Feb 28, 2022

Conversation

dtcaciuc
Copy link
Collaborator

This allows to set and persist shell vars between commands.

This allows to set and persist shell vars between commands.
@dtcaciuc dtcaciuc requested a review from echlebek February 27, 2022 05:20
@@ -12,6 +13,9 @@ import (
"syscall"
)

// Token used to separate output of individual commands in a suite.
const testBreak = "__GRILL__"
Copy link
Owner

Choose a reason for hiding this comment

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

Seems fragile, shouldn't it work by keeping track of indices?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can't think of how it would work because each test command may output more or less lines than what's expected. Cram uses similar line splits but with the addition of random salt, which I'm guessing is intended to minimize the chance of the separator occurring unintentionally in the test spec. I can add the same here.

Copy link
Owner

Choose a reason for hiding this comment

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

OK, sounds like a good compromise.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done; PTAL

@dtcaciuc dtcaciuc requested a review from echlebek February 27, 2022 21:28
Comment on lines 229 to 240
const digits = "0123456789"

// makeTestBreak generates a randomized line used to separate output of
// individual commands in a suite. Randomized element is added to reduce
// the change of the string occurring in the test output itself.
func makeTestBreak() string {
b := make([]byte, 8)
for i := range b {
b[i] = digits[rand.Intn(len(digits))]
}
return "GRILL" + string(b) + ":"
}
Copy link
Owner

Choose a reason for hiding this comment

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

This is fine, but you can also do this fwiw

b := make([]byte, 8)
rand.Read(b)
return hex.EncodeToString(b)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Much nicer; fixed

@dtcaciuc dtcaciuc merged commit 3db0ec1 into echlebek:master Feb 28, 2022
@dtcaciuc dtcaciuc deleted the shellstate branch February 28, 2022 00:44
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.

2 participants