use -r:off for runnableExamples that should compile but not run (#17203)
* use -r:off for runnableExamples that should compile but not run * use -r:off in other RT disabled tests
This commit is contained in:
parent
aef55a7a88
commit
dd6b0f81ef
5 changed files with 38 additions and 42 deletions
|
|
@ -14,32 +14,30 @@
|
|||
## application in production you should use a reverse proxy (for example nginx)
|
||||
## instead of allowing users to connect directly to this server.
|
||||
|
||||
runnableExamples:
|
||||
runnableExamples("-r:off"):
|
||||
# This example will create an HTTP server on port 8080. The server will
|
||||
# respond to all requests with a `200 OK` response code and "Hello World"
|
||||
# as the response body. Run locally with:
|
||||
# `nim doc --doccmd:-d:nimAsyncHttpServerEnableTest --lib:lib lib/pure/asynchttpserver.nim`
|
||||
# as the response body.
|
||||
import std/asyncdispatch
|
||||
if defined(nimAsyncHttpServerEnableTest):
|
||||
proc main {.async.} =
|
||||
const port = 8080
|
||||
var server = newAsyncHttpServer()
|
||||
proc cb(req: Request) {.async.} =
|
||||
echo (req.reqMethod, req.url, req.headers)
|
||||
let headers = {"Content-type": "text/plain; charset=utf-8"}
|
||||
await req.respond(Http200, "Hello World", headers.newHttpHeaders())
|
||||
proc main {.async.} =
|
||||
const port = 8080
|
||||
var server = newAsyncHttpServer()
|
||||
proc cb(req: Request) {.async.} =
|
||||
echo (req.reqMethod, req.url, req.headers)
|
||||
let headers = {"Content-type": "text/plain; charset=utf-8"}
|
||||
await req.respond(Http200, "Hello World", headers.newHttpHeaders())
|
||||
|
||||
echo "test this with: curl localhost:" & $port & "/"
|
||||
server.listen(Port(port))
|
||||
while true:
|
||||
if server.shouldAcceptRequest():
|
||||
await server.acceptRequest(cb)
|
||||
else:
|
||||
# too many concurrent connections, `maxFDs` exceeded
|
||||
# wait 500ms for FDs to be closed
|
||||
await sleepAsync(500)
|
||||
echo "test this with: curl localhost:" & $port & "/"
|
||||
server.listen(Port(port))
|
||||
while true:
|
||||
if server.shouldAcceptRequest():
|
||||
await server.acceptRequest(cb)
|
||||
else:
|
||||
# too many concurrent connections, `maxFDs` exceeded
|
||||
# wait 500ms for FDs to be closed
|
||||
await sleepAsync(500)
|
||||
|
||||
waitFor main()
|
||||
waitFor main()
|
||||
|
||||
import asyncnet, asyncdispatch, parseutils, uri, strutils
|
||||
import httpcore
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue