diff --git a/README.md b/README.md index 4ff1750..7fff1a6 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ go run examples/server_endpoint/test_server.go 3000 Add delays between commands for stability after the endpoint from a previous command is up: ⏱️ ````bash -```bash docci-output-contains="GOOD" docci-wait-for-endpoint=http://localhost:3000/health|30 +```bash docci-output-contains="GOOD" docci-wait-for-endpoint=http://localhost:3000/health|5 VALUE=$(curl http://localhost:3000/health) echo "Got value: $VALUE" ``` diff --git a/Taskfile.yml b/Taskfile.yml index 443edb6..68400dd 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -18,7 +18,7 @@ tasks: cmds: - mkdir -p $GOPATH/bin - task build - - cp out/docci $GOPATH/bin/docci + - cp out/docci `go env GOPATH`/bin/docci generates: - out/docci diff --git a/docci.go b/docci.go index b2d53cd..2b6f459 100644 --- a/docci.go +++ b/docci.go @@ -62,10 +62,7 @@ func RunDocciFileWithOptions(filePath string, opts types.DocciOpts) DocciResult // Build executable script with validation markers log.Debug("Building executable script") - script, validationMap, assertFailureMap := parser.BuildExecutableScriptWithOptions(blocks, types.DocciOpts{ - HideBackgroundLogs: hideBackgroundLogs, - KeepRunning: keepRunning, - }) + script, validationMap, assertFailureMap := parser.BuildExecutableScriptWithOptions(blocks, opts) // Execute the script log.Debug("Executing script") @@ -222,10 +219,7 @@ func RunDocciFilesWithOptions(filePaths []string, opts types.DocciOpts) DocciRes // Build executable script with validation markers log.Debug("Building executable script from merged blocks") - script, validationMap, assertFailureMap := parser.BuildExecutableScriptWithOptions(allBlocks, types.DocciOpts{ - HideBackgroundLogs: hideBackgroundLogs, - KeepRunning: keepRunning, - }) + script, validationMap, assertFailureMap := parser.BuildExecutableScriptWithOptions(allBlocks, opts) // Execute the script log.Debug("Executing merged script") diff --git a/parser/script_templates.go b/parser/script_templates.go index d9dbe5a..28f7560 100644 --- a/parser/script_templates.go +++ b/parser/script_templates.go @@ -27,8 +27,8 @@ fi // Background block template backgroundBlockTemplate = `# Background block {{INDEX}}{{FILE_INFO}} -setsid bash -c '{ -{{CONTENT}}}' > /tmp/docci_bg_{{INDEX}}.out 2>&1 & +( +{{CONTENT}}) > /tmp/docci_bg_{{INDEX}}.out 2>&1 & DOCCI_BG_PID_{{INDEX}}=$! echo 'Started background process {{INDEX}} with PID '$DOCCI_BG_PID_{{INDEX}} @@ -64,7 +64,7 @@ while true; do exit 1 fi - if curl -s -f --max-time 5 "$endpoint_url" > /dev/null 2>&1; then + if wget -q --timeout=5 --tries=1 --spider "$endpoint_url" > /dev/null 2>&1; then echo "Endpoint $endpoint_url is ready" break fi