[master] 4d06897eb varnishtest: Add include command

Nils Goroll nils.goroll at uplex.de
Sat May 17 18:25:09 UTC 2025


commit 4d06897eb6a5bd2ad47b8819f09910559d8d6649
Author: AlveElde <alve_elde at hotmail.com>
Date:   Thu Jan 18 16:38:46 2024 +0100

    varnishtest: Add include command
    
    The contents of a file included by this command are executed as-is. The
    command is global, which means that the include command can be used
    inside HTTP specs as the test case shows. We require at least one
    argument, and subsequent file path arguments are parsed in order.
    
    This command can be used to build more complex VTCs, as well as reducing
    repetitiveness. We make no attempts to avoid circular includes.
    
    Committer edit: This change was originally added to vtest as
    5a5b4ebfa33da9dfb57e8707d98a2f64f4dee7e2 and then manually applied to
    Varnish-Cache as f0dc9964e953fbcc11869957f11382098be0a9ab, but without the test
    case. The test-case was originally added as a00021.vtc, which, at the time of
    this retrospective addition, was already taken by the tunnel command test.

diff --git a/bin/varnishtest/tests/a00026.vtc b/bin/varnishtest/tests/a00026.vtc
new file mode 100644
index 000000000..bb0b88cd5
--- /dev/null
+++ b/bin/varnishtest/tests/a00026.vtc
@@ -0,0 +1,28 @@
+varnishtest "Test VTC includes"
+
+shell {
+	cat >${tmpdir}/f1 <<-EOF
+	rxreq
+	EOF
+}
+
+shell {
+	cat >${tmpdir}/f2 <<-EOF
+	txresp
+	EOF
+}
+
+shell {
+	cat >${tmpdir}/f3 <<-EOF
+	server s1 {
+		include "${tmpdir}/f1" "${tmpdir}/f2"
+	} -start
+	EOF
+}
+
+include "${tmpdir}/f3"
+
+client c1 -connect "${s1_sock}" {
+	txreq
+	rxresp
+} -run


More information about the varnish-commit mailing list