|
| 1 | +#!/bin/bash |
| 2 | +# -*- indent-tabs-mode: nil; tab-width: 2; sh-indentation: 2; -*- |
| 3 | + |
| 4 | +# Tests that the iterative bootstrap produces correct results for a |
| 5 | +# package with transitive dependencies. Verifies that the LIFO-based |
| 6 | +# iterative loop builds dependencies in the correct order (deps before |
| 7 | +# their dependents) and that the build-order.json and graph.json are |
| 8 | +# consistent. |
| 9 | + |
| 10 | +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 11 | +source "$SCRIPTDIR/common.sh" |
| 12 | + |
| 13 | +fromager \ |
| 14 | + --log-file="$OUTDIR/bootstrap.log" \ |
| 15 | + --error-log-file="$OUTDIR/fromager-errors.log" \ |
| 16 | + --sdists-repo="$OUTDIR/sdists-repo" \ |
| 17 | + --wheels-repo="$OUTDIR/wheels-repo" \ |
| 18 | + --work-dir="$OUTDIR/work-dir" \ |
| 19 | + bootstrap 'stevedore==5.2.0' |
| 20 | + |
| 21 | +# Verify expected output files exist |
| 22 | +EXPECTED_FILES=" |
| 23 | +$OUTDIR/wheels-repo/downloads/setuptools-*.whl |
| 24 | +$OUTDIR/wheels-repo/downloads/pbr-*.whl |
| 25 | +$OUTDIR/wheels-repo/downloads/stevedore-*.whl |
| 26 | +$OUTDIR/work-dir/build-order.json |
| 27 | +$OUTDIR/work-dir/graph.json |
| 28 | +" |
| 29 | + |
| 30 | +pass=true |
| 31 | +for pattern in $EXPECTED_FILES; do |
| 32 | + if [ ! -f "${pattern}" ]; then |
| 33 | + echo "Did not find $pattern" 1>&2 |
| 34 | + pass=false |
| 35 | + fi |
| 36 | +done |
| 37 | + |
| 38 | +# Verify build order: dependencies must appear before dependents |
| 39 | +# pbr and setuptools must come before stevedore in build-order.json |
| 40 | +BUILD_ORDER="$OUTDIR/work-dir/build-order.json" |
| 41 | +pbr_idx=$(python3 -c " |
| 42 | +import json, sys |
| 43 | +data = json.load(open('$BUILD_ORDER')) |
| 44 | +dists = [e['dist'] for e in data] |
| 45 | +print(dists.index('pbr') if 'pbr' in dists else -1) |
| 46 | +") |
| 47 | +stevedore_idx=$(python3 -c " |
| 48 | +import json, sys |
| 49 | +data = json.load(open('$BUILD_ORDER')) |
| 50 | +dists = [e['dist'] for e in data] |
| 51 | +print(dists.index('stevedore') if 'stevedore' in dists else -1) |
| 52 | +") |
| 53 | + |
| 54 | +if [ "$pbr_idx" -ge "$stevedore_idx" ] || [ "$pbr_idx" -eq "-1" ]; then |
| 55 | + echo "ERROR: pbr (idx=$pbr_idx) must appear before stevedore (idx=$stevedore_idx) in build order" 1>&2 |
| 56 | + pass=false |
| 57 | +fi |
| 58 | + |
| 59 | +# Verify graph.json has the expected dependency edges |
| 60 | +python3 -c " |
| 61 | +import json, sys |
| 62 | +graph = json.load(open('$OUTDIR/work-dir/graph.json')) |
| 63 | +# stevedore should exist as a node |
| 64 | +stevedore_nodes = [k for k in graph if k.startswith('stevedore==')] |
| 65 | +if not stevedore_nodes: |
| 66 | + print('ERROR: stevedore not found in graph', file=sys.stderr) |
| 67 | + sys.exit(1) |
| 68 | +# pbr should exist as a node |
| 69 | +pbr_nodes = [k for k in graph if k.startswith('pbr==')] |
| 70 | +if not pbr_nodes: |
| 71 | + print('ERROR: pbr not found in graph', file=sys.stderr) |
| 72 | + sys.exit(1) |
| 73 | +print('Graph structure verified') |
| 74 | +" || pass=false |
| 75 | + |
| 76 | +$pass |
0 commit comments