-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
This allows to set and persist shell vars between commands.
internal/grill/runner.go
Outdated
@@ -12,6 +13,9 @@ import ( | |||
"syscall" | |||
) | |||
|
|||
// Token used to separate output of individual commands in a suite. | |||
const testBreak = "__GRILL__" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done; PTAL
internal/grill/runner.go
Outdated
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) + ":" | ||
} |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much nicer; fixed
This allows to set and persist shell vars between commands.