From db3b3fb665bba7a063e038907efbc0a14d863d63 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 20 Apr 2024 18:47:10 -0400 Subject: [PATCH] chore: auto-complete for __spec__.jsonc file (#23476) This makes writing these tests a little easier. --- tests/specs/README.md | 19 ++++++++- tests/specs/schema.json | 90 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 tests/specs/schema.json diff --git a/tests/specs/README.md b/tests/specs/README.md index a23fa1ce6f..d9c620aa71 100644 --- a/tests/specs/README.md +++ b/tests/specs/README.md @@ -76,9 +76,26 @@ a "steps" array. - `args` - A string (that will be spilt on whitespace into an args array) or an array of arguments. - `output` - Path to use to assert the output. -- `clean` (boolean) - Whether to empty the deno_dir before running the step. +- `cleanDenoDir` (boolean) - Whether to empty the deno_dir before running the + step. - `exitCode` (number) - Expected exit code. +### Auto-complete + +To get auto-complete for these files, add the following to a local +`.vscode/settings.json` file: + +```json +{ + "json.schemas": [{ + "fileMatch": [ + "__test__.jsonc" + ], + "url": "./tests/specs/schema.json" + }] +} +``` + ## `.out` files `.out` files are used to assert the output when running a test or test step. diff --git a/tests/specs/schema.json b/tests/specs/schema.json new file mode 100644 index 0000000000..8b21ab32ce --- /dev/null +++ b/tests/specs/schema.json @@ -0,0 +1,90 @@ +{ + "$id": "https://github.com/denoland/deno/blob/tests/specs/schema.json", + "$schema": "http://json-schema.org/draft-07/schema", + "description": "Schema file for the __test__.jsonc files", + "required": [], + "title": "Deno internal spec test schema", + "type": "object", + "definitions": { + "single_test": { + "type": "object", + "required": ["args", "output"], + "properties": { + "args": { + "default": "", + "oneOf": [{ + "type": "string" + }, { + "type": "array", + "items": { + "type": "string" + } + }] + }, + "cleanDenoDir": { + "type": "boolean" + }, + "cwd": { + "type": "string" + }, + "commandName": { + "type": "string" + }, + "envs": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "output": { + "type": "string" + }, + "exitCode": { + "type": "integer" + } + } + } + }, + "oneOf": [{ + "required": ["steps"], + "properties": { + "tempDir": { + "type": "boolean" + }, + "base": { + "type": "string" + }, + "envs": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "steps": { + "type": "array", + "items": { + "$ref": "#/definitions/single_test" + } + } + } + }, { + "allOf": [{ + "properties": { + "tempDir": { + "type": "boolean" + }, + "base": { + "type": "string" + }, + "envs": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, { + "$ref": "#/definitions/single_test" + }] + }] +}