Skip to content

Commit

Permalink
[FAB-1481] Clean up created files after test
Browse files Browse the repository at this point in the history
Change-Id: Id9323d1cfc7c55e389468414d87c9362312ebc95
Signed-off-by: Gabor Hosszu <gabor@digitalasset.com>
  • Loading branch information
gaborh-da committed Dec 28, 2016
1 parent f9b68d4 commit 1d2ab7e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions orderer/sbft/main/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ import (

const keyfile = "testdata/key.pem"
const maindir = "github.com/hyperledger/fabric/orderer/sbft/main"
const mainexe = "main"

var mainexe = os.TempDir() + "/" + "sbft"

type peer struct {
id uint64
Expand All @@ -67,12 +68,16 @@ func skipInShortMode(t *testing.T) {
}

func build() {
buildcmd := exec.Command("go", "build", maindir)
buildcmd := exec.Command("go", "build", "-o", mainexe, maindir)
buildcmd.Stdout = os.Stdout
buildcmd.Stderr = os.Stderr
panicOnError(buildcmd.Run())
}

func deleteExe() {
panicOnError(os.Remove(mainexe))
}

func install() {
installcmd := exec.Command("go", "install", maindir)
installcmd.Stdout = os.Stdout
Expand All @@ -82,8 +87,8 @@ func install() {

func TestMain(m *testing.M) {
build()
install()
code := m.Run()
deleteExe()
os.Exit(code)
}

Expand Down

0 comments on commit 1d2ab7e

Please sign in to comment.