Choose test server port in a range

To fix random test failures
This commit is contained in:
Michaël Lemaire 2021-06-22 18:39:44 +02:00
parent bc885f4612
commit 9c8aa11dea
5 changed files with 28 additions and 7 deletions

1
config/run.flags Normal file
View File

@ -0,0 +1 @@
--allow-read --allow-net --location https://rs.thunderk.net/

1
config/test.flags Normal file
View File

@ -0,0 +1 @@
--allow-read --allow-net --location https://test.rs.thunderk.net/

19
run Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
# Simplified run tool for deno commands
if test $# -eq 0
then
echo "Usage: $0 [file or command]"
exit 1
elif echo $1 | grep -q '.*.ts'
then
denocmd=run
denoargs=$1
shift
else
denocmd=$1
shift
fi
denoargs="$(cat config/$denocmd.flags 2> /dev/null) $denoargs $@"
exec deno $denocmd $denoargs

View File

@ -1,8 +1,8 @@
#!/usr/bin/env -S deno run --allow-read --allow-net #!./run
import { getLocalStorage } from "./mod.ts";
import { KeyValueStorage } from "./basic.ts"; import { KeyValueStorage } from "./basic.ts";
import { HEADER_REPLYIER, HEADER_REQUESTER } from "./remote.ts";
import { json, opine, opineCors, readAll } from "./deps.ts"; import { json, opine, opineCors, readAll } from "./deps.ts";
import { getLocalStorage } from "./mod.ts";
import { HEADER_REPLYIER, HEADER_REQUESTER } from "./remote.ts";
const PORT = 5001; const PORT = 5001;

View File

@ -1,12 +1,12 @@
import { KeyValueStorage, MemoryStorage } from "./basic.ts";
import { expect } from "https://code.thunderk.net/typescript/devtools/raw/1.2.2/testing.ts"; import { expect } from "https://code.thunderk.net/typescript/devtools/raw/1.2.2/testing.ts";
import { getAvailablePort } from "https://deno.land/x/port@1.0.0/mod.ts";
import { KeyValueStorage, MemoryStorage } from "./basic.ts";
import { startRestServer } from "./server.ts";
export { export {
describe, describe,
expect, expect,
it, it,
} from "https://code.thunderk.net/typescript/devtools/raw/1.2.2/testing.ts"; } from "https://code.thunderk.net/typescript/devtools/raw/1.2.2/testing.ts";
import { getAvailablePort } from "https://deno.land/x/port@1.0.0/mod.ts";
import { startRestServer } from "./server.ts";
/** /**
* Basic high-level test suite for any kind storage * Basic high-level test suite for any kind storage
@ -43,7 +43,7 @@ export async function disableLocalStorage(
export async function runTestServer( export async function runTestServer(
body: (url: string) => Promise<void>, body: (url: string) => Promise<void>,
): Promise<void> { ): Promise<void> {
const port = await getAvailablePort(); const port = await getAvailablePort({ port: { start: 3000, end: 30000 } });
if (!port) { if (!port) {
throw new Error("No port available for test server"); throw new Error("No port available for test server");
} }