Skip to content
Permalink
Browse files

sanity: turn csi-sanity into normal Go program

The advantage is that "go get" works and that the useless "-test.*"
command line parameters are no longer present.
  • Loading branch information
pohly committed Oct 29, 2019
1 parent d5badbb commit d53f998b4664ecc45043ae93795a28dcb2ef46ec
Showing with 17 additions and 11 deletions.
  1. +3 −2 cmd/csi-sanity/Makefile
  2. +13 −7 cmd/csi-sanity/{sanity_test.go → main.go}
  3. +1 −2 pkg/sanity/sanity.go
@@ -22,8 +22,9 @@ PACKAGE :=$(DIR)/dist/$(APP_NAME)-$(RELEASEVER).$(GOOS).$(ARCH).tar.gz

all: $(APP_NAME)

$(APP_NAME): Makefile sanity_test.go
go test $(LDFLAGS) -c -o $(APP_NAME)
.PHONY: $(APP_NAME)
$(APP_NAME): Makefile
go build $(LDFLAGS) -o $(APP_NAME)

install: $(APP_NAME)
cp $(APP_NAME) $(GOPATH)/bin
@@ -13,13 +13,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package sanity
package main

import (
"flag"
"fmt"
"os"
"testing"

"github.com/kubernetes-csi/csi-test/pkg/sanity"
)
@@ -49,7 +48,15 @@ func int64Var(p *int64, name string, usage string) {
flag.Int64Var(p, prefix+name, *p, usage)
}

func TestMain(m *testing.M) {
type testing struct {
result int
}

func (t *testing) Fail() {
t.result = 1
}

func main() {
version := flag.Bool("version", false, "print version of this program")

// Support overriding the default configuration via flags.
@@ -79,9 +86,8 @@ func TestMain(m *testing.M) {
fmt.Printf("--%sendpoint must be provided with an CSI endpoint\n", prefix)
os.Exit(1)
}
os.Exit(m.Run())
}

func TestSanity(t *testing.T) {
sanity.Test(t, config)
t := testing{}
sanity.Test(&t, config)
os.Exit(t.result)
}
@@ -24,7 +24,6 @@ import (
"os"
"os/exec"
"strings"
"testing"
"time"

"github.com/kubernetes-csi/csi-test/utils"
@@ -185,7 +184,7 @@ func newTestContext(config *TestConfig) *TestContext {

// Test will test the CSI driver at the specified address by
// setting up a Ginkgo suite and running it.
func Test(t *testing.T, config TestConfig) {
func Test(t GinkgoTestingT, config TestConfig) {
sc := GinkgoTest(&config)
RegisterFailHandler(Fail)

0 comments on commit d53f998

Please sign in to comment.
You can’t perform that action at this time.