diff options
Diffstat (limited to 'yarns/splitting.yarn')
-rw-r--r-- | yarns/splitting.yarn | 211 |
1 files changed, 211 insertions, 0 deletions
diff --git a/yarns/splitting.yarn b/yarns/splitting.yarn new file mode 100644 index 00000000..2726d294 --- /dev/null +++ b/yarns/splitting.yarn @@ -0,0 +1,211 @@ +Artifact splitting tests +======================== + +Parsing and validation +---------------------- + +To verify that the products fields are parsed correctly, we have a +scenario that uses all of them, not relying on the default rules. + + SCENARIO building a system with morphologies that have splitting rules + GIVEN a workspace + AND a git server + +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/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 +them, and since this test is about validation, we don't care about the +result, so much as it succeeding to build something. + + 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 + +Smaller systems +--------------- + +An example use-case for splitting is to only include the runtime +strata for a target system, rather than including all the development +information, such as the documentation, C library headers and C static +libraries. + + SCENARIO building a system only using runtime strata + GIVEN a workspace + AND a git server + +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 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 +to check which files the output has, so we deploy a tarball and inspect +its contents. + + 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 + AND the user attempts to deploy the cluster test-cluster.morph in branch master with options test-system.location="$DATADIR/test.tar" + +The -runtime artifacts include executables and shared libraries. + + THEN morph succeeded + AND tarball test.tar contains bin/test + AND tarball test.tar contains lib/libtest.so + +The -devel artifacts include static libraries and documentation, so if +we've successfully excluded it, we won't have those files. + + AND tarball test.tar doesn't contain lib/libtest.a + AND tarball test.tar doesn't contain man/man3/test.3.gz + +As a consequence of how dependencies are generated, if we select strata +to go into our system, such that there are chunk artifacts that are not +needed, then they don't get built. + + SCENARIO building a system that has unused chunks + GIVEN a workspace + AND a git server + +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/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 + + +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.morph" + products: + - artifact: $name-bins + include: [ "(usr/)?s?bin/.*" ] + - artifact: $name-libs + include: + - (usr/)?lib(32|64)?/lib[^/]*\.so(\.\d+)* + - (usr/)?libexec/.* + - artifact: $name-devel + include: + - (usr/)?include/.* + - (usr/)?lib(32|64)?/lib.*\.a + - (usr/)?lib(32|64)?/lib.*\.la + - (usr/)?(lib(32|64)?|share)/pkgconfig/.*\.pc + - artifact: $name-doc + include: + - (usr/)?share/doc/.* + - (usr/)?share/man/.* + - (usr/)?share/info/.* + - artifact: $name-locale + include: + - (usr/)?share/locale/.* + - (usr/)?share/i18n/.* + - (usr/)?share/zoneinfo/.* + - artifact: $name-misc + include: [ .* ] + EOF + 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 + name=$(basename "${MATCH_1%.*}") + cat <<EOF >"$DATADIR/gits/morphs/$MATCH_1" + name: $name + kind: stratum + build-depends: + - morph: strata/build-essential.morph + products: + - artifact: $name-devel + include: + - .*-devel + - .*-debug + - .*-doc + - artifact: $name-runtime + include: + - .*-bins + - .*-libs + - .*-locale + - .*-misc + - .* + chunks: + - name: test-chunk + repo: test:test-chunk + unpetrify-ref: master + ref: $(run_in "$DATADIR/gits/test-chunk" git rev-parse master) + morph: test-chunk.morph + build-depends: [] + artifacts: + test-chunk-bins: $name-runtime + test-chunk-libs: $name-runtime + test-chunk-locale: $name-runtime + test-chunk-misc: $name-runtime + test-chunk-devel: $name-devel + test-chunk-doc: $name-devel + EOF + run_in "$DATADIR/gits/morphs" git add "$MATCH_1" + run_in "$DATADIR/gits/morphs" git commit -m 'Add default splitting rules' + + IMPLEMENTS GIVEN system (\S+) includes the default splitting rules + cat << EOF >> "$DATADIR/gits/morphs/$MATCH_1" + strata: + - name: build-essential + morph: strata/build-essential.morph + - name: core + morph: strata/core.morph + artifacts: + - 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' + + IMPLEMENTS GIVEN stratum (\S+) has chunks that aren't used in (\S+) + # Create an extra chunk that will never successfully build + cat >"$DATADIR/gits/morphs/unbuildable-chunk.morph" <<EOF + name: unbuildable-chunk + kind: chunk + install-commands: + - "false" + EOF + run_in "$DATADIR/gits/morphs" git add unbuildable-chunk.morph + run_in "$DATADIR/gits/morphs" git commit -m 'Add unbuildable chunk' + + # Create a stratum that has an artifact that doesn't include any + # artifacts from unbuildable-chunk + cat >>"$DATADIR/gits/morphs/$MATCH_1" <<EOF + products: + - artifact: $MATCH_2 + include: + - test-chunk-.* + 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-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-depends: + - test-chunk + EOF + run_in "$DATADIR/gits/morphs" git add "$MATCH_1" + run_in "$DATADIR/gits/morphs" git commit -m "add $MATCH_2 to stratum" |