summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmorph3
-rwxr-xr-xtests.branching/init-cwd.script25
-rwxr-xr-xtests.branching/init-default.script24
-rwxr-xr-xtests.branching/init-existing.script24
-rw-r--r--tests.branching/init-newdir.exit1
-rwxr-xr-xtests.branching/init-newdir.script23
-rw-r--r--tests.branching/init-nonempty.exit1
-rwxr-xr-xtests.branching/init-nonempty.script24
-rwxr-xr-xtests.branching/teardown22
9 files changed, 147 insertions, 0 deletions
diff --git a/morph b/morph
index 5e37bab6..d981bbb6 100755
--- a/morph
+++ b/morph
@@ -356,6 +356,9 @@ class Morph(cliapp.Application):
tempdir.remove()
+ def cmd_init(self, args):
+ '''Initialize a mine.'''
+
def msg(self, msg):
'''Show a message to the user about what is going on.'''
logging.debug(msg)
diff --git a/tests.branching/init-cwd.script b/tests.branching/init-cwd.script
new file mode 100755
index 00000000..53bb4599
--- /dev/null
+++ b/tests.branching/init-cwd.script
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Copyright (C) 2012 Codethink Limited
+#
+# 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; version 2 of the License.
+#
+# 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+set -eu
+
+# Test that "morph init" works for the current working directory.
+
+cd "$DATADIR"
+"$SRCDIR/scripts/test-morph" init .
+"$SRCDIR/scripts/list-tree" "$DATADIR"
+
diff --git a/tests.branching/init-default.script b/tests.branching/init-default.script
new file mode 100755
index 00000000..4e7a3420
--- /dev/null
+++ b/tests.branching/init-default.script
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Copyright (C) 2012 Codethink Limited
+#
+# 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; version 2 of the License.
+#
+# 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+set -eu
+
+# Test that "morph init" works without an explicit argument.
+
+cd "$DATADIR"
+"$SRCDIR/scripts/test-morph" init
+"$SRCDIR/scripts/list-tree" "$DATADIR"
diff --git a/tests.branching/init-existing.script b/tests.branching/init-existing.script
new file mode 100755
index 00000000..1f778ffd
--- /dev/null
+++ b/tests.branching/init-existing.script
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Copyright (C) 2012 Codethink Limited
+#
+# 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; version 2 of the License.
+#
+# 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+set -eu
+
+# Test that "morph init" works when given the name of an existing,
+# empty directory.
+
+"$SRCDIR/scripts/test-morph" init "$DATADIR"
+"$SRCDIR/scripts/list-tree" "$DATADIR"
diff --git a/tests.branching/init-newdir.exit b/tests.branching/init-newdir.exit
new file mode 100644
index 00000000..d00491fd
--- /dev/null
+++ b/tests.branching/init-newdir.exit
@@ -0,0 +1 @@
+1
diff --git a/tests.branching/init-newdir.script b/tests.branching/init-newdir.script
new file mode 100755
index 00000000..6c1bdcd0
--- /dev/null
+++ b/tests.branching/init-newdir.script
@@ -0,0 +1,23 @@
+#!/bin/sh
+# Copyright (C) 2012 Codethink Limited
+#
+# 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; version 2 of the License.
+#
+# 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+set -eu
+
+# Test that "morph init" gives an error when given the name of a
+# directory that does not exist yet.
+
+"$SRCDIR/scripts/test-morph" init "$DATADIR/foo"
diff --git a/tests.branching/init-nonempty.exit b/tests.branching/init-nonempty.exit
new file mode 100644
index 00000000..d00491fd
--- /dev/null
+++ b/tests.branching/init-nonempty.exit
@@ -0,0 +1 @@
+1
diff --git a/tests.branching/init-nonempty.script b/tests.branching/init-nonempty.script
new file mode 100755
index 00000000..8e18bb2f
--- /dev/null
+++ b/tests.branching/init-nonempty.script
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Copyright (C) 2012 Codethink Limited
+#
+# 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; version 2 of the License.
+#
+# 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+set -eu
+
+# Test that "morph init" fails when given the name of an existing,
+# non-empty directory.
+
+touch "$DATADIR/foo"
+"$SRCDIR/scripts/test-morph" init "$DATADIR"
diff --git a/tests.branching/teardown b/tests.branching/teardown
new file mode 100755
index 00000000..94928416
--- /dev/null
+++ b/tests.branching/teardown
@@ -0,0 +1,22 @@
+#!/bin/sh
+# Copyright (C) 2012 Codethink Limited
+#
+# 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; version 2 of the License.
+#
+# 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+# Clean up $DATADIR.
+
+set -eu
+
+find "$DATADIR" -mindepth 1 -delete