--- a/loaders/convey/convey.go Tue Sep 19 22:34:39 2017 -0500
+++ b/loaders/convey/convey.go Wed Sep 20 16:13:09 2017 -0500
@@ -19,6 +19,7 @@
"github.com/go-yaml/yaml"
@@ -222,6 +223,8 @@
remaining = append(remaining, k)
+ sort.Strings(remaining) return fmt.Errorf("The following tasks are part of a dependency cycle: %s", strings.Join(remaining, ", "))
--- a/loaders/convey/convey_test.go Tue Sep 19 22:34:39 2017 -0500
+++ b/loaders/convey/convey_test.go Wed Sep 20 16:13:09 2017 -0500
@@ -37,6 +37,7 @@
s.RegisterPlugin(junit.NewPlugin())
s.AddSuite(&conveySuite{})
+ s.AddSuite(&extendSuite{}) s.AddSuite(&extendsSuite{})
s.AddSuite(&defaultPlanSuite{})
s.AddSuite(&environmentSuite{})
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loaders/convey/extend_test.go Wed Sep 20 16:13:09 2017 -0500
@@ -0,0 +1,182 @@
+ * Copyright 2016-2017 Gary Kramlich <grim@reaperworld.com> + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program 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 General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + "github.com/aphistic/sweet" + . "github.com/onsi/gomega" + cConfig "bitbucket.org/rw_grim/convey/config" + "bitbucket.org/rw_grim/convey/intrinsic" +// This test suite tests +type extendSuite struct{} +func (d *extendSuite) TestSimple(t sweet.T) { + cfg, err := loader.Load(".", ".", []byte(data)) + Expect(err).To(BeNil()) + Expect(cfg.Tasks).To(HaveLen(2)) + Expect(cfg.Tasks).To(HaveKey("a")) + Expect(cfg.Tasks).To(HaveKey("b")) + Expect(cfg.Tasks["b"].(*intrinsic.Extend).InnerTask).NotTo(BeIdenticalTo(cfg.Tasks["a"])) + Expect(cfg.Tasks["b"].(*intrinsic.Extend).InnerTask).To(BeEquivalentTo(cfg.Tasks["a"])) +func (d *extendSuite) TestExtendChain(t sweet.T) { + cfg, err := loader.Load(".", ".", []byte(data)) + Expect(err).To(BeNil()) + Expect(cfg.Tasks).To(HaveLen(3)) + Expect(cfg.Tasks).To(HaveKey("a")) + Expect(cfg.Tasks).To(HaveKey("b")) + Expect(cfg.Tasks).To(HaveKey("c")) + Expect(cfg.Tasks["c"].(*intrinsic.Extend).InnerTask).NotTo(BeIdenticalTo(cfg.Tasks["b"])) + Expect(cfg.Tasks["c"].(*intrinsic.Extend).InnerTask).To(BeEquivalentTo(cfg.Tasks["b"])) + Expect(cfg.Tasks["b"].(*intrinsic.Extend).InnerTask).NotTo(BeIdenticalTo(cfg.Tasks["a"])) + Expect(cfg.Tasks["b"].(*intrinsic.Extend).InnerTask).To(BeEquivalentTo(cfg.Tasks["a"])) + Expect(cfg.Tasks["c"].(*intrinsic.Extend).InnerTask.(*intrinsic.Extend).InnerTask).NotTo(BeIdenticalTo(cfg.Tasks["a"])) + Expect(cfg.Tasks["c"].(*intrinsic.Extend).InnerTask.(*intrinsic.Extend).InnerTask).To(BeEquivalentTo(cfg.Tasks["a"])) +func (d *extendSuite) TestCycle(t sweet.T) { + _, err := loader.Load(".", ".", []byte(data)) + Expect(err).To(MatchError("The following tasks are part of a dependency cycle: a, b")) +func (d *extendSuite) TestMissingTask(t sweet.T) { + _, err := loader.Load(".", ".", []byte(data)) + Expect(err).To(MatchError("b: Extending undeclared task 'a'")) +func (d *extendSuite) TestExtendExtends(t sweet.T) { + fileLoader: func(name string, c *Loader) (*cConfig.Config, error) { + return c.Load(".", name, []byte(baseData)) + cfg, err := loader.Load(".", ".", []byte(extendedData)) + Expect(err).To(BeNil()) + Expect(cfg.Tasks).To(HaveLen(2)) + Expect(cfg.Tasks).To(HaveKey("foo")) + Expect(cfg.Tasks).To(HaveKey("bar")) + Expect(cfg.Tasks).To(HaveKey("foo")) + Expect(cfg.Tasks).To(HaveKey("bar")) + Expect(cfg.Tasks["bar"].(*intrinsic.Extend).InnerTask).NotTo(BeIdenticalTo(cfg.Tasks["foo"])) + Expect(cfg.Tasks["bar"].(*intrinsic.Extend).InnerTask).To(BeEquivalentTo(cfg.Tasks["foo"]))