Skip to content

Commit

Permalink
vm: refactor TestRunWithDifferentArguments as it takes too long to pass
Browse files Browse the repository at this point in the history
This test is slow on Windows, so refactor it a bit and avoid the following
error:
```
--- FAIL: TestRunWithDifferentArguments (4.01s)
	cli_test.go:96:
		Error Trace:    cli_test.go:96
										cli_test.go:321
		Error:          command took too long time
		Test:           TestRunWithDifferentArguments
```
  • Loading branch information
AnnaShaleva committed Feb 8, 2022
1 parent eedeb77 commit 705a89f
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions pkg/vm/cli/cli_test.go
Expand Up @@ -318,48 +318,54 @@ func TestRunWithDifferentArguments(t *testing.T) {

filename = "'" + filename + "'"
e := newTestVMCLI(t)
e.runProg(t,
"loadgo "+filename, "run notexists",
"loadgo "+filename, "run negate false",
"loadgo "+filename, "run negate true",
"loadgo "+filename, "run negate bool:invalid",
"loadgo "+filename, "run getInt 123",
"loadgo "+filename, "run getInt int:invalid",
"loadgo "+filename, "run getString validstring",
"loadgo "+filename, "run initHasRun",
"loadhex "+hex.EncodeToString([]byte{byte(opcode.ADD)}),
"run _ 1 2",
"loadbase64 "+base64.StdEncoding.EncodeToString([]byte{byte(opcode.MUL)}),
"run _ 21 2",
)

e.runProg(t, "loadgo "+filename, "run notexists")
e.checkNextLine(t, "READY: loaded \\d.* instructions")
e.checkNextLine(t, "Error:")

e = newTestVMCLI(t)
e.runProg(t, "loadgo "+filename, "run negate false")
e.checkNextLine(t, "READY: loaded \\d.* instructions")
e.checkStack(t, true)

e = newTestVMCLI(t)
e.runProg(t, "loadgo "+filename, "run negate true")
e.checkNextLine(t, "READY: loaded \\d.* instructions")
e.checkStack(t, false)

e = newTestVMCLI(t)
e.runProg(t, "loadgo "+filename, "run negate bool:invalid")
e.checkNextLine(t, "READY: loaded \\d.* instructions")
e.checkError(t, ErrInvalidParameter)

e = newTestVMCLI(t)
e.runProg(t, "loadgo "+filename, "run getInt 123")
e.checkNextLine(t, "READY: loaded \\d.* instructions")
e.checkStack(t, 123)

e = newTestVMCLI(t)
e.runProg(t, "loadgo "+filename, "run getInt int:invalid")
e.checkNextLine(t, "READY: loaded \\d.* instructions")
e.checkError(t, ErrInvalidParameter)

e = newTestVMCLI(t)
e.runProg(t, "loadgo "+filename, "run getString validstring")
e.checkNextLine(t, "READY: loaded \\d.* instructions")
e.checkStack(t, "validstring")

e = newTestVMCLI(t)
e.runProg(t, "loadgo "+filename, "run initHasRun")
e.checkNextLine(t, "READY: loaded \\d.* instructions")
e.checkStack(t, true)

e = newTestVMCLI(t)
e.runProg(t, "loadhex "+hex.EncodeToString([]byte{byte(opcode.ADD)}),
"run _ 1 2")
e.checkNextLine(t, "READY: loaded \\d.* instructions")
e.checkStack(t, 3)

e = newTestVMCLI(t)
e.runProg(t, "loadbase64 "+base64.StdEncoding.EncodeToString([]byte{byte(opcode.MUL)}),
"run _ 21 2")
e.checkNextLine(t, "READY: loaded \\d.* instructions")
e.checkStack(t, 42)
}
Expand Down

0 comments on commit 705a89f

Please sign in to comment.