summaryrefslogtreecommitdiff
path: root/yarns
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@gmail.com>2014-09-24 16:36:34 +0000
committerRichard Maw <richard.maw@gmail.com>2014-10-01 09:30:14 +0000
commit5ac9f90a64cdadaf4d9adb243c6be2f0f4d1764a (patch)
tree35b5792371b7abf9f6bc1bc24c41c44d342ed9d7 /yarns
parentb228561897aecea8a60908c354cee79938cf4e31 (diff)
downloadmorph-5ac9f90a64cdadaf4d9adb243c6be2f0f4d1764a.tar.gz
Modify yarns to use test-shell instead of build-mode: test
When all the tests that use build-mode: test are gone, the build mode can be removed.
Diffstat (limited to 'yarns')
-rw-r--r--yarns/branches-workspaces.yarn11
-rw-r--r--yarns/implementations.yarn301
-rw-r--r--yarns/regression.yarn6
-rw-r--r--yarns/splitting.yarn27
4 files changed, 178 insertions, 167 deletions
diff --git a/yarns/branches-workspaces.yarn b/yarns/branches-workspaces.yarn
index 200f9508..34aa97e0 100644
--- a/yarns/branches-workspaces.yarn
+++ b/yarns/branches-workspaces.yarn
@@ -202,14 +202,14 @@ is a chunk repository created in the mocked git server, for testing
purposes.
WHEN the user edits the chunk test-chunk in branch foo
- THEN in branch foo, stratum strata/test-stratum.morph refs test-chunk in foo
+ THEN in branch foo, stratum strata/core.morph refs test-chunk in foo
AND the edited chunk test:test-chunk has git branch foo
Editing a morphology should not cause it to start having repo or ref
fields when referring to strata, when it didn't before.
- AND in branch foo, system systems/test-system.morph refers to test-stratum without repo
- AND in branch foo, system systems/test-system.morph refers to test-stratum without ref
+ AND in branch foo, system systems/test-system.morph refers to core without repo
+ AND in branch foo, system systems/test-system.morph refers to core without ref
FINALLY the git server is shut down
Temporary Build Branch behaviour
@@ -398,14 +398,15 @@ Nor do we need temporary build branches for distributed builds.
IMPLEMENTS WHEN the user makes changes to test-chunk in branch (\S+)
chunkdir="$(slashify_colons "test:test-chunk")"
cd "$DATADIR/workspace/$MATCH_1/$chunkdir"
- sed -i -e 's/Hello/Goodbye/g' test-bin
+ sed -i -e 's/Hello/Goodbye/g' usr/libexec/test-bin
IMPLEMENTS THEN the changes to test-chunk in branch (\S+) are included in the temporary build branch
build_ref_prefix=baserock/builds/
chunkdir="$(slashify_colons "test:test-chunk")"
cd "$DATADIR/workspace/$MATCH_1/$chunkdir"
+ testbin=usr/libexec/test-bin
eval "$(git for-each-ref --count=1 --shell --sort=committerdate \
- --format='git cat-file -p %(refname):test-bin | diff test-bin -' \
+ --format='git cat-file -p %(refname):$testbin | diff $testbin -' \
"$build_ref_prefix")"
IMPLEMENTS WHEN the user commits changes to (\S+) in branch (\S+)
diff --git a/yarns/implementations.yarn b/yarns/implementations.yarn
index 52eee01d..e99c1817 100644
--- a/yarns/implementations.yarn
+++ b/yarns/implementations.yarn
@@ -67,72 +67,47 @@ another to hold a chunk.
# Create a directory for all the git repositories.
mkdir "$DATADIR/gits"
- # Create the chunk repository.
- mkdir "$DATADIR/gits/test-chunk"
-
- run_in "$DATADIR/gits/test-chunk" git init .
- cat > "$DATADIR/gits/test-chunk/test-bin" <<'EOF'
- #!/bin/sh
- echo Hello World
- EOF
- cat > "$DATADIR/gits/test-chunk/test.h" <<'EOF'
- int foo(void);
- EOF
- cat > "$DATADIR/gits/test-chunk/test.pc" <<'EOF'
- prefix=/usr
- includedir=${prefix}/include
- Name: test
- Cflags: -I{includedir}
+ # Create the bootstrap chunk repositories
+ mkdir "$DATADIR/gits/bootstrap-chunk"
+ cd "$DATADIR/gits/bootstrap-chunk"
+ git init .
+ git checkout -b bootstrap
+ cp "$SRCDIR/scripts/test-shell.c" sh.c
+ install /dev/stdin <<'EOF' configure
+ #!/bin/true
EOF
- run_in "$DATADIR/gits/test-chunk" git add .
- run_in "$DATADIR/gits/test-chunk" git commit --allow-empty -m Initial.
+ printf >Makefile '
+ CFLAGS = -D_GNU_SOURCE -static
- # Create a repo for the morphologies.
+ all: sh
- mkdir "$DATADIR/gits/morphs"
+ install: sh
+ \tinstall -D -m755 sh $(DESTDIR)/bin/sh'
+ git add .
+ git commit -m "Add bootstrap shell"
- arch=$(run_morph print-architecture)
- install -m644 -D /dev/stdin << EOF "$DATADIR/gits/morphs/systems/test-system.morph"
- name: test-system
- kind: system
- arch: $arch
- strata:
- - name: test-stratum
- morph: strata/test-stratum.morph
- EOF
+ git checkout --orphan master HEAD
+ # Commit a pre-built test-shell, as a compiler is too heavy to bootstrap
+ make sh
+ mkdir bin
+ mv sh bin/sh
+ git rm -f Makefile sh.c configure
+ git add bin/sh
+ git commit -m "Build bootstrap shell with bootstrap shell"
- install -m644 -D /dev/stdin << EOF "$DATADIR/gits/morphs/strata/test-stratum.morph"
- name: test-stratum
- kind: stratum
- chunks:
- - name: test-chunk
- repo: test:test-chunk
- morph: test-chunk.morph
- unpetrify-ref: master
- ref: $(run_in "$DATADIR/gits/test-chunk" git rev-parse master)
- build-mode: test
- build-depends: []
- EOF
+ # Create the test chunk repository.
+
+ mkdir "$DATADIR/gits/test-chunk"
+ cd "$DATADIR/gits/test-chunk"
+ git init .
# To verify that chunk splitting works, we have a chunk that installs
# dummy files in all the places that different kinds of files are
# usually installed. e.g. executables in `/bin` and `/usr/bin`
- install -m644 -D /dev/stdin << 'EOF' "$DATADIR/gits/morphs/test-chunk.morph"
- name: test-chunk
- kind: chunk
- build-system: manual
-
- # `install-commands` is a list of shell commands to run. Commands
- # may be on multiple lines, and indeed anything programmatic will
- # benefit from doing so. Arguably we could have just one command,
- # but it's split into multiple so that morph can inform us which
- # command failed without us having to include a lot of status
- # information in the command and look at the error message.
-
- install-commands:
-
+ PREFIX=/usr
+ DESTDIR=.
# It's important that we can test whether executables get
# installed, so we install an empty script into `/usr/bin/test` and
# `/usr/sbin/test`.
@@ -144,10 +119,10 @@ another to hold a chunk.
# that the file exists, rather than its contents, we can use /dev/null
# as the source.
- - |
- for bindir in bin sbin; do
- install -D /dev/null "$DESTDIR/$PREFIX/$bindir/test"
- done
+
+ for bindir in bin sbin; do
+ install -D /dev/null "$DESTDIR/$PREFIX/$bindir/test"
+ done
# We need shared libraries too, sometimes they're libraries to support
# the executables that a chunk provides, sometimes for other chunks.
@@ -158,14 +133,13 @@ another to hold a chunk.
# Shared libraries' file names start with lib and end with `.so`
# for shared-object, with version numbers optionally suffixed.
- - |
- for libdir in lib lib32 lib64; do
- dirpath="$DESTDIR/$PREFIX/$libdir"
- install -D /dev/null "$dirpath/libtest.so"
- ln -s libtest.so "$dirpath/libtest.so.0"
- ln -s libtest.so.0 "$dirpath/libtest.so.0.0"
- ln -s libtest.so.0.0 "$dirpath/libtest.so.0.0.0"
- done
+ for libdir in lib lib32 lib64; do
+ dirpath="$DESTDIR/$PREFIX/$libdir"
+ install -D /dev/null "$dirpath/libtest.so"
+ ln -s libtest.so "$dirpath/libtest.so.0"
+ ln -s libtest.so.0 "$dirpath/libtest.so.0.0"
+ ln -s libtest.so.0.0 "$dirpath/libtest.so.0.0.0"
+ done
# Shared objects aren't the only kind of library, some executable
# binaries count as libraries, such as git's plumbing commands.
@@ -173,8 +147,10 @@ another to hold a chunk.
# In some distributions they go into /lib, in others, and the default
# autotools configuration, they go into /libexec.
- - |
- install -D test-bin "$DESTDIR/$PREFIX/libexec/test-bin"
+ install -D /dev/stdin "$DESTDIR/$PREFIX/libexec/test-bin" <<'EOF'
+ #!/bin/sh
+ echo Hello World
+ EOF
# As well as run-time libraries, there's development files. For C
# this is headers, which describe the API of the libraries, which
@@ -185,9 +161,9 @@ another to hold a chunk.
# Header files go into `include` and end with `.h`. They are not
# executable, so the install command changes the permissions with the
# `-m` option.
-
- - |
- install -D -m 644 test.h "$DESTDIR/$PREFIX/include/test.h"
+ install -D -m 644 /dev/stdin <<'EOF' "$DESTDIR/$PREFIX/include/test.h"
+ int foo(void);
+ EOF
# `pkg-config` is a standard way to locate libraries and get the
# compiler flags needed to build with the library. It's also used
@@ -195,68 +171,138 @@ another to hold a chunk.
# so as well as being found in `lib/pkgconfig`, it can be found in
# `share/pkgconfig`, so we install dummy files to both.
- - |
- for pkgdir in lib lib32 lib64 share; do
- install -D -m 644 test.pc \
- "$DESTDIR/$PREFIX/$pkgdir/pkgconfig/test.pc"
- done
+ for pkgdir in lib lib32 lib64 share; do
+ install -D -m 644 /dev/stdin <<EOF \
+ "$DESTDIR/$PREFIX/$pkgdir/pkgconfig/test.pc"
+ prefix=$PREFIX
+ includedir=\${prefix}/include
+ Name: test
+ Cflags: -I{includedir}
+ EOF
+ done
# Static libraries can be used to build static binaries, which don't
# require their dependencies to be installed. They are typically in
# the form of `.a` archive and `.la` libtool archives.
- - |
- for libdir in lib lib32 lib64; do
- for libname in libtest.a libtest.la; do
- install -D -m 644 /dev/null "$DESTDIR/$PREFIX/$libdir/$libname"
- done
- done
+ for libdir in lib lib32 lib64; do
+ for libname in libtest.a libtest.la; do
+ install -D -m 644 /dev/null "$DESTDIR/$PREFIX/$libdir/$libname"
+ done
+ done
# Packages may also install documentation, this comes in a variety
# of formats, but info pages, man pages and html documentation are
# the most common.
- - |
- for docfile in info/test.info.gz man/man3/test.3.gz doc/test/doc.html; do
- install -D -m 644 /dev/null "$DESTDIR/$PREFIX/share/$docfile"
- done
+ for docfile in info/test.info.gz man/man3/test.3.gz doc/test/doc.html; do
+ install -D -m 644 /dev/null "$DESTDIR/$PREFIX/share/$docfile"
+ done
# Locale covers translations, timezones, keyboard layouts etc. in
# all manner of strange file formats and locations.
# Locale provides various translations for specific messages.
- - |
- install -D -m 644 /dev/null \
- "$DESTDIR/$PREFIX/share/locale/en_GB/LC_MESSAGES/test.mo"
+ install -D -m 644 /dev/null \
+ "$DESTDIR/$PREFIX/share/locale/en_GB/LC_MESSAGES/test.mo"
# Internationalisation (i18n) includes character maps and other data
# such as currency.
- - |
- for localefile in i18n/locales/en_GB charmaps/UTF-8.gz; do
- install -D -m 644 /dev/null "$DESTDIR/$PREFIX/share/$localefile"
- done
+ for localefile in i18n/locales/en_GB charmaps/UTF-8.gz; do
+ install -D -m 644 /dev/null "$DESTDIR/$PREFIX/share/$localefile"
+ done
# Timezones are another kind of localisation.
- - |
- install -D -m 644 /dev/null "$DESTDIR/$PREFIX/share/zoneinfo/UTC"
+ install -D -m 644 /dev/null "$DESTDIR/$PREFIX/share/zoneinfo/UTC"
# We also need a catch rule for everything that doesn't fit into
# the above categories, so to test that, we create some files that
# don't belong in one.
- - |
- for cfgfile in test.conf README; do
- install -D -m 644 /dev/null "$DESTDIR/etc/test.d/$cfgfile"
- done
+ for cfgfile in test.conf README; do
+ install -D -m 644 /dev/null "$DESTDIR/etc/test.d/$cfgfile"
+ done
+
+ git add .
+ git commit --allow-empty -m Initial.
+
+ # Create a repo for the morphologies.
+
+ mkdir "$DATADIR/gits/morphs"
+ cd "$DATADIR/gits/morphs"
+ git init .
+ arch=$(run_morph print-architecture)
+ install -m644 -D /dev/stdin << EOF "systems/test-system.morph"
+ name: test-system
+ kind: system
+ arch: $arch
+ strata:
+ - name: build-essential
+ morph: strata/build-essential.morph
+ - name: core
+ morph: strata/core.morph
+ EOF
+
+ install -m644 -D /dev/stdin << EOF "strata/build-essential.morph"
+ name: build-essential
+ kind: stratum
+ chunks:
+ - name: stage1-chunk
+ repo: test:bootstrap-chunk
+ ref: $(run_in "$DATADIR/gits/bootstrap-chunk" git rev-parse bootstrap)
+ unpetrify-ref: nootstrap
+ build-mode: bootstrap
+ build-depends: []
+ - name: stage2-chunk
+ morph: stage2-chunk.morph
+ repo: test:bootstrap-chunk
+ ref: $(run_in "$DATADIR/gits/bootstrap-chunk" git rev-parse master)
+ unpetrify-ref: master
+ build-depends:
+ - stage1-chunk
+ EOF
+ install -m644 -D /dev/stdin << EOF "strata/core.morph"
+ name: core
+ kind: stratum
+ build-depends:
+ - morph: strata/build-essential.morph
+ chunks:
+ - name: test-chunk
+ morph: test-chunk.morph
+ repo: test:test-chunk
+ unpetrify-ref: master
+ ref: $(run_in "$DATADIR/gits/test-chunk" git rev-parse master)
+ build-depends: []
+ EOF
+
+ install -m644 -D /dev/stdin << 'EOF' "test-chunk.morph"
+ name: test-chunk
+ kind: chunk
+ build-system: manual
+ # `install-commands` is a list of shell commands to run. Commands
+ # may be on multiple lines, and indeed anything programmatic will
+ # benefit from doing so. Arguably we could have just one command,
+ # but it's split into multiple so that morph can inform us which
+ # command failed without us having to include a lot of status
+ # information in the command and look at the error message.
+ install-commands:
+ - copy files
+ EOF
+
+ install -m644 -D /dev/stdin << 'EOF' "stage2-chunk.morph"
+ name: test-chunk
+ kind: chunk
+ build-system: manual
+ install-commands:
+ - copy files
EOF
- run_in "$DATADIR/gits/morphs" git init .
- run_in "$DATADIR/gits/morphs" git add .
- run_in "$DATADIR/gits/morphs" git commit -m Initial.
- run_in "$DATADIR/gits/morphs" git tag -a "test-tag" -m "Tagging test-tag"
+ git add .
+ git commit -m Initial.
+ git tag -a "test-tag" -m "Tagging test-tag"
# Start a git daemon to serve our git repositories
port_file="$DATADIR/git-daemon-port"
@@ -298,45 +344,6 @@ We need a consistent value for the architecture in some tests, so we
have a morphology using the test architecture.
IMPLEMENTS GIVEN a system called (\S+) for the test architecture in the git server
-
- cat << EOF > "$DATADIR/gits/morphs/stage1-chunk.morph"
- name: stage1-chunk
- kind: chunk
- build-system: dummy
- EOF
-
- run_in "$DATADIR/gits/morphs" git add .
- run_in "$DATADIR/gits/morphs" git commit -m "Add chunk for $MATCH_1"
-
-
- install -m644 -D /dev/stdin << EOF "$DATADIR/gits/morphs/strata/build-essential.morph"
- name: build-essential
- kind: stratum
- chunks:
- - name: stage1-chunk
- morph: stage1-chunk.morph
- repo: test:test-chunk
- ref: $(run_in "$DATADIR/gits/test-chunk" git rev-parse master)
- unpetrify-ref: master
- build-mode: bootstrap
- build-depends: []
- EOF
-
- install -m644 -D /dev/stdin << EOF "$DATADIR/gits/morphs/strata/core.morph"
- name: core
- kind: stratum
- build-depends:
- - morph: strata/build-essential.morph
- chunks:
- - name: test-chunk
- morph: test-chunk.morph
- repo: test:test-chunk
- unpetrify-ref: master
- ref: $(run_in "$DATADIR/gits/test-chunk" git rev-parse master)
- build-mode: test
- build-depends: []
- EOF
-
name="$(basename "${MATCH_1%.*}")"
cat << EOF > "$DATADIR/gits/morphs/$MATCH_1"
arch: testarch
@@ -380,7 +387,7 @@ We also need to verify that a system branch has been checked out.
IMPLEMENTS THEN the system branch (\S+) is checked out
is_dir "$DATADIR/workspace/$MATCH_1/test/morphs"
is_file "$DATADIR/workspace/$MATCH_1/test/morphs/systems/test-system.morph"
- is_file "$DATADIR/workspace/$MATCH_1/test/morphs/strata/test-stratum.morph"
+ is_file "$DATADIR/workspace/$MATCH_1/test/morphs/strata/core.morph"
We can create a new branch, off master.
@@ -487,8 +494,10 @@ print-architecture` to get a value appropriate for morph.
kind: system
name: $name
strata:
- - name: test-stratum
- morph: strata/test-stratum.morph
+ - name: build-essential
+ morph: strata/build-essential.morph
+ - name: core
+ morph: strata/core.morph
EOF
Reporting status of checked out repositories:
diff --git a/yarns/regression.yarn b/yarns/regression.yarn
index 7991ab12..c424f437 100644
--- a/yarns/regression.yarn
+++ b/yarns/regression.yarn
@@ -58,15 +58,15 @@ source it depended on.
SCENARIO changing the artifacts a system uses
GIVEN a workspace
AND a git server
- AND system systems/test-system.morph uses test-stratum-runtime from test-stratum
- AND stratum strata/test-stratum.morph has match rules: [{artifact: test-stratum-runtime, include: [.*-(bins|libs|locale)]}, {artifact: test-stratum-devel, include: [.*-(devel|doc|misc)]}]
+ AND system systems/test-system.morph uses core-runtime from core
+ AND stratum strata/core.morph has match rules: [{artifact: core-runtime, include: [.*-(bins|libs|locale)]}, {artifact: core-devel, include: [.*-(devel|doc|misc)]}]
WHEN the user checks out the system branch called master
GIVEN a cluster called test-cluster.morph in system branch master
AND a system in cluster test-cluster.morph in branch master called test-system
AND system test-system in cluster test-cluster.morph in branch master builds systems/test-system.morph
AND system test-system in cluster test-cluster.morph in branch master has deployment type: tar
WHEN the user builds the system systems/test-system.morph in branch master
- GIVEN stratum strata/test-stratum.morph in system branch master has match rules: [{artifact: test-stratum-runtime, include: [.*-(bins|libs|misc)]}, {artifact: test-stratum-devel, include: [.*-(devel|doc|locale)]}]
+ GIVEN stratum strata/core.morph in system branch master has match rules: [{artifact: core-runtime, include: [.*-(bins|libs|misc)]}, {artifact: core-devel, include: [.*-(devel|doc|locale)]}]
WHEN the user builds the system systems/test-system.morph in branch master
AND the user deploys the cluster test-cluster.morph in branch master with options test-system.location="$DATADIR/test.tar"
THEN tarball test.tar contains baserock/test-chunk-misc.meta
diff --git a/yarns/splitting.yarn b/yarns/splitting.yarn
index 9248f60c..2726d294 100644
--- a/yarns/splitting.yarn
+++ b/yarns/splitting.yarn
@@ -15,7 +15,7 @@ To test that all the fields are recognised, we set the new fields to
their default values.
AND chunk test-chunk includes the default splitting rules
- AND stratum strata/test-stratum.morph includes the default splitting rules
+ AND stratum strata/core.morph includes the default splitting rules
AND system systems/test-system.morph includes the default splitting rules
The default rules produce a system that is identical to not providing
@@ -41,7 +41,7 @@ libraries.
The only change we need to make is to add a field to the system morphology
to select which artifact to use in the system.
- AND system systems/test-system.morph uses test-stratum-runtime from test-stratum
+ AND system systems/test-system.morph uses core-runtime from core
WHEN the user checks out the system branch called master
The best way to test that only using some stratum artifacts works is
@@ -79,8 +79,8 @@ This GIVEN has a chunk in the stratum that never successfully builds,
so we know that if the system successfully builds, then we only built
chunks that were needed.
- AND stratum strata/test-stratum.morph has chunks that aren't used in test-stratum-minimal
- AND system systems/test-system.morph uses test-stratum-minimal from test-stratum
+ AND stratum strata/core.morph has chunks that aren't used in core-minimal
+ AND system systems/test-system.morph uses core-minimal from core
WHEN the user checks out the system branch called master
THEN morph build the system systems/test-system.morph of the branch master
FINALLY the git server is shut down
@@ -92,7 +92,7 @@ Implementations
IMPLEMENTS GIVEN chunk (\S+) includes the default splitting rules
# Append default products rules
name="$(basename "${MATCH_1%.*}")"
- cat <<EOF >>"$DATADIR/gits/morphs/$MATCH_1"
+ cat <<EOF >>"$DATADIR/gits/morphs/$MATCH_1.morph"
products:
- artifact: $name-bins
include: [ "(usr/)?s?bin/.*" ]
@@ -119,7 +119,7 @@ Implementations
- artifact: $name-misc
include: [ .* ]
EOF
- run_in "$DATADIR/gits/morphs" git add "$MATCH_1"
+ run_in "$DATADIR/gits/morphs" git add "$MATCH_1.morph"
run_in "$DATADIR/gits/morphs" git commit -m 'Add default splitting rules'
IMPLEMENTS GIVEN stratum (\S+) includes the default splitting rules
@@ -127,6 +127,8 @@ Implementations
cat <<EOF >"$DATADIR/gits/morphs/$MATCH_1"
name: $name
kind: stratum
+ build-depends:
+ - morph: strata/build-essential.morph
products:
- artifact: $name-devel
include:
@@ -146,7 +148,6 @@ Implementations
unpetrify-ref: master
ref: $(run_in "$DATADIR/gits/test-chunk" git rev-parse master)
morph: test-chunk.morph
- build-mode: test
build-depends: []
artifacts:
test-chunk-bins: $name-runtime
@@ -162,11 +163,13 @@ Implementations
IMPLEMENTS GIVEN system (\S+) includes the default splitting rules
cat << EOF >> "$DATADIR/gits/morphs/$MATCH_1"
strata:
- - name: test-stratum
- morph: strata/test-stratum.morph
+ - name: build-essential
+ morph: strata/build-essential.morph
+ - name: core
+ morph: strata/core.morph
artifacts:
- - test-stratum-runtime
- - test-stratum-devel
+ - core-runtime
+ - core-devel
EOF
run_in "$DATADIR/gits/morphs" git add "$MATCH_1"
run_in "$DATADIR/gits/morphs" git commit -m 'Add default splitting rules'
@@ -195,14 +198,12 @@ Implementations
morph: test-chunk.morph
unpetrify-ref: master
ref: $(run_in "$DATADIR/gits/test-chunk" git rev-parse master)
- build-mode: test
build-depends: []
- name: unbuildable-chunk
repo: test:test-chunk
unpetrify-ref: refs/heads/master
ref: $(run_in "$DATADIR/gits/test-chunk" git rev-parse master)
morph: unbuildable-chunk.morph
- build-mode: test
build-depends:
- test-chunk
EOF