This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 9426500 docs: exec code block for shell commands in Test Nginx (#5625)
9426500 is described below
commit 942650037d77007a292b4f80d98975fe9d6a5a37
Author: Bisakh <[email protected]>
AuthorDate: Sun Nov 28 08:43:54 2021 +0530
docs: exec code block for shell commands in Test Nginx (#5625)
Co-authored-by: 罗泽轩 <[email protected]>
---
docs/en/latest/internal/testing-framework.md | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/docs/en/latest/internal/testing-framework.md
b/docs/en/latest/internal/testing-framework.md
index db86729..7b22fd7 100644
--- a/docs/en/latest/internal/testing-framework.md
+++ b/docs/en/latest/internal/testing-framework.md
@@ -286,3 +286,24 @@ ONLY:
--- response_body
{"action":"get","count":0,"node":{"dir":true,"key":"/apisix/upstreams","nodes":{}}}
```
+
+### Executing Shell Commands
+
+It is possible to execute shell commands while writing tests in test-nginx for
APISIX. We expose this feature via `exec` code block. The `stdout` of the
executed process can be captured via `response_body` code block and `stderr`
(if any) can be captured by filtering error.log through `grep_error_log`. Here
is an example:
+
+```
+=== TEST 1: check exec stdout
+--- exec
+echo hello world
+--- response_body
+hello world
+
+
+=== TEST 2: when exec returns an error
+--- exec
+echxo hello world
+--- grep_error_log eval
+qr/failed to execute the script [ -~]*/
+--- grep_error_log_out
+failed to execute the script with status: 127, reason: exit, stderr: /bin/sh:
1: echxo: not found
+```