diff --git a/pythia.mk b/pythia.mk index ab31de3..96b08a0 100644 --- a/pythia.mk +++ b/pythia.mk @@ -15,6 +15,13 @@ ENV_OUT_DIR := $(VM_OUT_DIR) +ENV_GO_DIR := $~/test +ENV_BIND_DIR := $(GO_DIR)/bin +ENV_GOPATH := "$(abspath $(ENV_GO_DIR)):$(abspath $(GO_DIR))" +ENV_GO := GOPATH=$(ENV_GOPATH) go + +ENV_GO_PACKAGES := env_test + # The environments target is filled by the subdirectories $(call add_target,environments,BUILD,Generate all environments) all: environments @@ -22,4 +29,9 @@ environments: $(call include_subdirs, busybox python java mono c) +$(call add_target,envtest,MISC,Run environments tests) +check: envtest +envtest: + $(ENV_GO) test $(ENV_GO_PACKAGES) + # vim:set ts=4 sw=4 noet: diff --git a/test/src/env_test/env_test.go b/test/src/env_test/env_test.go new file mode 100644 index 0000000..ab9d0f3 --- /dev/null +++ b/test/src/env_test/env_test.go @@ -0,0 +1,42 @@ +// Copyright 2013 The Pythia Authors. +// This file is part of Pythia. +// +// Pythia is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// Pythia is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with Pythia. If not, see . + +package env_test + +import ( + "io/ioutil" + "path" + "pythia" + "pythia/backend" + "strings" + "testing" + "testutils/pytest" +) + +func TestEnvironments(t *testing.T) { + backend.Run(t, "hello-input", "me\npythia\n", + pythia.Success, "Hello me!\nHello pythia!\n") + taskfiles, _ := ioutil.ReadDir(pytest.TasksDir) + for _, f := range taskfiles { + if !f.IsDir() && path.Ext(f.Name()) == ".task" { + matched, _ := path.Match("test-*", f.Name()) + if matched { + task := strings.TrimSuffix(f.Name(), path.Ext(f.Name())) + input := "Environment test: " + task + backend.Run(t, task, input, pythia.Success, input) + } + } + } +}