@@ -14,11 +14,14 @@ archive:
14
14
path: "$( mangle_path " $archiveDir " ) "
15
15
EOF
16
16
17
+ function clean_output () {
18
+ echo $( echo " $@ " | sed 1d | sed " s/^[ \t]*//" )
19
+ }
20
+
17
21
# fill archive
18
22
run_bob build --download=no --upload root-alpha root-bravo
19
23
FINGERPRINT=Alice run_bob build --force --download=no --upload root-alpha root-bravo
20
24
21
- pushd $archiveDir
22
25
run_bob archive scan
23
26
24
27
# first try to keep everything by using multiple expressions
@@ -28,13 +31,14 @@ newNum=$(/usr/bin/find -name '*.tgz' | wc -l)
28
31
test $oldNum -eq $newNum
29
32
30
33
# Find one of the artifacts
31
- found=$( run_bob archive find ' meta.package == "root-bravo"' )
34
+ found=$( clean_output " $( run_bob archive find ' meta.package == "root-bravo"' ) " )
35
+ pushd $archiveDir
32
36
expect_exist " $found "
37
+ popd
33
38
34
39
# selectively keep one half
35
40
run_bob archive clean --dry-run ' metaEnv.TYPE == "alpha"'
36
41
run_bob archive clean -v ' metaEnv.TYPE == "alpha"'
37
- popd
38
42
39
43
# alpha can be downloaded, bravo must fail
40
44
rm -rf work
@@ -48,29 +52,26 @@ pushd $archiveDir
48
52
mkdir -p 64/ad
49
53
/usr/bin/tar zcf 64/ad/6386bae45ebd6788e404758a247e26e5c778-1.tgz /dev/zero
50
54
touch 64/ad/aabbcc-too-short.tgz
51
- run_bob archive scan
52
55
popd
53
56
57
+ run_bob archive scan
54
58
# Test that -v doesn't catch fire
55
59
run_bob archive scan -v
56
60
run_bob archive clean -v ' metaEnv.TYPE == "alpha"'
57
61
58
- # Test for --fail option
62
+ # Test for --fail option (--fail only reports -1 if there are no files matching the pattern xx/xx/hash-1.tgz)
63
+ expect_success run_bob archive scan --fail -v
64
+ expect_success run_bob archive clean --fail -v ' metaEnv.TYPE == "alpha"'
65
+ rm -rf work $archiveDir /*
59
66
expect_fail run_bob archive scan --fail -v
60
67
expect_fail run_bob archive clean --fail -v ' metaEnv.TYPE == "alpha"'
61
- pushd $archiveDir
62
- run_bob archive scan --fail -v
63
- run_bob archive clean --fail -v ' metaEnv.TYPE == "alpha"'
64
- popd
65
68
66
69
# Test the "LIMIT" feature. Build a number or artifacts and keep only a portion
67
70
# of them. By default the artifacts are sorted by build date and the most
68
71
# recent is kept. Verify that the correct subset was retained.
69
72
rm -rf " $archiveDir /" *
70
73
run_bob build --download no --upload -q ' many-*'
71
- pushd $archiveDir
72
74
run_bob archive clean --fail -v ' meta.recipe == "many" LIMIT 3'
73
- popd
74
75
test $( /usr/bin/find $archiveDir -name ' *.tgz' | wc -l) -eq 3
75
76
run_bob build --download forced --force many-07 many-06 many-05
76
77
@@ -79,31 +80,27 @@ run_bob build --download forced --force many-07 many-06 many-05
79
80
# must not be counted.
80
81
rm -rf " $archiveDir /" *
81
82
run_bob build --download no --force --upload -q ' many-*'
82
- pushd $archiveDir
83
83
run_bob archive clean --fail -v ' meta.recipe == "many" LIMIT 2 OrDeR By metaEnv.FUZZ ASC'
84
- popd
85
84
test $( /usr/bin/find $archiveDir -name ' *.tgz' | wc -l) -eq 2
86
85
run_bob build --download forced --force many-01 many-03
87
86
88
87
# Must fail if LIMIT is zero, invalid or negative
89
- pushd $archiveDir
90
88
expect_fail run_bob archive clean ' meta.recipe == "many" LIMIT 0'
91
89
expect_fail run_bob archive clean ' meta.recipe == "many" LIMIT -3'
92
90
expect_fail run_bob archive clean ' meta.recipe == "many" LIMIT foobar'
93
- popd
94
91
95
92
# Build artifacts with special audit meta keys. Try to find them later.
96
93
rm -rf " $archiveDir /" * work
97
94
run_bob build --upload -M my-key=one root-alpha
98
95
run_bob build --upload -M my-key=two root-bravo
99
- pushd $archiveDir
100
96
run_bob archive scan --fail
101
- found1=$( run_bob archive find -n ' meta.recipe == "root" && meta.my-key == "one"' )
97
+ found1=$( clean_output " $( run_bob archive find -n ' meta.recipe == "root" && meta.my-key == "one"' ) " )
98
+ found2=$( clean_output " $( run_bob archive find -n ' meta.recipe == "root" && meta.my-key == "two"' ) " )
99
+ pushd $archiveDir
102
100
expect_exist " $found1 "
103
- found2=$( run_bob archive find -n ' meta.recipe == "root" && meta.my-key == "two"' )
104
101
expect_exist " $found2 "
105
- test " $found1 " ! = " $found2 "
106
102
popd
103
+ test " $found1 " ! = " $found2 "
107
104
108
105
# Make sure invalid audit meta keys are rejected
109
106
expect_fail run_bob build -M " !nv@l1d=key" root-alpha
0 commit comments