From 76a6ddc3a467546908e1c7af48e910f01365b54c Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 10 Dec 2020 13:35:50 +0300 Subject: [PATCH 1/2] vmcli/test: run shell after providing input In some cases, `Run()` can read from input before we have written anything to it. --- pkg/vm/cli/cli_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/vm/cli/cli_test.go b/pkg/vm/cli/cli_test.go index 87efc1656..d59bcedad 100644 --- a/pkg/vm/cli/cli_test.go +++ b/pkg/vm/cli/cli_test.go @@ -75,16 +75,16 @@ func newTestVMCLIWithLogo(t *testing.T, printLogo bool) *executor { Stdin: e.in, Stdout: e.out, }) - go func() { - require.NoError(t, e.cli.Run()) - close(e.ch) - }() return e } func (e *executor) runProg(t *testing.T, commands ...string) { cmd := strings.Join(commands, "\n") + "\n" e.in.WriteString(cmd + "\n") + go func() { + require.NoError(t, e.cli.Run()) + close(e.ch) + }() select { case <-e.ch: case <-time.After(time.Second): From c7ce9cd4f6859891ba74046f2494f40679cb0038 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 10 Dec 2020 13:40:27 +0300 Subject: [PATCH 2/2] compiler: defer dir removal right after creation --- pkg/compiler/compiler_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/compiler/compiler_test.go b/pkg/compiler/compiler_test.go index 3341fb799..c9aad096d 100644 --- a/pkg/compiler/compiler_test.go +++ b/pkg/compiler/compiler_test.go @@ -61,13 +61,13 @@ func TestCompiler(t *testing.T) { require.NoError(t, err) err = os.MkdirAll(exampleSavePath, os.ModePerm) require.NoError(t, err) - outfile := exampleSavePath + "/test.nef" - _, err = compiler.CompileAndSave(exampleCompilePath+"/"+infos[0].Name(), &compiler.Options{Outfile: outfile}) - require.NoError(t, err) defer func() { err := os.RemoveAll(exampleSavePath) require.NoError(t, err) }() + outfile := exampleSavePath + "/test.nef" + _, err = compiler.CompileAndSave(exampleCompilePath+"/"+infos[0].Name(), &compiler.Options{Outfile: outfile}) + require.NoError(t, err) }, }, }