Skip to content
This repository has been archived by the owner on May 11, 2020. It is now read-only.

Commit

Permalink
wagon: add initial doc + gofmt test
Browse files Browse the repository at this point in the history
This CL adds an initial documentation placeholder for the wagon package.
It also adds a simple test to make sure files are being gofmt'ed.
  • Loading branch information
sbinet committed May 26, 2017
1 parent 21c4a5b commit de0a5a5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright 2017 The go-interpreter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Package wagon is a WebAssembly-based interpreter in Go, for Go.
package wagon
40 changes: 40 additions & 0 deletions wagon_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2017 The go-interpreter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package wagon

import (
"bytes"
"os/exec"
"testing"
)

func TestGofmt(t *testing.T) {
exe, err := exec.LookPath("goimports")
if err != nil {
switch e := err.(type) {
case *exec.Error:
if e.Err == exec.ErrNotFound {
exe, err = exec.LookPath("gofmt")
}
}
}
if err != nil {
t.Fatal(err)
}

cmd := exec.Command(exe, "-d", ".")
buf := new(bytes.Buffer)
cmd.Stdout = buf
cmd.Stderr = buf

err = cmd.Run()
if err != nil {
t.Fatalf("error running %s:\n%s\n%v", exe, string(buf.Bytes()), err)
}

if len(buf.Bytes()) != 0 {
t.Errorf("some files were not gofmt'ed:\n%s\n", string(buf.Bytes()))
}
}

0 comments on commit de0a5a5

Please sign in to comment.