File: dependency-ordering

package info (click to toggle)
zkg 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,740 kB
  • sloc: python: 5,910; sh: 268; makefile: 265; cpp: 24
file content (92 lines) | stat: -rw-r--r-- 2,599 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# This test puts in place a dependecy tree, installs the tree's root package,
# and verifies that package builds and testing honors the dependency ordering:
# depended-upon packages need to be built and available prior to dependers.
# The package tree:

# foo  ---> bar ----> grault
#     \            /
#      baz -> corge
#
# To verify the ordering we use package executables that dependers require both
# in test_command and build_command. This leverages the fact that executables
# transparently appear in a bin/ directory in the test staging area. foo's build
# & test call executables that bar and baz install; baz's build & test call
# corge's executable, bar and corge call grault's executable.

# We trigger package tests in the below, for which zkg internally looks
# for zeek-config. So require a Zeek install:
# @TEST-REQUIRES: type zeek-config

# @TEST-EXEC: BUILDLOG=$(pwd)/build.log bash %INPUT

# After testing, the packages get installed up the dependency chain, installing
# their executables into the bin folder at the test's toplevel. That directory
# isn't automatically in the path, so add it.
# @TEST-EXEC: PATH=$(pwd)/bin:$PATH zkg install foo

# Verify the order and number of times the packages got built.
# @TEST-EXEC: btest-diff build.log

add_executable() {
    echo "echo from $1" >$1
    chmod +x $1
    git add $1
}

(
    cd packages/foo
    cat >>zkg.meta <<EOF
build_command = bar && baz && echo "building foo" >>$BUILDLOG
test_command = bar && baz
depends =
  bar *
  baz *
EOF
    git commit -am 'foo: depend on bar and baz, add commands'
)

(
    cd packages/bar
    cat >>zkg.meta <<EOF
build_command = grault && echo "building bar" >>$BUILDLOG
test_command = grault
executables = bar
depends = grault *
EOF
    add_executable bar
    git commit -am 'bar: depend on grault, add executable and commands'
)

(
    cd packages/baz
    cat >>zkg.meta <<EOF
build_command = corge && echo "building baz" >>$BUILDLOG
test_command = corge
executables = baz
depends = corge *
EOF
    add_executable baz
    git commit -am 'baz: depend on corge, add executable and commands'
)

(
    cd packages/corge
    cat >>zkg.meta <<EOF
build_command = grault && echo "building corge" >>$BUILDLOG
test_command = grault
executables = corge
depends = grault *
EOF
    add_executable corge
    git commit -am 'corge: depend on grault, add executable and commands'
)

(
    cd packages/grault
    cat >>zkg.meta <<EOF
build_command = echo "building grault" >>$BUILDLOG
executables = grault
EOF
    add_executable grault
    git commit -am 'grault: add executable and build command'
)