summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/python-check36
-rwxr-xr-xtests.as-root/build-with-external-strata.script6
-rwxr-xr-xtests.as-root/build-with-push.script6
-rwxr-xr-xtests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script7
-rwxr-xr-xtests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script7
-rwxr-xr-xtests.as-root/building-a-system-branch-works-anywhere.script6
-rwxr-xr-xtests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script4
-rwxr-xr-xtests.as-root/tarball-image-is-sensible.script4
-rwxr-xr-xtests.branching/ambiguous-refs.script9
-rwxr-xr-xtests.branching/edit-updates-stratum.script6
-rwxr-xr-xtests.branching/petrify-no-double-petrify.script7
-rwxr-xr-xtests.branching/petrify.script6
-rwxr-xr-xtests.branching/workflow-petrify.script6
-rwxr-xr-xtests.merging/basic.script5
-rwxr-xr-xtests.merging/conflict-chunks.script7
-rwxr-xr-xtests.merging/conflict-stratum-field-ordering.script7
-rwxr-xr-xtests.merging/move-chunk-repo.script6
-rwxr-xr-xtests.merging/rename-chunk.script5
-rwxr-xr-xtests.merging/rename-stratum.script6
19 files changed, 56 insertions, 90 deletions
diff --git a/scripts/python-check b/scripts/python-check
new file mode 100644
index 00000000..6b79897f
--- /dev/null
+++ b/scripts/python-check
@@ -0,0 +1,36 @@
+#!/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.
+
+# When sourced by scripts, if the python version is too old
+# fake the output and exit.
+
+if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
+then
+ outpath="$(dirname "$0")/$(basename "$0" .script).stdout"
+ errpath="$(dirname "$0")/$(basename "$0" .script).stderr"
+ exitpath="$(dirname "$0")/$(basename "$0" .script).exit"
+ if [ -r "$outpath" ]; then
+ cat "$outpath"
+ fi
+ if [ -r "$errpath" ]; then
+ cat "$errpath" >&2
+ fi
+ if [ -r "$exitpath" ]; then
+ exit "$(cat "$exitpath")"
+ else
+ exit 0
+ fi
+fi
diff --git a/tests.as-root/build-with-external-strata.script b/tests.as-root/build-with-external-strata.script
index affb28f5..6bd14c10 100755
--- a/tests.as-root/build-with-external-strata.script
+++ b/tests.as-root/build-with-external-strata.script
@@ -19,11 +19,7 @@
set -eu
# Disable test on versions of Python before 2.7.
-if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
-then
- cat "$SRCDIR/tests.as-root/build-with-external-strata.stdout"
- exit 0
-fi
+. "$SRCDIR/scripts/python-check"
. "$SRCDIR/scripts/setup-3rd-party-strata"
diff --git a/tests.as-root/build-with-push.script b/tests.as-root/build-with-push.script
index 1c3fb3fd..554edaaa 100755
--- a/tests.as-root/build-with-push.script
+++ b/tests.as-root/build-with-push.script
@@ -20,11 +20,7 @@
set -eu
# Disable test on versions of Python before 2.7.
-if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
-then
- cat "$SRCDIR/tests.as-root/build-with-push.stdout"
- exit 0
-fi
+source "$SRCDIR/scripts/python-check"
source "$SRCDIR/tests.as-root/setup-build"
diff --git a/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script b/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script
index 9ccc3dee..bf8ecf71 100755
--- a/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script
+++ b/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script
@@ -20,12 +20,7 @@
set -eu
# Disable test on versions of Python before 2.7.
-if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
-then
- name=building-a-system-branch-multiple-times-doesnt-generate-new-artifacts
- cat "$SRCDIR/tests.as-root/$name.stdout"
- exit 0
-fi
+source "$SRCDIR/scripts/python-check"
source "$SRCDIR/tests.as-root/setup-build"
diff --git a/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script b/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script
index 642093dc..65c25c73 100755
--- a/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script
+++ b/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script
@@ -20,12 +20,7 @@
set -eu
# Disable test on versions of Python before 2.7.
-if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
-then
- name="building-a-system-branch-picks-up-uncommitted-changes"
- cat "$SRCDIR/tests.as-root/$name.stdout"
- exit 0
-fi
+source "$SRCDIR/scripts/python-check"
source "$SRCDIR/tests.as-root/setup-build"
diff --git a/tests.as-root/building-a-system-branch-works-anywhere.script b/tests.as-root/building-a-system-branch-works-anywhere.script
index 2bba83dc..e79fa167 100755
--- a/tests.as-root/building-a-system-branch-works-anywhere.script
+++ b/tests.as-root/building-a-system-branch-works-anywhere.script
@@ -20,11 +20,7 @@
set -eu
# Disable test on versions of Python before 2.7.
-if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
-then
- cat "$SRCDIR/tests.as-root/building-a-system-branch-works-anywhere.stdout"
- exit 0
-fi
+source "$SRCDIR/scripts/python-check"
source "$SRCDIR/tests.as-root/setup-build"
diff --git a/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script b/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script
index fea92d65..95e7a504 100755
--- a/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script
+++ b/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script
@@ -20,9 +20,7 @@
set -eu
-case $(python --version 2>&1) in
- "Python 2.6"*) exit 0 ;;
-esac
+. "$SRCDIR/scripts/python-check"
cache="$DATADIR/cache/artifacts"
kernelrepo="$DATADIR/kernel-repo"
diff --git a/tests.as-root/tarball-image-is-sensible.script b/tests.as-root/tarball-image-is-sensible.script
index 412d27e0..035a13c7 100755
--- a/tests.as-root/tarball-image-is-sensible.script
+++ b/tests.as-root/tarball-image-is-sensible.script
@@ -20,9 +20,7 @@
set -eu
-case $(python --version 2>&1) in
- "Python 2.6"*) exit 0 ;;
-esac
+. "$SRCDIR/scripts/python-check"
. "$SRCDIR/scripts/fix-committer-info"
diff --git a/tests.branching/ambiguous-refs.script b/tests.branching/ambiguous-refs.script
index 9da776fd..3b2ec5e8 100755
--- a/tests.branching/ambiguous-refs.script
+++ b/tests.branching/ambiguous-refs.script
@@ -20,13 +20,10 @@
set -eu
-. "$SRCDIR/scripts/fix-committer-info"
-
# Disable test on versions of Python before 2.7.
-if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
-then
- exit 0
-fi
+. "$SRCDIR/scripts/python-check"
+
+. "$SRCDIR/scripts/fix-committer-info"
cd "$DATADIR/morphs"
git mv hello-stratum.morph goodbye-stratum.morph
diff --git a/tests.branching/edit-updates-stratum.script b/tests.branching/edit-updates-stratum.script
index d43fd360..8b6af1d1 100755
--- a/tests.branching/edit-updates-stratum.script
+++ b/tests.branching/edit-updates-stratum.script
@@ -21,11 +21,7 @@
set -eu
# Disable test on versions of Python before 2.7.
-if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
-then
- cat "$SRCDIR/tests.branching/edit-updates-stratum.stdout"
- exit 0
-fi
+. "$SRCDIR/scripts/python-check"
# Create system branch.
cd "$DATADIR/workspace"
diff --git a/tests.branching/petrify-no-double-petrify.script b/tests.branching/petrify-no-double-petrify.script
index 56326cdc..1b5289c4 100755
--- a/tests.branching/petrify-no-double-petrify.script
+++ b/tests.branching/petrify-no-double-petrify.script
@@ -22,12 +22,7 @@ set -eu
# Disable test on versions of Python before 2.7.
-if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
-then
- cat "$SRCDIR/tests.branching/petrify-no-double-petrify.stdout"
- exit 0
-fi
-
+. "$SRCDIR/scripts/python-check"
cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
diff --git a/tests.branching/petrify.script b/tests.branching/petrify.script
index a74ae6ba..0fb4a4c4 100755
--- a/tests.branching/petrify.script
+++ b/tests.branching/petrify.script
@@ -23,11 +23,7 @@ set -eu
# Disable test on versions of Python before 2.7.
-if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
-then
- cat "$SRCDIR/tests.branching/petrify.stdout"
- exit 0
-fi
+. "$SRCDIR/scripts/python-check"
. "$SRCDIR/tests.branching/setup-second-chunk"
diff --git a/tests.branching/workflow-petrify.script b/tests.branching/workflow-petrify.script
index a73e17db..35643012 100755
--- a/tests.branching/workflow-petrify.script
+++ b/tests.branching/workflow-petrify.script
@@ -22,11 +22,7 @@
set -eu
# Disable test on versions of Python before 2.7.
-if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
-then
- cat "$SRCDIR/tests.branching/workflow-petrify.stdout"
- exit 0
-fi
+. "$SRCDIR/scripts/python-check"
. "$SRCDIR/scripts/setup-3rd-party-strata"
diff --git a/tests.merging/basic.script b/tests.merging/basic.script
index 6b063a20..8eddcfdb 100755
--- a/tests.merging/basic.script
+++ b/tests.merging/basic.script
@@ -20,10 +20,7 @@
set -eu
# Disable test on versions of Python before 2.7.
-if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
-then
- exit 0
-fi
+. "$SRCDIR/scripts/python-check"
cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
diff --git a/tests.merging/conflict-chunks.script b/tests.merging/conflict-chunks.script
index a9b85989..37ee4fb8 100755
--- a/tests.merging/conflict-chunks.script
+++ b/tests.merging/conflict-chunks.script
@@ -20,12 +20,7 @@
set -eu
# Disable test on versions of Python before 2.7.
-if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
-then
- cat "$SRCDIR/tests.merging/conflict-chunks.stdout"
- cat "$SRCDIR/tests.merging/conflict-chunks.stderr" >&2
- exit 0
-fi
+. "$SRCDIR/scripts/python-check"
. "$SRCDIR/scripts/setup-3rd-party-strata"
diff --git a/tests.merging/conflict-stratum-field-ordering.script b/tests.merging/conflict-stratum-field-ordering.script
index 3c1dce1c..13ddf3fb 100755
--- a/tests.merging/conflict-stratum-field-ordering.script
+++ b/tests.merging/conflict-stratum-field-ordering.script
@@ -25,12 +25,7 @@
set -eu
# Disable test on versions of Python before 2.7.
-if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
-then
- cat "$SRCDIR/tests.branching/merge-conflict-stratum.stdout"
- cat "$SRCDIR/tests.branching/merge-conflict-stratum.stderr" >&2
- exit 1
-fi
+. "$SRCDIR/scripts/python-check"
cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
diff --git a/tests.merging/move-chunk-repo.script b/tests.merging/move-chunk-repo.script
index 1e3befbd..a203a824 100755
--- a/tests.merging/move-chunk-repo.script
+++ b/tests.merging/move-chunk-repo.script
@@ -20,11 +20,7 @@
set -eu
# Disable test on versions of Python before 2.7.
-if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
-then
- cat "$SRCDIR/tests.merging/move-chunk-repo.stderr" >&2
- exit 1
-fi
+. "$SRCDIR/scripts/python-check"
# Create system branch.
cd "$DATADIR/workspace"
diff --git a/tests.merging/rename-chunk.script b/tests.merging/rename-chunk.script
index fb76491b..a50a83bd 100755
--- a/tests.merging/rename-chunk.script
+++ b/tests.merging/rename-chunk.script
@@ -20,10 +20,7 @@
set -eu
# Disable test on versions of Python before 2.7.
-if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
-then
- exit 0
-fi
+. "$SRCDIR/scripts/python-check"
# Create system branch.
cd "$DATADIR/workspace"
diff --git a/tests.merging/rename-stratum.script b/tests.merging/rename-stratum.script
index 64fb7e15..b0e5d57e 100755
--- a/tests.merging/rename-stratum.script
+++ b/tests.merging/rename-stratum.script
@@ -20,11 +20,7 @@
set -eu
# Disable test on versions of Python before 2.7.
-if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
-then
- cat "$SRCDIR/tests.merging/rename-stratum.stderr" 1>&2
- exit 1
-fi
+. "$SRCDIR/scripts/python-check"
# Create system branch.
cd "$DATADIR/workspace"