From 8d9a939630bc677c2d2e7c4202a400f9bc0ab3ad Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Tue, 29 Jan 2013 11:58:13 +0000 Subject: Separate out build tests from general Morph tests --- tests.build/ambiguous-refs.script | 32 +++++ tests.build/build-chunk-failures-dump-log.exit | 1 + tests.build/build-chunk-failures-dump-log.script | 42 +++++++ tests.build/build-chunk-failures-dump-log.stdout | 8 ++ tests.build/build-chunk-writes-log.script | 37 ++++++ tests.build/build-chunk.script | 30 +++++ tests.build/build-chunk.stdout | 8 ++ tests.build/build-stratum-with-submodules.script | 75 ++++++++++++ tests.build/build-stratum-with-submodules.stdout | 4 + tests.build/build-stratum.script | 29 +++++ tests.build/build-stratum.stdout | 7 ++ ...ld-system-autotools-fails-if-autogen-fails.exit | 1 + ...-system-autotools-fails-if-autogen-fails.script | 39 ++++++ tests.build/build-system-autotools.script | 57 +++++++++ tests.build/build-system-autotools.stdout | 8 ++ tests.build/build-system-cpan.script | 65 ++++++++++ tests.build/build-system-cpan.stdout | 2 + tests.build/build-system-python-distutils.script | 67 +++++++++++ tests.build/build-system-python-distutils.stdout | 10 ++ tests.build/missing-ref.exit | 1 + tests.build/missing-ref.script | 23 ++++ tests.build/missing-ref.stderr | 1 + tests.build/morphless-chunks.script | 71 +++++++++++ tests.build/morphless-chunks.stdout | 5 + tests.build/rebuild-cached-stratum.script | 58 +++++++++ tests.build/rebuild-cached-stratum.stdout | 8 ++ tests.build/setup | 134 +++++++++++++++++++++ tests.build/stratum-overlap-warns.script | 39 ++++++ tests.build/stratum-overlap-warns.setup | 117 ++++++++++++++++++ tests.build/stratum-overlap-writes-overlap.script | 35 ++++++ tests.build/stratum-overlap-writes-overlap.setup | 1 + tests.build/stratum-overlap-writes-overlap.stdout | 4 + tests.build/uses-tempdir.script | 28 +++++ 33 files changed, 1047 insertions(+) create mode 100755 tests.build/ambiguous-refs.script create mode 100644 tests.build/build-chunk-failures-dump-log.exit create mode 100755 tests.build/build-chunk-failures-dump-log.script create mode 100644 tests.build/build-chunk-failures-dump-log.stdout create mode 100755 tests.build/build-chunk-writes-log.script create mode 100755 tests.build/build-chunk.script create mode 100644 tests.build/build-chunk.stdout create mode 100755 tests.build/build-stratum-with-submodules.script create mode 100644 tests.build/build-stratum-with-submodules.stdout create mode 100755 tests.build/build-stratum.script create mode 100644 tests.build/build-stratum.stdout create mode 100644 tests.build/build-system-autotools-fails-if-autogen-fails.exit create mode 100755 tests.build/build-system-autotools-fails-if-autogen-fails.script create mode 100755 tests.build/build-system-autotools.script create mode 100644 tests.build/build-system-autotools.stdout create mode 100755 tests.build/build-system-cpan.script create mode 100644 tests.build/build-system-cpan.stdout create mode 100755 tests.build/build-system-python-distutils.script create mode 100644 tests.build/build-system-python-distutils.stdout create mode 100644 tests.build/missing-ref.exit create mode 100755 tests.build/missing-ref.script create mode 100644 tests.build/missing-ref.stderr create mode 100755 tests.build/morphless-chunks.script create mode 100644 tests.build/morphless-chunks.stdout create mode 100755 tests.build/rebuild-cached-stratum.script create mode 100644 tests.build/rebuild-cached-stratum.stdout create mode 100755 tests.build/setup create mode 100755 tests.build/stratum-overlap-warns.script create mode 100755 tests.build/stratum-overlap-warns.setup create mode 100755 tests.build/stratum-overlap-writes-overlap.script create mode 120000 tests.build/stratum-overlap-writes-overlap.setup create mode 100644 tests.build/stratum-overlap-writes-overlap.stdout create mode 100755 tests.build/uses-tempdir.script (limited to 'tests.build') diff --git a/tests.build/ambiguous-refs.script b/tests.build/ambiguous-refs.script new file mode 100755 index 00000000..fbfbdfd7 --- /dev/null +++ b/tests.build/ambiguous-refs.script @@ -0,0 +1,32 @@ +#!/bin/sh +# +# Copyright (C) 2011-2013 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. + + +## Guard against a bug that occurs if 'git show-ref' is used to resolve refs +## instead of 'git rev-parse --verify': show-ref returns a list of partial +## matches sorted alphabetically, so any code using it may resolve refs + +set -eu + +# Create a ref that will show up in 'git show-ref' before the real master ref +cd "$DATADIR/morphs-repo" +git checkout -q -b alpha/master +git rm -q hello-stratum.morph +git commit -q -m "This ref will not build correctly" + +"$SRCDIR/scripts/test-morph" build-morphology \ + test:morphs-repo master hello-stratum diff --git a/tests.build/build-chunk-failures-dump-log.exit b/tests.build/build-chunk-failures-dump-log.exit new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/tests.build/build-chunk-failures-dump-log.exit @@ -0,0 +1 @@ +1 diff --git a/tests.build/build-chunk-failures-dump-log.script b/tests.build/build-chunk-failures-dump-log.script new file mode 100755 index 00000000..b54c2c1e --- /dev/null +++ b/tests.build/build-chunk-failures-dump-log.script @@ -0,0 +1,42 @@ +#!/bin/bash +# +# Copyright (C) 2011-2013 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. + + +## Test building a chunk that fails. + +set -eu + +chunkrepo="$DATADIR/chunk-repo" +cd "$chunkrepo" +git checkout --quiet master +cat <false.morph +{ + "name": "false", + "kind": "chunk", + "build-system": "dummy", + "build-commands": [ + "echo The next command will fail", + "false" + ] +} +EOF +git add false.morph +git commit --quiet -m "Make a morphology that fails." + +"$SRCDIR/scripts/test-morph" build-morphology \ + test:chunk-repo master false \ + 2>/dev/null diff --git a/tests.build/build-chunk-failures-dump-log.stdout b/tests.build/build-chunk-failures-dump-log.stdout new file mode 100644 index 00000000..7a13c12a --- /dev/null +++ b/tests.build/build-chunk-failures-dump-log.stdout @@ -0,0 +1,8 @@ +build failed +# configure +# # echo dummy configure +dummy configure +# build +# # echo The next command will fail +The next command will fail +# # false diff --git a/tests.build/build-chunk-writes-log.script b/tests.build/build-chunk-writes-log.script new file mode 100755 index 00000000..0e7aac88 --- /dev/null +++ b/tests.build/build-chunk-writes-log.script @@ -0,0 +1,37 @@ +#!/bin/sh +# +# Copyright (C) 2011-2013 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. + + +## Test building a chunk - build log should be saved. + +set -eu + +"$SRCDIR/scripts/test-morph" build-morphology test:chunk-repo farrokh hello + +SOURCES="$DATADIR/cached-sources" +find "$DATADIR/cache/artifacts" -name '*.chunk.*' | + sed 's|\.chunk\..*||' | sort -u >"$SOURCES" + +found=false +# list of sources in cache is not piped because while loop changes variable +while read source; do + [ -e "$source".build-log ] || continue + found=true + break +done <"$SOURCES" +"$found" + diff --git a/tests.build/build-chunk.script b/tests.build/build-chunk.script new file mode 100755 index 00000000..4232d3f6 --- /dev/null +++ b/tests.build/build-chunk.script @@ -0,0 +1,30 @@ +#!/bin/sh +# +# Copyright (C) 2011-2013 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. + + +## Test building a chunk. + +set -eu + +"$SRCDIR/scripts/test-morph" build-morphology test:chunk-repo farrokh hello + +for chunk in "$DATADIR/cache/artifacts/"*.chunk.* +do + echo "$chunk:" | sed 's/[^.]*//' + tar -tf "$chunk" | LC_ALL=C sort | sed '/^\.\/./s:^\./::' + echo +done diff --git a/tests.build/build-chunk.stdout b/tests.build/build-chunk.stdout new file mode 100644 index 00000000..8077cac2 --- /dev/null +++ b/tests.build/build-chunk.stdout @@ -0,0 +1,8 @@ +.chunk.hello: +./ +baserock/ +baserock/hello.meta +bin/ +bin/hello +etc/ + diff --git a/tests.build/build-stratum-with-submodules.script b/tests.build/build-stratum-with-submodules.script new file mode 100755 index 00000000..987fbadf --- /dev/null +++ b/tests.build/build-stratum-with-submodules.script @@ -0,0 +1,75 @@ +#!/bin/sh +# +# Copyright (C) 2011-2013 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. + + +## Test build a stratum that uses a chunk which needs a submodule. + +set -eu + +# tests/setup creates a chunk-repo. We now create a new chunk, which +# uses chunk-repo as a submodule. + +parent="$DATADIR/parent-repo" +mkdir "$parent" +cat < "$parent/parent.morph" +{ + "name": "parent", + "kind": "chunk", + "build-system": "manual", + "build-commands": [ + "test -f le-sub/README" + ] +} +EOF + +"$SRCDIR/scripts/run-git-in" "$parent" init --quiet +"$SRCDIR/scripts/run-git-in" "$parent" add . +"$SRCDIR/scripts/run-git-in" "$parent" \ + submodule --quiet add -b farrokh "$DATADIR/chunk-repo" le-sub > /dev/null +"$SRCDIR/scripts/run-git-in" "$parent" commit --quiet -m initial + + +# Modify the stratum to refer to the parent, not the submodule. + +morphs="$DATADIR/morphs-repo" +cat < "$morphs/submod-stratum.morph" +{ + "name": "submod-stratum", + "kind": "stratum", + "chunks": [ + { + "name": "parent", + "repo": "test:parent-repo", + "ref": "master", + "build-depends": [] + } + ] +} +EOF +"$SRCDIR/scripts/run-git-in" "$morphs" add submod-stratum.morph +"$SRCDIR/scripts/run-git-in" "$morphs" commit --quiet -m 'foo' + + +# No build and verify we got a stratum. + +"$SRCDIR/scripts/test-morph" build-morphology \ + test:morphs-repo master submod-stratum +"$SRCDIR/scripts/assemble-stratum" --cachedir "$DATADIR/cache" \ + "$DATADIR/cache/artifacts/"*submod-stratum \ + "$DATADIR/stratum.tar" submod-stratum +tar -tf "$DATADIR/stratum.tar" | LC_ALL=C sort | sed '/^\.\/./s:^\./::' + diff --git a/tests.build/build-stratum-with-submodules.stdout b/tests.build/build-stratum-with-submodules.stdout new file mode 100644 index 00000000..a5f677f3 --- /dev/null +++ b/tests.build/build-stratum-with-submodules.stdout @@ -0,0 +1,4 @@ +./ +baserock/ +baserock/parent.meta +baserock/submod-stratum.meta diff --git a/tests.build/build-stratum.script b/tests.build/build-stratum.script new file mode 100755 index 00000000..4392036d --- /dev/null +++ b/tests.build/build-stratum.script @@ -0,0 +1,29 @@ +#!/bin/sh +# +# Copyright (C) 2011-2013 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. + + +## Test build a simple stratum. + +set -eu + +"$SRCDIR/scripts/test-morph" build-morphology \ + test:morphs-repo master hello-stratum +"$SRCDIR/scripts/assemble-stratum" --cachedir "$DATADIR/cache" \ + "$DATADIR/cache/artifacts/"*.hello-stratum \ + "$DATADIR/stratum.tar" hello-stratum +tar -tf "$DATADIR/stratum.tar" | LC_ALL=C sort | sed '/^\.\/./s:^\./::' + diff --git a/tests.build/build-stratum.stdout b/tests.build/build-stratum.stdout new file mode 100644 index 00000000..4f422ea4 --- /dev/null +++ b/tests.build/build-stratum.stdout @@ -0,0 +1,7 @@ +./ +baserock/ +baserock/hello-stratum.meta +baserock/hello.meta +bin/ +bin/hello +etc/ diff --git a/tests.build/build-system-autotools-fails-if-autogen-fails.exit b/tests.build/build-system-autotools-fails-if-autogen-fails.exit new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/tests.build/build-system-autotools-fails-if-autogen-fails.exit @@ -0,0 +1 @@ +1 diff --git a/tests.build/build-system-autotools-fails-if-autogen-fails.script b/tests.build/build-system-autotools-fails-if-autogen-fails.script new file mode 100755 index 00000000..ddd3e4cc --- /dev/null +++ b/tests.build/build-system-autotools-fails-if-autogen-fails.script @@ -0,0 +1,39 @@ +#!/bin/sh +# +# Copyright (C) 2012-2013 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. + + +## Test that the autotools build system fails if it runs autogen.sh and that +## fails. + +set -eu + +x="$DATADIR/autogen-chunk" +mkdir "$x" +cat < "$x/autogen.sh" +#!/bin/sh +echo "in failing autogen.sh" +exit 1 +EOF +chmod a+x "$x/autogen.sh" +"$SRCDIR/scripts/run-git-in" "$x" init --quiet +"$SRCDIR/scripts/run-git-in" "$x" add . +"$SRCDIR/scripts/run-git-in" "$x" commit --quiet -m initial + +"$SRCDIR/scripts/test-morph" build-morphology \ + test:autogen-chunk master detected \ + >/dev/null 2> /dev/null + diff --git a/tests.build/build-system-autotools.script b/tests.build/build-system-autotools.script new file mode 100755 index 00000000..35fcd779 --- /dev/null +++ b/tests.build/build-system-autotools.script @@ -0,0 +1,57 @@ +#!/bin/sh +# +# Copyright (C) 2011-2013 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. + + +## Convert the hello-chunk project to something autotools-like, then +## build it. + +set -eu + +chunkrepo="$DATADIR/chunk-repo" +cd "$chunkrepo" + +git checkout --quiet farrokh + +cat <<'EOF' >Makefile +all: hello + +install: all + install -d "$(DESTDIR)/etc" + install -d "$(DESTDIR)/bin" + install hello "$(DESTDIR)/bin/hello" +EOF +git add Makefile + +cat < hello.morph +{ + "name": "hello", + "kind": "chunk", + "build-system": "autotools", + "configure-commands": [] +} +EOF +git add hello.morph +git commit --quiet -m "Convert hello to an autotools project" + +"$SRCDIR/scripts/test-morph" build-morphology test:chunk-repo farrokh hello + +for chunk in "$DATADIR/cache/artifacts/"*.chunk.* +do + echo "$chunk:" | sed 's/[^.]*//' + tar -tf "$chunk" | LC_ALL=C sort | sed '/^\.\/./s:^\./::' + echo +done diff --git a/tests.build/build-system-autotools.stdout b/tests.build/build-system-autotools.stdout new file mode 100644 index 00000000..8077cac2 --- /dev/null +++ b/tests.build/build-system-autotools.stdout @@ -0,0 +1,8 @@ +.chunk.hello: +./ +baserock/ +baserock/hello.meta +bin/ +bin/hello +etc/ + diff --git a/tests.build/build-system-cpan.script b/tests.build/build-system-cpan.script new file mode 100755 index 00000000..6e5a02e4 --- /dev/null +++ b/tests.build/build-system-cpan.script @@ -0,0 +1,65 @@ +#!/bin/sh +# +# Copyright (C) 2011-2013 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. + + +## Convert the hello-chunk project to perl with CPAN and build. + +set -eu + +chunkrepo="$DATADIR/chunk-repo" +cd "$chunkrepo" + +git checkout --quiet farrokh + +git rm --quiet hello.c + +cat <hello +#!/usr/bin/perl +print "hello, world\n" +EOF +git add hello + +cat <Makefile.PL +use strict; +use warnings; +use ExtUtils::MakeMaker; +WriteMakefile( + EXE_FILES => ['hello'], +) +EOF +git add Makefile.PL + +cat <hello.morph +{ + "name": "hello", + "kind": "chunk", + "build-system": "cpan" +} +EOF +git add hello.morph + +git commit --quiet -m 'convert hello into a perl cpan project' + +"$SRCDIR/scripts/test-morph" build-morphology --prefix=/ \ + test:chunk-repo farrokh hello + +for chunk in "$DATADIR/cache/artifacts/"*.chunk.* +do + echo "$chunk:" | sed 's/[^.]*//' + tar -tf "$chunk" | LC_ALL=C sort | + sed -e '/^\.\/./s:^\./::' | grep -F "bin/hello" +done diff --git a/tests.build/build-system-cpan.stdout b/tests.build/build-system-cpan.stdout new file mode 100644 index 00000000..5cbe4c73 --- /dev/null +++ b/tests.build/build-system-cpan.stdout @@ -0,0 +1,2 @@ +.chunk.hello: +bin/hello diff --git a/tests.build/build-system-python-distutils.script b/tests.build/build-system-python-distutils.script new file mode 100755 index 00000000..2a1b5f70 --- /dev/null +++ b/tests.build/build-system-python-distutils.script @@ -0,0 +1,67 @@ +#!/bin/sh +# +# Copyright (C) 2011-2013 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. + + +## Convert the hello-chunk project to python with distutils and build. + +set -eu + +chunkrepo="$DATADIR/chunk-repo" +cd "$chunkrepo" + +git checkout --quiet farrokh + +git rm --quiet hello.c +cat <hello +#!/usr/bin/python +print "hello, world" +EOF +git add hello + +cat <setup.py +#!/usr/bin/python +from distutils.core import setup +setup(name='hello', + scripts=['hello']) +EOF +git add setup.py + +cat <hello.morph +{ + "name": "hello", + "kind": "chunk", + "build-system": "python-distutils" +} +EOF +git add hello.morph + +git commit --quiet -m 'convert hello into a python project' + +"$SRCDIR/scripts/test-morph" build-morphology --prefix= \ + test:chunk-repo farrokh hello + +for chunk in "$DATADIR/cache/artifacts/"*.chunk.* +do + echo "$chunk:" | sed 's/[^.]*//' + tar -tf "$chunk" | LC_ALL=C sort | sed '/^\.\/./s:^\./::' + echo +done | +sed -e 's:^local/::' \ + -e 's:lib/python2.[6-9]/:lib/python2.x/:' \ + -e 's:/hello-0\.0\.0[^/]*\.egg-info$:/hello.egg-info/:' \ + -e 's:[^/]*-packages:packages:' \ + -e '/^$/d' diff --git a/tests.build/build-system-python-distutils.stdout b/tests.build/build-system-python-distutils.stdout new file mode 100644 index 00000000..4d4abdbb --- /dev/null +++ b/tests.build/build-system-python-distutils.stdout @@ -0,0 +1,10 @@ +.chunk.hello: +./ +baserock/ +baserock/hello.meta +bin/ +bin/hello +lib/ +lib/python2.x/ +lib/python2.x/packages/ +lib/python2.x/packages/hello.egg-info/ diff --git a/tests.build/missing-ref.exit b/tests.build/missing-ref.exit new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/tests.build/missing-ref.exit @@ -0,0 +1 @@ +1 diff --git a/tests.build/missing-ref.script b/tests.build/missing-ref.script new file mode 100755 index 00000000..db654e61 --- /dev/null +++ b/tests.build/missing-ref.script @@ -0,0 +1,23 @@ +#!/bin/sh +# +# Copyright (C) 2011-2013 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. + + +## Test building with a bad reference. + +"$SRCDIR/scripts/test-morph" build-morphology \ + test:chunk-repo non-existent-branch hello + diff --git a/tests.build/missing-ref.stderr b/tests.build/missing-ref.stderr new file mode 100644 index 00000000..d2b5d254 --- /dev/null +++ b/tests.build/missing-ref.stderr @@ -0,0 +1 @@ +ERROR: Ref non-existent-branch is an invalid reference for repo file://TMP/chunk-repo diff --git a/tests.build/morphless-chunks.script b/tests.build/morphless-chunks.script new file mode 100755 index 00000000..b5b8f37e --- /dev/null +++ b/tests.build/morphless-chunks.script @@ -0,0 +1,71 @@ +#!/bin/sh +# +# Copyright (C) 2012-2013 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. + + +## Try to build a morphless chunk. + +set -eu + +# Create an auto-detectable chunk. + +mkdir "$DATADIR/morphless" +cd "$DATADIR/morphless" + +touch configure +chmod +x configure +# FIXME: If we leave the file empty, busybox sh on ARMv7 fails to execute it. +echo '#!/bin/sh' > configure + +cat << EOF > Makefile +all install: +EOF + +git init --quiet +git add * +git commit --quiet -m initial + + +# Create a stratum that refers to the morphless chunk. + +mkdir "$DATADIR/stratum" +cd "$DATADIR/stratum" +cat << EOF > alfred.morph +{ + "name": "alfred", + "kind": "stratum", + "chunks": [ + { + "name": "morphless", + "repo": "test:morphless", + "ref": "master", + "build-depends": [] + } + ] +} +EOF +git init --quiet +git add alfred.morph +git commit --quiet -m initial + +"$SRCDIR/scripts/test-morph" build-morphology test:stratum master alfred + +for chunk in "$DATADIR/cache/artifacts/"*.chunk.* +do + echo "$chunk:" | sed 's/[^.]*//' + tar -tf "$chunk" | LC_ALL=C sort | sed '/^\.\/./s:^\./::' + echo +done diff --git a/tests.build/morphless-chunks.stdout b/tests.build/morphless-chunks.stdout new file mode 100644 index 00000000..8e17b29a --- /dev/null +++ b/tests.build/morphless-chunks.stdout @@ -0,0 +1,5 @@ +.chunk.morphless: +./ +baserock/ +baserock/morphless.meta + diff --git a/tests.build/rebuild-cached-stratum.script b/tests.build/rebuild-cached-stratum.script new file mode 100755 index 00000000..06003a26 --- /dev/null +++ b/tests.build/rebuild-cached-stratum.script @@ -0,0 +1,58 @@ +#!/bin/sh +# +# Copyright (C) 2011-2013 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. + + +## Does a cached stratum get rebuilt if its chunk changes? +## This tests a bug that is currently in morph, where the stratum does +## not get rebuilt in that case. Later on, the test will guard against +## regressions. + +set -eu + +cache="$DATADIR/cache/artifacts" + +# Make a branch in the chunk repo where we can make our own modifications. +(cd "$DATADIR/chunk-repo" && + git checkout --quiet farrokh && + git checkout --quiet -b rebuild-cached-stratum) + +# Make a branch in the morphs repo and modify the stratum to refer to +# the new chunk branch. +(cd "$DATADIR/morphs-repo" && + git checkout --quiet -b rebuild-cached-stratum && + sed -i 's/farrokh/rebuild-cached-stratum/' hello-stratum.morph && + git commit --quiet -m "rebuild-cached-stratum" -a) + +# Build the first time. +"$SRCDIR/scripts/test-morph" build-morphology \ + test:morphs-repo rebuild-cached-stratum hello-stratum +echo "first build:" +(cd "$cache" && ls *.chunk.* *hello-stratum | sed 's/^[^.]*\./ /' | + LC_ALL=C sort) + +# Change the chunk. +(cd "$DATADIR/chunk-repo" && + echo >> hello.c && + git commit --quiet -am change) + +# Rebuild. +"$SRCDIR/scripts/test-morph" build-morphology \ + test:morphs-repo rebuild-cached-stratum hello-stratum +echo "second build:" +(cd "$cache" && ls *.chunk.* *hello-stratum | sed 's/^[^.]*\./ /' | + LC_ALL=C sort) + diff --git a/tests.build/rebuild-cached-stratum.stdout b/tests.build/rebuild-cached-stratum.stdout new file mode 100644 index 00000000..eee106f5 --- /dev/null +++ b/tests.build/rebuild-cached-stratum.stdout @@ -0,0 +1,8 @@ +first build: + chunk.hello + stratum.hello-stratum +second build: + chunk.hello + chunk.hello + stratum.hello-stratum + stratum.hello-stratum diff --git a/tests.build/setup b/tests.build/setup new file mode 100755 index 00000000..50fd5bd4 --- /dev/null +++ b/tests.build/setup @@ -0,0 +1,134 @@ +#!/bin/sh +# +# Create git repositories for tests. The chunk repository will contain a +# simple "hello, world" C program, and two branches ("master", "farrokh"), +# with the master branch containing just a README. The two branches are there +# so that we can test building a branch that hasn't been checked out. +# The branches are different so that we know that if the wrong branch +# is uses, the build will fail. +# +# The stratum repository contains a single branch, "master", with a +# stratum and a system morphology that include the chunk above. +# +# Copyright (C) 2011-2013 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 + +# The $DATADIR should be empty at the beginnig of each test. +find "$DATADIR" -mindepth 1 -delete + +# Create chunk repository. + +chunkrepo="$DATADIR/chunk-repo" +mkdir "$chunkrepo" +cd "$chunkrepo" +git init --quiet + +cat < README +This is a sample README. +EOF +git add README +git commit --quiet -m "add README" + +git checkout --quiet -b farrokh + +cat < hello.c +#include +int main(void) +{ + puts("hello, world"); + return 0; +} +EOF +git add hello.c + +cat < hello.morph +{ + "name": "hello", + "kind": "chunk", + "build-system": "dummy", + "build-commands": [ + "gcc -o hello hello.c" + ], + "install-commands": [ + "install -d \\"\$DESTDIR\\"/etc", + "install -d \\"\$DESTDIR\\"/bin", + "install hello \\"\$DESTDIR\\"/bin/hello" + ] +} +EOF +git add hello.morph + +git commit --quiet -m "add a hello world program and morph" + +git checkout --quiet master + + + +# Create morph repository. + +morphsrepo="$DATADIR/morphs-repo" +mkdir "$morphsrepo" +cd "$morphsrepo" +git init --quiet + +cat < hello-stratum.morph +{ + "name": "hello-stratum", + "kind": "stratum", + "chunks": [ + { + "name": "hello", + "repo": "test:chunk-repo", + "ref": "farrokh", + "build-depends": [] + } + ] +} +EOF +git add hello-stratum.morph + +cat < hello-system.morph +{ + "name": "hello-system", + "kind": "system", + "system-kind": "syslinux-disk", + "disk-size": "1G", + "strata": [ + { + "morph": "hello-stratum", + "repo": "test:morphs-repo", + "ref": "master" + } + ] +} +EOF +git add hello-system.morph + +git commit --quiet -m "add morphs" + + +# Create a morph configuration file. +cat < "$DATADIR/morph.conf" +[config] +repo-alias = test=file://$DATADIR/%s#file://$DATADIR/%s +cachedir = $DATADIR/cache +log = $DATADIR/morph.log +no-distcc = true +quiet = true +EOF + diff --git a/tests.build/stratum-overlap-warns.script b/tests.build/stratum-overlap-warns.script new file mode 100755 index 00000000..86071954 --- /dev/null +++ b/tests.build/stratum-overlap-warns.script @@ -0,0 +1,39 @@ +#!/bin/sh +# +# Copyright (C) 2011-2013 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. + + +## If a stratum has multiple chunks that have the same files in them, +## then this should be noted. + +set -eu + +log="$DATADIR/morph.log" +warnings="$DATADIR/warnings" +cache="$DATADIR/cache/artifacts" + +warning_mentions(){ + grep -F "$1" <"$warnings" >/dev/null 2>/dev/null +} + +"$SRCDIR/scripts/test-morph" build-morphology --log=$log \ + test:morphs-repo overlap overlap-stratum > /dev/null +grep WARNING "$log" >"$warnings" +for str in overlap-stratum \ + overlap-foo-baz overlap-foobar bin/bar \ + overlap-fooqux bin/foo; do + warning_mentions 'overlap-stratum' || exit $? +done diff --git a/tests.build/stratum-overlap-warns.setup b/tests.build/stratum-overlap-warns.setup new file mode 100755 index 00000000..ef771794 --- /dev/null +++ b/tests.build/stratum-overlap-warns.setup @@ -0,0 +1,117 @@ +#!/bin/sh +# +# If a stratum has multiple chunks that have the same files in them, +# then this should be notified +# +# Copyright (C) 2011-2013 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 + +chunkrepo="$DATADIR/chunk-repo" +morphsrepo="$DATADIR/morphs-repo" + +cd "$morphsrepo" +git checkout --quiet -b overlap master +cat <overlap-stratum.morph +{ + "name": "overlap-stratum", + "kind": "stratum", + "chunks": [ + { + "name": "dirs", + "repo": "test:chunk-repo", + "ref": "overlap", + "build-depends": [] + }, + { + "name": "overlap-foobar", + "repo": "test:chunk-repo", + "ref": "overlap", + "build-depends": ["dirs"] + }, + { + "name": "overlap-fooqux", + "repo": "test:chunk-repo", + "ref": "overlap", + "build-depends": ["overlap-foobar"] + }, + { + "name": "overlap-foo-baz", + "repo": "test:chunk-repo", + "ref": "overlap", + "build-depends": ["overlap-fooqux"] + } + ] +} +EOF +git add overlap-stratum.morph +git commit --quiet -m "add overlapping stratum" + +cd "$chunkrepo" +git checkout --quiet -b overlap master + +cat <dirs.morph +{ + "name": "dirs", + "kind": "chunk", + "install-commands": [ + "mkdir -p \$DESTDIR/bin", + "ln -s / \$DESTDIR/usr" + ] +} +EOF +git add dirs.morph + +cat <overlap-foo-baz.morph +{ + "name": "overlap-foo-baz", + "kind": "chunk", + "install-commands": [ + "mkdir -p \$DESTDIR/bin", + "for f in foo bar baz; do echo echo \$f >\$DESTDIR/bin/\$f; done" + ] +} +EOF +git add overlap-foo-baz.morph + +cat <overlap-foobar.morph +{ + "name": "overlap-foobar", + "kind": "chunk", + "install-commands": [ + "mkdir -p \$DESTDIR/usr/bin \$DESTDIR/bin", + "echo echo foobar >\$DESTDIR/usr/bin/foobar", + "ln -s /usr/bin/foobar \$DESTDIR/bin/foo", + "ln -s /usr/bin/foobar \$DESTDIR/bin/bar" + ] +} +EOF +git add overlap-foobar.morph + +cat <overlap-fooqux.morph +{ + "name": "overlap-fooqux", + "kind": "chunk", + "install-commands": [ + "mkdir -p \$DESTDIR/usr/bin \$DESTDIR/bin", + "for f in qux fooqux; do echo echo \$f >\$DESTDIR/usr/bin/\$f; done", + "ln -s /usr/bin/fooqux \$DESTDIR/bin/foo" + ] +} +EOF +git add overlap-fooqux.morph + +git commit --quiet -m 'Add overlapping chunks' diff --git a/tests.build/stratum-overlap-writes-overlap.script b/tests.build/stratum-overlap-writes-overlap.script new file mode 100755 index 00000000..90b65cb9 --- /dev/null +++ b/tests.build/stratum-overlap-writes-overlap.script @@ -0,0 +1,35 @@ +#!/bin/sh +# +# Copyright (C) 2011-2013 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. + + +## If a stratum has multiple chunks that have the same files in them, +## then the overlaps must be written to the cache + +set -eu + +cache="$DATADIR/cache/artifacts" + + +"$SRCDIR/scripts/test-morph" build-morphology \ + test:morphs-repo overlap overlap-stratum > /dev/null +"$SRCDIR/scripts/list-overlaps" groups \ + "$cache"/*.stratum.overlap-stratum.overlaps | +while IFS='\n' read overlaps; do + echo $overlaps + "$SRCDIR/scripts/list-overlaps" list-files \ + "$cache"/*.stratum.overlap-stratum.overlaps $overlaps +done diff --git a/tests.build/stratum-overlap-writes-overlap.setup b/tests.build/stratum-overlap-writes-overlap.setup new file mode 120000 index 00000000..255e9a74 --- /dev/null +++ b/tests.build/stratum-overlap-writes-overlap.setup @@ -0,0 +1 @@ +stratum-overlap-warns.setup \ No newline at end of file diff --git a/tests.build/stratum-overlap-writes-overlap.stdout b/tests.build/stratum-overlap-writes-overlap.stdout new file mode 100644 index 00000000..40485659 --- /dev/null +++ b/tests.build/stratum-overlap-writes-overlap.stdout @@ -0,0 +1,4 @@ +overlap-foo-baz overlap-foobar overlap-fooqux +bin/foo +overlap-foo-baz overlap-foobar +bin/bar diff --git a/tests.build/uses-tempdir.script b/tests.build/uses-tempdir.script new file mode 100755 index 00000000..a9ac40dd --- /dev/null +++ b/tests.build/uses-tempdir.script @@ -0,0 +1,28 @@ +#!/bin/sh +# +# Copyright (C) 2011-2013 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. + + +## Test that temporary directories are created in the dir specified +## by --tempdir rather than specified in the environment by TMPDIR. + +set -eu +export TMPDIR +TMPDIR="$DATADIR"/unwritable-tmp +install -m 000 -d "$TMPDIR" +mkdir "$DATADIR"/tmp +"$SRCDIR/scripts/test-morph" build-morphology --tempdir "$DATADIR"/tmp \ + test:morphs-repo master hello-stratum -- cgit v1.2.1