From 9a8acbbcab65ebd7b7b7d38bc65b3dc6908ae3be Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Mon, 16 Apr 2018 13:37:17 -0700 Subject: [PATCH] negative wait WIP --- common/boot_command/boot_command_ast.go | 6 ++++++ common/boot_command/boot_command_ast_test.go | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/common/boot_command/boot_command_ast.go b/common/boot_command/boot_command_ast.go index 16b562e95..38ce97144 100644 --- a/common/boot_command/boot_command_ast.go +++ b/common/boot_command/boot_command_ast.go @@ -84,6 +84,12 @@ type waitExpression struct { // Do waits the amount of time described by the expression. It is cancellable // through the context. func (w *waitExpression) Do(ctx context.Context, _ BCDriver) error { + /* + // do I want this to not parse or to error? + if w.d < 0 { + panic("Was not expecting negative wait duration.") + } + */ log.Printf("[INFO] Waiting %s", w.d) select { case <-time.After(w.d): diff --git a/common/boot_command/boot_command_ast_test.go b/common/boot_command/boot_command_ast_test.go index 613b427b7..60369f572 100644 --- a/common/boot_command/boot_command_ast_test.go +++ b/common/boot_command/boot_command_ast_test.go @@ -99,3 +99,18 @@ func Test_special(t *testing.T) { } } } + +func Test_negativeWait(t *testing.T) { + in := "" + _, err := ParseReader("", strings.NewReader(in)) + if err != nil { + log.Fatal(err) + } + + /* + gL := toIfaceSlice(got) + for _, g := range gL { + assert.Equal(t, tt.out, g.(*specialExpression).String()) + } + */ +}