Update to latest asynctest, with unittest2 support
Also fixes a number of GcUnsafe2 warnings, by placing var declarations inside the suite.
This commit is contained in:
parent
e199aa57da
commit
e974a866b6
|
@ -1,32 +0,0 @@
|
||||||
## nim-websock
|
|
||||||
## Copyright (c) 2021 Status Research & Development GmbH
|
|
||||||
## Licensed under either of
|
|
||||||
## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
|
||||||
## * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
|
||||||
## at your option.
|
|
||||||
## This file may not be copied, modified, or distributed except according to
|
|
||||||
## those terms.
|
|
||||||
|
|
||||||
import unittest2
|
|
||||||
export unittest2 except suite, test
|
|
||||||
|
|
||||||
template suite*(name, body) =
|
|
||||||
suite name:
|
|
||||||
|
|
||||||
template setup(setupBody) {.used.} =
|
|
||||||
setup:
|
|
||||||
let asyncproc = proc {.async.} = setupBody
|
|
||||||
waitFor asyncproc()
|
|
||||||
|
|
||||||
template teardown(teardownBody) {.used.} =
|
|
||||||
teardown:
|
|
||||||
let asyncproc = proc {.async.} = teardownBody
|
|
||||||
waitFor asyncproc()
|
|
||||||
|
|
||||||
let suiteproc = proc = body # Avoids GcUnsafe2 warnings with chronos
|
|
||||||
suiteproc()
|
|
||||||
|
|
||||||
template test*(name, body) =
|
|
||||||
test name:
|
|
||||||
let asyncproc = proc {.async.} = body
|
|
||||||
waitFor asyncproc()
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
import std/os
|
import std/os
|
||||||
import pkg/[chronos, stew/byteutils, stew/io2]
|
import pkg/[chronos, stew/byteutils, stew/io2]
|
||||||
import ../asyncunit
|
import pkg/asynctest/unittest2
|
||||||
import ../../websock/websock, ../helpers
|
import ../../websock/websock, ../helpers
|
||||||
import ../../websock/extensions/compression/deflate
|
import ../../websock/extensions/compression/deflate
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
|
|
||||||
import std/strutils
|
import std/strutils
|
||||||
import pkg/[chronos, stew/byteutils]
|
import pkg/[chronos, stew/byteutils]
|
||||||
|
import pkg/asynctest/unittest2
|
||||||
|
|
||||||
import ../../ws/ws
|
import ../../ws/ws
|
||||||
import ../asyncunit
|
|
||||||
|
|
||||||
type
|
type
|
||||||
ExtHandler = proc(ext: Ext, frame: Frame): Future[Frame] {.raises: [Defect].}
|
ExtHandler = proc(ext: Ext, frame: Frame): Future[Frame] {.raises: [Defect].}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
import pkg/[chronos, stew/byteutils]
|
import pkg/[chronos, stew/byteutils]
|
||||||
import ../asyncunit
|
import pkg/asynctest/unittest2
|
||||||
import ./base64ext, ./hexext
|
import ./base64ext, ./hexext
|
||||||
import ../../websock/websock, ../helpers
|
import ../../websock/websock, ../helpers
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
import
|
import
|
||||||
pkg/[asynctest, chronos],
|
pkg/chronos,
|
||||||
|
pkg/asynctest/unittest2,
|
||||||
../websock/extensions
|
../websock/extensions
|
||||||
|
|
||||||
suite "extension parser":
|
suite "extension parser":
|
||||||
|
|
|
@ -7,16 +7,18 @@
|
||||||
## This file may not be copied, modified, or distributed except according to
|
## This file may not be copied, modified, or distributed except according to
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
import pkg/[asynctest, stew/byteutils]
|
import pkg/stew/byteutils
|
||||||
|
import pkg/asynctest/unittest2
|
||||||
|
|
||||||
include ../websock/frame
|
include ../websock/frame
|
||||||
include ../websock/utils
|
include ../websock/utils
|
||||||
|
|
||||||
# TODO: Fix Test.
|
# TODO: Fix Test.
|
||||||
|
|
||||||
|
suite "Test data frames":
|
||||||
|
|
||||||
var maskKey: array[4, char]
|
var maskKey: array[4, char]
|
||||||
|
|
||||||
suite "Test data frames":
|
|
||||||
test "# 7bit length text":
|
test "# 7bit length text":
|
||||||
check (await Frame(
|
check (await Frame(
|
||||||
fin: false,
|
fin: false,
|
||||||
|
@ -252,6 +254,8 @@ suite "Test data frames":
|
||||||
|
|
||||||
suite "Test control frames":
|
suite "Test control frames":
|
||||||
|
|
||||||
|
var maskKey: array[4, char]
|
||||||
|
|
||||||
test "Close":
|
test "Close":
|
||||||
check (await Frame(
|
check (await Frame(
|
||||||
fin: true,
|
fin: true,
|
||||||
|
|
|
@ -11,7 +11,7 @@ import
|
||||||
std/[strutils],
|
std/[strutils],
|
||||||
pkg/[
|
pkg/[
|
||||||
stew/byteutils,
|
stew/byteutils,
|
||||||
asynctest,
|
asynctest/unittest2,
|
||||||
chronos,
|
chronos,
|
||||||
chronicles
|
chronicles
|
||||||
],
|
],
|
||||||
|
@ -78,12 +78,11 @@ proc waitForClose(ws: WSSession) {.async.} =
|
||||||
except CatchableError:
|
except CatchableError:
|
||||||
trace "Closing websocket"
|
trace "Closing websocket"
|
||||||
|
|
||||||
# TODO: use new test framework from dryajov
|
suite "UTF-8 validator in action":
|
||||||
# if it is ready.
|
|
||||||
var server: HttpServer
|
var server: HttpServer
|
||||||
let address = initTAddress("127.0.0.1:8888")
|
let address = initTAddress("127.0.0.1:8888")
|
||||||
|
|
||||||
suite "UTF-8 validator in action":
|
|
||||||
teardown:
|
teardown:
|
||||||
server.stop()
|
server.stop()
|
||||||
await server.closeWait()
|
await server.closeWait()
|
||||||
|
|
|
@ -12,20 +12,20 @@ import pkg/[
|
||||||
httputils,
|
httputils,
|
||||||
chronos,
|
chronos,
|
||||||
chronicles,
|
chronicles,
|
||||||
stew/byteutils]
|
stew/byteutils,
|
||||||
|
asynctest/unittest2]
|
||||||
|
|
||||||
import ../websock/websock
|
import ../websock/websock
|
||||||
|
|
||||||
import ./asynctest
|
|
||||||
import ./helpers
|
import ./helpers
|
||||||
|
|
||||||
let
|
let address = initTAddress("127.0.0.1:8888")
|
||||||
address* = initTAddress("127.0.0.1:8888")
|
|
||||||
|
suite "Test handshake":
|
||||||
|
|
||||||
var
|
var
|
||||||
server: HttpServer
|
server: HttpServer
|
||||||
|
|
||||||
suite "Test handshake":
|
|
||||||
teardown:
|
teardown:
|
||||||
server.stop()
|
server.stop()
|
||||||
await server.closeWait()
|
await server.closeWait()
|
||||||
|
@ -98,6 +98,9 @@ suite "Test handshake":
|
||||||
protocols = @["proto"])
|
protocols = @["proto"])
|
||||||
|
|
||||||
suite "Test transmission":
|
suite "Test transmission":
|
||||||
|
var
|
||||||
|
server: HttpServer
|
||||||
|
|
||||||
teardown:
|
teardown:
|
||||||
server.stop()
|
server.stop()
|
||||||
await server.closeWait()
|
await server.closeWait()
|
||||||
|
@ -163,6 +166,10 @@ suite "Test transmission":
|
||||||
await waitForClose(session)
|
await waitForClose(session)
|
||||||
|
|
||||||
suite "Test ping-pong":
|
suite "Test ping-pong":
|
||||||
|
|
||||||
|
var
|
||||||
|
server: HttpServer
|
||||||
|
|
||||||
teardown:
|
teardown:
|
||||||
server.stop()
|
server.stop()
|
||||||
await server.closeWait()
|
await server.closeWait()
|
||||||
|
@ -280,6 +287,10 @@ suite "Test ping-pong":
|
||||||
await session.close()
|
await session.close()
|
||||||
|
|
||||||
suite "Test framing":
|
suite "Test framing":
|
||||||
|
|
||||||
|
var
|
||||||
|
server: HttpServer
|
||||||
|
|
||||||
teardown:
|
teardown:
|
||||||
server.stop()
|
server.stop()
|
||||||
await server.closeWait()
|
await server.closeWait()
|
||||||
|
@ -338,6 +349,10 @@ suite "Test framing":
|
||||||
await waitForClose(session)
|
await waitForClose(session)
|
||||||
|
|
||||||
suite "Test Closing":
|
suite "Test Closing":
|
||||||
|
|
||||||
|
var
|
||||||
|
server: HttpServer
|
||||||
|
|
||||||
teardown:
|
teardown:
|
||||||
server.stop()
|
server.stop()
|
||||||
await server.closeWait()
|
await server.closeWait()
|
||||||
|
@ -564,6 +579,9 @@ suite "Test Closing":
|
||||||
await session.close(reason = "HH")
|
await session.close(reason = "HH")
|
||||||
|
|
||||||
suite "Test Payload":
|
suite "Test Payload":
|
||||||
|
var
|
||||||
|
server: HttpServer
|
||||||
|
|
||||||
teardown:
|
teardown:
|
||||||
server.stop()
|
server.stop()
|
||||||
await server.closeWait()
|
await server.closeWait()
|
||||||
|
@ -789,6 +807,9 @@ suite "Test Payload":
|
||||||
ws.binary == false
|
ws.binary == false
|
||||||
|
|
||||||
suite "Test Binary message with Payload":
|
suite "Test Binary message with Payload":
|
||||||
|
var
|
||||||
|
server: HttpServer
|
||||||
|
|
||||||
teardown:
|
teardown:
|
||||||
server.stop()
|
server.stop()
|
||||||
await server.closeWait()
|
await server.closeWait()
|
||||||
|
@ -953,6 +974,9 @@ suite "Test Binary message with Payload":
|
||||||
ws.binary == true
|
ws.binary == true
|
||||||
|
|
||||||
suite "Partial frames":
|
suite "Partial frames":
|
||||||
|
var
|
||||||
|
server: HttpServer
|
||||||
|
|
||||||
teardown:
|
teardown:
|
||||||
server.stop()
|
server.stop()
|
||||||
await server.closeWait()
|
await server.closeWait()
|
||||||
|
|
|
@ -19,7 +19,7 @@ requires "chronos >= 3.0.0"
|
||||||
requires "httputils >= 0.2.0"
|
requires "httputils >= 0.2.0"
|
||||||
requires "chronicles#ba2817f1"
|
requires "chronicles#ba2817f1"
|
||||||
requires "stew >= 0.1.0"
|
requires "stew >= 0.1.0"
|
||||||
requires "asynctest >= 0.2.0 & < 0.3.0"
|
requires "asynctest >= 0.3.0 & < 0.4.0"
|
||||||
requires "nimcrypto"
|
requires "nimcrypto"
|
||||||
requires "bearssl"
|
requires "bearssl"
|
||||||
requires "https://github.com/status-im/nim-zlib"
|
requires "https://github.com/status-im/nim-zlib"
|
||||||
|
|
Loading…
Reference in New Issue