Skip to content

Commit e1d8271

Browse files
committed
Merge remote-tracking branch 'origin/topic/awelzel/force-still-fails-tests'
* origin/topic/awelzel/force-still-fails-tests: Reduce to 2 CPUs per task for CI tasks Fix upgrade using test_command of old version Change --force to fail on failing tests
2 parents 5ade27d + 9881210 commit e1d8271

File tree

12 files changed

+154
-39
lines changed

12 files changed

+154
-39
lines changed

.cirrus.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cpus: &CPUS 8
1+
cpus: &CPUS 2
22

33
resources_template: &RESOURCES_TEMPLATE
44
cpu: *CPUS

CHANGES

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
2.13.0-30 | 2023-04-21 20:37:27 +0200
2+
3+
* Reduce to 2 CPUs per task for CI tasks (Arne Welzel, Corelight)
4+
5+
Specifying 8 CPUs and two tasks immediately allocates as many resources
6+
as are available for free for a single user on Cirrus. Depending on what
7+
else a user is using Cirrus for, execution of zkg tasks may be delayed
8+
for significant amounts of time.
9+
10+
The test-suite does not run such a long duration that the 4x reduction
11+
in CPUs should have a practical impact.
12+
13+
* Fix upgrade using test_command of old version (Arne Welzel, Corelight)
14+
15+
* GH-137: Change --force to fail on failing tests (Arne Welzel, Corelight)
16+
17+
This is a user-visible change in behavior, but to something sane, so
18+
hopefully that's acceptable.
19+
20+
Currently, `--force` is oftentimes used in scenarios where it should mean
21+
"non-interactive". At the same time, `--force` also implies to ignore
22+
failing test commands. This is not reasonable behavior, particularly as
23+
`--skiptests` is available. This patch changes the behavior and causes
24+
install/upgrade to exit with a failure code when tests fail even with
25+
`--force` provided.
26+
27+
If someone intentionally wants to install a package with broken tests,
28+
they can/should use `--skiptests` explicitly instead. That is less
29+
surprising and stands out more.
30+
31+
Fixes #137
32+
133
2.13.0-26 | 2023-02-03 09:23:59 +0100
234

335
* Fix zkg bundled usage (Arne Welzel, Corelight)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.13.0-26
1+
2.13.0-30

doc/man/zkg.1

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
2727
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
2828
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
2929
..
30-
.TH "ZKG" "1" "Jan 17, 2023" "2.13.0-24" "Zeek Package Manager"
30+
.TH "ZKG" "1" "Apr 21, 2023" "2.13.0-30" "Zeek Package Manager"
3131
.SH NAME
3232
zkg \- Zeek Package Manager
3333
.sp
@@ -38,10 +38,7 @@ A command\-line package manager for Zeek.
3838
.sp
3939
.nf
4040
.ft C
41-
usage: zkg [\-h] [\-\-version] [\-\-configfile FILE | \-\-user] [\-\-verbose]
42-
[\-\-extra\-source NAME=URL]
43-
{test,install,bundle,unbundle,remove,uninstall,purge,refresh,upgrade,load,unload,pin,unpin,list,search,info,config,autoconfig,env,create,template}
44-
...
41+
usage: zkg [\-h] [\-\-version] [\-\-configfile FILE | \-\-user] [\-\-verbose] [\-\-extra\-source NAME=URL] {test,install,bundle,unbundle,remove,uninstall,purge,refresh,upgrade,load,unload,pin,unpin,list,search,info,config,autoconfig,env,create,template} ...
4542
.ft P
4643
.fi
4744
.UNINDENT
@@ -119,9 +116,7 @@ Installs packages from a configured package source or directly from a git URL.
119116
.sp
120117
.nf
121118
.ft C
122-
usage: zkg install [\-h] [\-\-skiptests] [\-\-nodeps] [\-\-nosuggestions]
123-
[\-\-version VERSION] [\-\-force] [\-\-user\-var NAME=VAL]
124-
package [package ...]
119+
usage: zkg install [\-h] [\-\-skiptests] [\-\-nodeps] [\-\-nosuggestions] [\-\-version VERSION] [\-\-force] [\-\-user\-var NAME=VAL] package [package ...]
125120
.ft P
126121
.fi
127122
.UNINDENT
@@ -229,9 +224,7 @@ This command creates a bundle file containing a collection of Zeek packages. If
229224
.sp
230225
.nf
231226
.ft C
232-
usage: zkg bundle [\-h] [\-\-force] [\-\-nodeps] [\-\-nosuggestions]
233-
[\-\-manifest MANIFEST [MANIFEST ...] \-\-]
234-
filename.bundle
227+
usage: zkg bundle [\-h] [\-\-force] [\-\-nodeps] [\-\-nosuggestions] [\-\-manifest MANIFEST [MANIFEST ...] \-\-] filename.bundle
235228
.ft P
236229
.fi
237230
.UNINDENT
@@ -270,8 +263,7 @@ This command unpacks a bundle file formerly created by the \fBbundle\fP command
270263
.sp
271264
.nf
272265
.ft C
273-
usage: zkg unbundle [\-h] [\-\-replace] [\-\-force] [\-\-user\-var NAME=VAL]
274-
filename.bundle
266+
usage: zkg unbundle [\-h] [\-\-replace] [\-\-force] [\-\-user\-var NAME=VAL] filename.bundle
275267
.ft P
276268
.fi
277269
.UNINDENT
@@ -307,8 +299,7 @@ Retrieve latest package metadata from sources and checks whether any installed p
307299
.sp
308300
.nf
309301
.ft C
310-
usage: zkg refresh [\-h] [\-\-aggregate] [\-\-fail\-on\-aggregate\-problems] [\-\-push]
311-
[\-\-sources SOURCES [SOURCES ...]]
302+
usage: zkg refresh [\-h] [\-\-aggregate] [\-\-fail\-on\-aggregate\-problems] [\-\-push] [\-\-sources SOURCES [SOURCES ...]]
312303
.ft P
313304
.fi
314305
.UNINDENT
@@ -340,9 +331,7 @@ Uprades the specified package(s) to latest available version. If no specific pa
340331
.sp
341332
.nf
342333
.ft C
343-
usage: zkg upgrade [\-h] [\-\-skiptests] [\-\-nodeps] [\-\-nosuggestions] [\-\-force]
344-
[\-\-user\-var NAME=VAL]
345-
[package ...]
334+
usage: zkg upgrade [\-h] [\-\-skiptests] [\-\-nodeps] [\-\-nosuggestions] [\-\-force] [\-\-user\-var NAME=VAL] [package ...]
346335
.ft P
347336
.fi
348337
.UNINDENT
@@ -493,8 +482,7 @@ Outputs a list of packages that match a given category.
493482
.sp
494483
.nf
495484
.ft C
496-
usage: zkg list [\-h] [\-\-nodesc]
497-
[{all,installed,not_installed,loaded,unloaded,outdated}]
485+
usage: zkg list [\-h] [\-\-nodesc] [{all,installed,not_installed,loaded,unloaded,outdated}]
498486
.ft P
499487
.fi
500488
.UNINDENT
@@ -549,9 +537,7 @@ Shows detailed information/metadata for given packages. If the package is curren
549537
.sp
550538
.nf
551539
.ft C
552-
usage: zkg info [\-h] [\-\-version VERSION] [\-\-nolocal] [\-\-json]
553-
[\-\-jsonpretty SPACES] [\-\-allvers]
554-
package [package ...]
540+
usage: zkg info [\-h] [\-\-version VERSION] [\-\-nolocal] [\-\-json] [\-\-jsonpretty SPACES] [\-\-allvers] package [package ...]
555541
.ft P
556542
.fi
557543
.UNINDENT
@@ -593,8 +579,7 @@ The default output of this command is a valid package manager config file that c
593579
.sp
594580
.nf
595581
.ft C
596-
usage: zkg config [\-h]
597-
[{all,sources,user_vars,state_dir,script_dir,plugin_dir,bin_dir,zeek_dist,bro_dist}]
582+
usage: zkg config [\-h] [{all,sources,user_vars,state_dir,script_dir,plugin_dir,bin_dir,zeek_dist,bro_dist}]
598583
.ft P
599584
.fi
600585
.UNINDENT
@@ -658,9 +643,7 @@ This command creates a new Zeek package in the directory provided via \-\-packag
658643
.sp
659644
.nf
660645
.ft C
661-
usage: zkg create [\-h] \-\-packagedir DIR [\-\-version VERSION]
662-
[\-\-features FEATURE [FEATURE ...]] [\-\-template URL]
663-
[\-\-force] [\-\-user\-var NAME=VAL]
646+
usage: zkg create [\-h] \-\-packagedir DIR [\-\-version VERSION] [\-\-features FEATURE [FEATURE ...]] [\-\-template URL] [\-\-force] [\-\-user\-var NAME=VAL]
664647
.ft P
665648
.fi
666649
.UNINDENT
@@ -698,9 +681,7 @@ This command shows versions and supported features for a given package.
698681
.sp
699682
.nf
700683
.ft C
701-
usage: zkg template info [\-h] [\-\-json] [\-\-jsonpretty SPACES]
702-
[\-\-version VERSION]
703-
[URL]
684+
usage: zkg template info [\-h] [\-\-json] [\-\-jsonpretty SPACES] [\-\-version VERSION] [URL]
704685
.ft P
705686
.fi
706687
.UNINDENT
@@ -730,7 +711,7 @@ The template version to report on. A version tag, branch name, or commit hash m
730711
.SH CONFIG FILE
731712
.sp
732713
The \fBzkg\fP command\-line tool uses an INI\-format config file to allow
733-
users to customize their Package Sources, Package installation paths, Zeek executable/source paths, and other
714+
users to customize their \fI\%Package Sources\fP, \fI\%Package\fP installation paths, Zeek executable/source paths, and other
734715
\fBzkg\fP options.
735716
.sp
736717
See the default/example config file below for explanations of the
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
2+
Installing "one<...>/foo"
3+
error: incomplete installation, the follow packages failed to be installed:
4+
one<...>/foo (main)
5+
Failed installing "one<...>/foo": package build_command failed, see log in <...>/foo-build.log
6+
have_load_bar=1
7+
have_load_foo=0
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
2+
=== install without skiptests
3+
error: failed to run tests for one<...>/foo: test_command failed with exit code 1
4+
Running unit tests for "one<...>/foo"
5+
have_load_foo=0
6+
=== install with skiptests
7+
Installing "one<...>/foo"
8+
Installed "one<...>/foo" (main)
9+
Loaded "one<...>/foo"
10+
have_load_foo=1
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
2+
Installing "one<...>/foo"
3+
Installed "one<...>/foo" (1.0.2)
4+
Loaded "one<...>/foo"
5+
=== upgrade without skiptests
6+
error: failed to run tests for one<...>/foo: test_command failed with exit code 1
7+
Running unit tests for "one<...>/foo"
8+
=== upgrade with skiptest
9+
Upgraded "one<...>/foo" (1.0.3)
10+
print "foo 1.0.3";
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# @TEST-DOC: Test that a failing build_command fails the package installation, no matter what.
2+
# @TEST-REQUIRES: type zeek-config
3+
#
4+
# @TEST-EXEC: bash %INPUT
5+
6+
# @TEST-EXEC: zkg install bar
7+
#
8+
# @TEST-EXEC-FAIL: zkg -v install --force --skiptests foo >>out 2>&1
9+
# @TEST-EXEC: echo "have_load_bar=$(grep -c '@load.*bar' ./scripts/packages/packages.zeek)" >>out
10+
# @TEST-EXEC: echo "have_load_foo=$(grep -c '@load.*foo' ./scripts/packages/packages.zeek)" >>out
11+
#
12+
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
13+
14+
cd packages/foo
15+
echo 'build_command = exit 1' >> zkg.meta
16+
git commit -am 'build fails'
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# @TEST-DOC: Test that a failing test_command with --force causes zkg install to fail and the package is not loaded. Also, verify that --skiptests can override that.
2+
# @TEST-REQUIRES: type zeek-config
3+
#
4+
# @TEST-EXEC: bash %INPUT
5+
6+
# @TEST-EXEC: echo "=== install without skiptests" >>out
7+
# @TEST-EXEC-FAIL: zkg -v install --force foo >>out 2>&1
8+
# @TEST-EXEC: echo "have_load_foo=$(grep -c '@load.*foo' ./scripts/packages/packages.zeek)" >>out
9+
#
10+
# @TEST-EXEC: rm -rf ./state
11+
# @TEST-EXEC: echo "=== install with skiptests" >>out
12+
# @TEST-EXEC: zkg -v install --force --skiptests foo >>out 2>&1
13+
# @TEST-EXEC: echo "have_load_foo=$(grep -c '@load.*foo' ./scripts/packages/packages.zeek)" >>out
14+
#
15+
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
16+
17+
cd packages/foo
18+
echo 'test_command = exit 1' >> zkg.meta
19+
git commit -am 'add a test'

testing/tests/upgrade-test-fail

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# @TEST-DOC: Upgrading fails when a test_comamnd fails, even with --force.
2+
# @TEST-REQUIRES: type zeek-config
3+
# @TEST-EXEC: (cd packages/foo && echo 'print "foo 1.0.2";' >> __load__.zeek && git tag -a 1.0.2 -m 1.0.2 )
4+
5+
# @TEST-EXEC: zkg install foo >>out 2>&1
6+
7+
# @TEST-EXEC: bash improve-foo-tag-1.0.3
8+
9+
# @TEST-EXEC: zkg refresh
10+
#
11+
# @TEST-EXEC: echo "=== upgrade without skiptests" >>out
12+
# @TEST-EXEC-FAIL: zkg upgrade --force >>out 2>&1
13+
14+
# The upgrade failed, no 1.0.3 to be found in the __load__.zeek file
15+
# @TEST-EXEC-FAIL: grep -F '1.0.3' scripts/packages/foo/__load__.zeek >>out
16+
#
17+
# @TEST-EXEC: echo "=== upgrade with skiptest" >>out
18+
# @TEST-EXEC: zkg upgrade --force --skiptests >>out 2>&1
19+
# @TEST-EXEC: grep -F '1.0.3' scripts/packages/foo/__load__.zeek >>out
20+
#
21+
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
22+
23+
@TEST-START-FILE improve-foo-tag-1.0.3
24+
set -e
25+
cd packages/foo
26+
echo 'test_command = exit 1' >> zkg.meta
27+
echo 'print "foo 1.0.3";' > __load__.zeek
28+
git add zkg.meta
29+
git commit -am 'add a test'
30+
git tag -a 1.0.3 -m 1.0.3
31+
@TEST-END-FILE

0 commit comments

Comments
 (0)