1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 16:19:12 -05:00

refactor: rename Deno.TestDefinition.skip to ignore (#4400)

This commit is contained in:
Bartek Iwańczuk 2020-03-19 10:58:12 +01:00 committed by GitHub
parent 54d1f299dc
commit b0b27c4310
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 82 additions and 83 deletions

View file

@ -17,7 +17,7 @@ declare namespace Deno {
export interface TestDefinition {
fn: TestFunction;
name: string;
skip?: boolean;
ignore?: boolean;
disableOpSanitizer?: boolean;
disableResourceSanitizer?: boolean;
}
@ -38,7 +38,7 @@ declare namespace Deno {
enum TestStatus {
Passed = "passed",
Failed = "failed",
Skipped = "skipped"
Ignored = "ignored"
}
interface TestResult {

View file

@ -10,7 +10,7 @@ import { assert } from "./util.ts";
const RED_FAILED = red("FAILED");
const GREEN_OK = green("ok");
const YELLOW_SKIPPED = yellow("SKIPPED");
const YELLOW_IGNORED = yellow("ignored");
const disabledConsole = new Console((_x: string, _isErr?: boolean): void => {});
function formatDuration(time = 0): string {
@ -68,7 +68,7 @@ export type TestFunction = () => void | Promise<void>;
export interface TestDefinition {
fn: TestFunction;
name: string;
skip?: boolean;
ignore?: boolean;
disableOpSanitizer?: boolean;
disableResourceSanitizer?: boolean;
}
@ -93,12 +93,12 @@ export function test(
if (!t) {
throw new TypeError("The test name can't be empty");
}
testDef = { fn: fn as TestFunction, name: t, skip: false };
testDef = { fn: fn as TestFunction, name: t, ignore: false };
} else if (typeof t === "function") {
if (!t.name) {
throw new TypeError("The test function can't be anonymous");
}
testDef = { fn: t, name: t.name, skip: false };
testDef = { fn: t, name: t.name, ignore: false };
} else {
if (!t.fn) {
throw new TypeError("Missing test function");
@ -106,8 +106,7 @@ export function test(
if (!t.name) {
throw new TypeError("The test name can't be empty");
}
testDef = { ...t, skip: Boolean(t.skip) };
testDef = { ...t, ignore: Boolean(t.ignore) };
}
if (testDef.disableOpSanitizer !== true) {
@ -141,7 +140,7 @@ export interface RunTestsOptions {
enum TestStatus {
Passed = "passed",
Failed = "failed",
Skipped = "skipped"
Ignored = "ignored"
}
interface TestResult {
@ -211,11 +210,11 @@ class TestApi {
const results: TestResult[] = [];
const suiteStart = +new Date();
for (const { name, fn, skip } of this.testsToRun) {
for (const { name, fn, ignore } of this.testsToRun) {
const result: Partial<TestResult> = { name, duration: 0 };
yield { kind: TestEvent.TestStart, name };
if (skip) {
result.status = TestStatus.Skipped;
if (ignore) {
result.status = TestStatus.Ignored;
this.stats.ignored++;
} else {
const start = +new Date();
@ -321,8 +320,8 @@ export class ConsoleTestReporter implements TestReporter {
case TestStatus.Failed:
this.log(`${RED_FAILED} ${formatDuration(result.duration)}`);
break;
case TestStatus.Skipped:
this.log(`${YELLOW_SKIPPED} ${formatDuration(result.duration)}`);
case TestStatus.Ignored:
this.log(`${YELLOW_IGNORED} ${formatDuration(result.duration)}`);
break;
}
}

View file

@ -17,7 +17,7 @@ unitTest(function simpleTestFn(): void {
});
unitTest({
skip: Deno.build.os === "win",
ignore: Deno.build.os === "win",
perms: { read: true, write: true },
},
function complexTestFn(): void {

View file

@ -27,7 +27,7 @@ unitTest(
// Check symlink when not on windows
unitTest(
{
skip: Deno.build.os === "win",
ignore: Deno.build.os === "win",
perms: { read: true, write: true }
},
function chmodSyncSymlinkSuccess(): void {
@ -103,7 +103,7 @@ unitTest(
unitTest(
{
skip: Deno.build.os === "win",
ignore: Deno.build.os === "win",
perms: { read: true, write: true }
},
async function chmodSymlinkSuccess(): Promise<void> {

View file

@ -203,7 +203,7 @@ unitTest(
{
// FIXME(bartlomieju):
// The feature below is not implemented, but the test should work after implementation
skip: true,
ignore: true,
perms: { net: true }
},
async function fetchWithInfRedirection(): Promise<void> {
@ -363,7 +363,7 @@ function bufferServer(addr: string): Deno.Buffer {
unitTest(
{
// FIXME(bartlomieju)
skip: true,
ignore: true,
perms: { net: true }
},
async function fetchRequest(): Promise<void> {
@ -393,7 +393,7 @@ unitTest(
unitTest(
{
// FIXME(bartlomieju)
skip: true,
ignore: true,
perms: { net: true }
},
async function fetchPostBodyString(): Promise<void> {
@ -427,7 +427,7 @@ unitTest(
unitTest(
{
// FIXME(bartlomieju)
skip: true,
ignore: true,
perms: { net: true }
},
async function fetchPostBodyTypedArray(): Promise<void> {

View file

@ -18,7 +18,7 @@ unitTest(
{
perms: { net: true },
// TODO:
skip: Deno.build.os === "win"
ignore: Deno.build.os === "win"
},
function netUdpListenClose(): void {
const socket = Deno.listen({
@ -111,7 +111,7 @@ unitTest({ perms: { net: true } }, async function netTcpDialListen(): Promise<
});
unitTest(
{ skip: Deno.build.os === "win", perms: { net: true } },
{ ignore: Deno.build.os === "win", perms: { net: true } },
async function netUdpSendReceive(): Promise<void> {
const alice = Deno.listen({ port: 4500, transport: "udp" });
assertEquals(alice.addr.port, 4500);
@ -151,7 +151,7 @@ unitTest(
);
unitTest(
{ skip: Deno.build.os === "win", perms: { net: true } },
{ ignore: Deno.build.os === "win", perms: { net: true } },
async function netUdpListenCloseWhileIterating(): Promise<void> {
const socket = Deno.listen({ port: 8000, transport: "udp" });
const nextWhileClosing = socket[Symbol.asyncIterator]().next();
@ -166,7 +166,7 @@ unitTest(
unitTest(
{
// FIXME(bartlomieju)
skip: true,
ignore: true,
perms: { net: true }
},
async function netListenAsyncIterator(): Promise<void> {
@ -201,7 +201,7 @@ unitTest(
unitTest(
{
// FIXME(bartlomieju)
skip: true,
ignore: true,
perms: { net: true }
},
async function netCloseReadSuccess() {
@ -238,7 +238,7 @@ unitTest(
unitTest(
{
// FIXME(bartlomieju)
skip: true,
ignore: true,
perms: { net: true }
},
async function netDoubleCloseRead() {
@ -270,7 +270,7 @@ unitTest(
unitTest(
{
// FIXME(bartlomieju)
skip: true,
ignore: true,
perms: { net: true }
},
async function netCloseWriteSuccess() {
@ -309,7 +309,7 @@ unitTest(
unitTest(
{
// FIXME(bartlomieju)
skip: true,
ignore: true,
perms: { net: true }
},
async function netDoubleCloseWrite() {

View file

@ -50,7 +50,7 @@ unitTest(function envPermissionDenied2(): void {
// case-insensitive. Case normalization needs be done using the collation
// that Windows uses, rather than naively using String.toLowerCase().
unitTest(
{ skip: Deno.build.os !== "win", perms: { env: true, run: true } },
{ ignore: Deno.build.os !== "win", perms: { env: true, run: true } },
async function envCaseInsensitive() {
// Utility function that runs a Deno subprocess with the environment
// specified in `inputEnv`. The subprocess reads the environment variables

View file

@ -49,7 +49,7 @@ unitTest(
unitTest(
{
// No signals on windows.
skip: Deno.build.os === "win",
ignore: Deno.build.os === "win",
perms: { run: true }
},
async function runCommandFailedWithSignal(): Promise<void> {

View file

@ -14,7 +14,7 @@ unitTest({ perms: { read: true } }, function realpathSyncSuccess(): void {
unitTest(
{
skip: Deno.build.os === "win",
ignore: Deno.build.os === "win",
perms: { read: true, write: true }
},
function realpathSyncSymlink(): void {
@ -66,7 +66,7 @@ unitTest({ perms: { read: true } }, async function realpathSuccess(): Promise<
unitTest(
{
skip: Deno.build.os === "win",
ignore: Deno.build.os === "win",
perms: { read: true, write: true }
},
async function realpathSymlink(): Promise<void> {

View file

@ -14,7 +14,7 @@ function defer(n: number): Promise<void> {
}
unitTest(
{ skip: Deno.build.os !== "win" },
{ ignore: Deno.build.os !== "win" },
async function signalsNotImplemented(): Promise<void> {
assertThrows(
() => {
@ -104,7 +104,7 @@ unitTest(
);
unitTest(
{ skip: Deno.build.os === "win", perms: { run: true, net: true } },
{ ignore: Deno.build.os === "win", perms: { run: true, net: true } },
async function signalStreamTest(): Promise<void> {
const resolvable = createResolvable();
// This prevents the program from exiting.
@ -138,7 +138,7 @@ unitTest(
);
unitTest(
{ skip: Deno.build.os === "win", perms: { run: true } },
{ ignore: Deno.build.os === "win", perms: { run: true } },
async function signalPromiseTest(): Promise<void> {
const resolvable = createResolvable();
// This prevents the program from exiting.
@ -161,7 +161,7 @@ unitTest(
);
unitTest(
{ skip: Deno.build.os === "win", perms: { run: true } },
{ ignore: Deno.build.os === "win", perms: { run: true } },
async function signalShorthandsTest(): Promise<void> {
let s: Deno.SignalStream;
s = Deno.signals.alarm(); // for SIGALRM

View file

@ -184,7 +184,7 @@ unitTest({ perms: { read: true } }, async function lstatNotFound(): Promise<
});
unitTest(
{ skip: Deno.build.os !== "win", perms: { read: true, write: true } },
{ ignore: Deno.build.os !== "win", perms: { read: true, write: true } },
async function statNoUnixFields(): Promise<void> {
const enc = new TextEncoder();
const data = enc.encode("Hello");
@ -205,7 +205,7 @@ unitTest(
);
unitTest(
{ skip: Deno.build.os === "win", perms: { read: true, write: true } },
{ ignore: Deno.build.os === "win", perms: { read: true, write: true } },
async function statUnixFields(): Promise<void> {
const enc = new TextEncoder();
const data = enc.encode("Hello");

View file

@ -123,12 +123,12 @@ interface UnitTestPermissions {
}
interface UnitTestOptions {
skip?: boolean;
ignore?: boolean;
perms?: UnitTestPermissions;
}
interface UnitTestDefinition extends Deno.TestDefinition {
skip: boolean;
ignore: boolean;
perms: Permissions;
}
@ -169,7 +169,7 @@ export function unitTest(
const unitTestDefinition: UnitTestDefinition = {
name,
fn,
skip: !!options.skip,
ignore: !!options.ignore,
perms: normalizedPerms
};

View file

@ -3,7 +3,7 @@ import { unitTest, assertEquals } from "./test_util.ts";
unitTest(
{
skip: Deno.build.os === "win"
ignore: Deno.build.os === "win"
},
function umaskSuccess(): void {
const prevMask = Deno.umask(0o020);

View file

@ -183,7 +183,7 @@ unitTest(function sortingNonExistentParamRemovesQuestionMarkFromURL(): void {
unitTest(
{
// FIXME(bartlomieju)
skip: true
ignore: true
},
function customInspectFunction(): void {
const url = new URL("http://example.com/?");

View file

@ -43,7 +43,7 @@ zzz,yyy,xxx`,
["a,a", `bbb`, "ccc"],
["zzz", "yyy", "xxx"]
],
skip: true
ignore: true
},
{
Name: "NoEOLTest",
@ -63,7 +63,7 @@ line","one line","three
line
field"`,
Output: [["two\nline"], ["one line"], ["three\nline\nfield"]],
skip: true
ignore: true
},
{
Name: "BlankLine",
@ -263,20 +263,20 @@ x,,,
Input: 'a,"b\nc"d,e',
Error: true,
// Error: &ParseError{StartLine: 1, Line: 2, Column: 1, Err: ErrQuote},
skip: true
ignore: true
},
{
Name: "StartLine2",
Input: 'a,b\n"d\n\n,e',
Error: true,
// Error: &ParseError{StartLine: 2, Line: 5, Column: 0, Err: ErrQuote},
skip: true
ignore: true
},
{
Name: "CRLFInQuotedField", // Issue 21201
Input: 'A,"Hello\r\nHi",B\r\n',
Output: [["A", "Hello\nHi", "B"]],
skip: true
ignore: true
},
{
Name: "BinaryBlobField", // Issue 19410
@ -287,32 +287,32 @@ x,,,
Name: "TrailingCR",
Input: "field1,field2\r",
Output: [["field1", "field2"]],
skip: true
ignore: true
},
{
Name: "QuotedTrailingCR",
Input: '"field"\r',
Output: [['"field"']],
skip: true
ignore: true
},
{
Name: "QuotedTrailingCRCR",
Input: '"field"\r\r',
Error: true,
// Error: &ParseError{StartLine: 1, Line: 1, Column: 6, Err: ErrQuote},
skip: true
ignore: true
},
{
Name: "FieldCR",
Input: "field\rfield\r",
Output: [["field\rfield"]],
skip: true
ignore: true
},
{
Name: "FieldCRCR",
Input: "field\r\rfield\r\r",
Output: [["field\r\rfield\r"]],
skip: true
ignore: true
},
{
Name: "FieldCRCRLF",
@ -328,7 +328,7 @@ x,,,
Name: "FieldCRCRLFCRCR",
Input: "field\r\r\n\r\rfield\r\r\n\r\r",
Output: [["field\r"], ["\r\rfield\r"], ["\r"]],
skip: true
ignore: true
},
{
Name: "MultiFieldCRCRLFCRCR",
@ -338,7 +338,7 @@ x,,,
["\r\rfield1", "field2\r"],
["\r\r", ""]
],
skip: true
ignore: true
},
{
Name: "NonASCIICommaAndComment",
@ -374,12 +374,12 @@ x,,,
Name: "QuotedFieldMultipleLF",
Input: '"\n\n\n\n"',
Output: [["\n\n\n\n"]],
skip: true
ignore: true
},
{
Name: "MultipleCRLF",
Input: "\r\n\r\n\r\n\r\n",
skip: true
ignore: true
},
/**
* The implementation may read each line in several chunks if
@ -392,7 +392,7 @@ x,,,
"#ignore\n".repeat(10000) + "@".repeat(5000) + "," + "*".repeat(5000),
Output: [["@".repeat(5000), "*".repeat(5000)]],
Comment: "#",
skip: true
ignore: true
},
{
Name: "QuoteWithTrailingCRLF",
@ -410,27 +410,27 @@ x,,,
Name: "DoubleQuoteWithTrailingCRLF",
Input: '"foo""bar"\r\n',
Output: [[`foo"bar`]],
skip: true
ignore: true
},
{
Name: "EvenQuotes",
Input: `""""""""`,
Output: [[`"""`]],
skip: true
ignore: true
},
{
Name: "OddQuotes",
Input: `"""""""`,
Error: true,
// Error:" &ParseError{StartLine: 1, Line: 1, Column: 7, Err: ErrQuote}",
skip: true
ignore: true
},
{
Name: "LazyOddQuotes",
Input: `"""""""`,
Output: [[`"""`]],
LazyQuotes: true,
skip: true
ignore: true
},
{
Name: "BadComma1",
@ -466,7 +466,7 @@ x,,,
];
for (const t of testCases) {
Deno.test({
skip: !!t.skip,
ignore: !!t.ignore,
name: `[CSV] ${t.Name}`,
async fn(): Promise<void> {
let comma = ",";

View file

@ -27,10 +27,10 @@ async function startServer(): Promise<Deno.Process> {
}
// TODO: https://github.com/denoland/deno/issues/4108
const skip = build.os == "win";
const ignore = build.os == "win";
test({
skip,
ignore,
name: "GET / should serve html",
async fn() {
const server = await startServer();
@ -49,7 +49,7 @@ test({
});
test({
skip,
ignore,
name: "GET /ws should upgrade conn to ws",
async fn() {
const server = await startServer();

View file

@ -6,7 +6,7 @@ Deno.test({
name: "[examples/curl] send a request to a specified url",
// FIXME(bartlomieju): this test is leaking both resources and ops,
// and causes interference with other tests
skip: true,
ignore: true,
fn: async () => {
const server = serve({ port: 8081 });
(async (): Promise<void> => {

View file

@ -8,7 +8,7 @@ const isWindows = Deno.build.os == "win";
export async function testWalk(
setup: (arg0: string) => void | Promise<void>,
t: Deno.TestFunction,
skip = false
ignore = false
): Promise<void> {
const name = t.name;
async function fn(): Promise<void> {
@ -23,7 +23,7 @@ export async function testWalk(
await remove(d, { recursive: true });
}
}
Deno.test({ skip, name: `[walk] ${name}`, fn });
Deno.test({ ignore, name: `[walk] ${name}`, fn });
}
function normalize({ filename }: WalkInfo): string {

View file

@ -346,7 +346,7 @@ test(async function requestBodyReaderWithTransferEncoding(): Promise<void> {
test({
name: "destroyed connection",
// FIXME(bartlomieju): hangs on windows, cause can't do `Deno.kill`
skip: true,
ignore: true,
fn: async (): Promise<void> => {
// Runs a simple server as another process
const p = Deno.run({
@ -387,7 +387,7 @@ test({
test({
name: "serveTLS",
// FIXME(bartlomieju): hangs on windows, cause can't do `Deno.kill`
skip: true,
ignore: true,
fn: async (): Promise<void> => {
// Runs a simple server as another process
const p = Deno.run({
@ -459,7 +459,7 @@ test("close server while iterating", async (): Promise<void> => {
// We need to find a way to similarly trigger an error on Windows so that
// we can test if connection is closed.
test({
skip: Deno.build.os == "win",
ignore: Deno.build.os == "win",
name: "respond error handling",
async fn(): Promise<void> {
const connClosedPromise = deferred();

View file

@ -5,7 +5,7 @@ import { chmod, chmodSync } from "./_fs_chmod.ts";
test({
name: "ASYNC: Permissions are changed (non-Windows)",
skip: Deno.build.os === "win",
ignore: Deno.build.os === "win",
async fn() {
const tempFile: string = await Deno.makeTempFile();
const originalFileMode: number | null = (await Deno.lstat(tempFile)).mode;
@ -31,7 +31,7 @@ test({
test({
name: "SYNC: Permissions are changed (non-Windows)",
skip: Deno.build.os === "win",
ignore: Deno.build.os === "win",
fn() {
const tempFile: string = Deno.makeTempFileSync();
const originalFileMode: number | null = Deno.lstatSync(tempFile).mode;

View file

@ -4,10 +4,10 @@ import { fail, assertEquals } from "../../testing/asserts.ts";
import { chown, chownSync } from "./_fs_chown.ts";
//chown is difficult to test. Best we can do is set the existing user id/group id again
const skip = Deno.build.os == "win";
const ignore = Deno.build.os == "win";
test({
skip,
ignore,
name: "ASYNC: setting existing uid/gid works as expected (non-Windows)",
async fn() {
const tempFile: string = await Deno.makeTempFile();
@ -35,7 +35,7 @@ test({
});
test({
skip,
ignore,
name: "SYNC: setting existing uid/gid works as expected (non-Windows)",
fn() {
const tempFile: string = Deno.makeTempFileSync();

View file

@ -12,7 +12,7 @@ if (Deno.build.os !== "win") {
test({
name: "readlinkSuccess",
skip: Deno.build.os === "win",
ignore: Deno.build.os === "win",
async fn() {
const data = await new Promise((res, rej) => {
readlink(newname, (err, data) => {
@ -30,7 +30,7 @@ test({
test({
name: "readlinkEncodeBufferSuccess",
skip: Deno.build.os === "win",
ignore: Deno.build.os === "win",
async fn() {
const data = await new Promise((res, rej) => {
readlink(newname, { encoding: "buffer" }, (err, data) => {
@ -48,7 +48,7 @@ test({
test({
name: "readlinkSyncSuccess",
skip: Deno.build.os === "win",
ignore: Deno.build.os === "win",
fn() {
const data = readlinkSync(newname);
assertEquals(typeof data, "string");
@ -58,7 +58,7 @@ test({
test({
name: "readlinkEncodeBufferSuccess",
skip: Deno.build.os === "win",
ignore: Deno.build.os === "win",
fn() {
const data = readlinkSync(newname, { encoding: "buffer" });
assert(data instanceof Uint8Array);

View file

@ -19,7 +19,7 @@ function reader(s: string): TextProtoReader {
}
test({
skip: true,
ignore: true,
name: "[textproto] Reader : DotBytes",
async fn(): Promise<void> {
const _input =