-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5891 from clebergnu/runnable_recipe_schema
Signed-off-by: Jan Richter <[email protected]>
- Loading branch information
Showing
3 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://avocado-project.org/runnable-recipe.schema.json", | ||
"title": "runnable-recipe", | ||
"description": "Runnable serialized in a JSON based recipe file", | ||
"type": "object", | ||
"properties": { | ||
"kind": { | ||
"description": "The kind of runnable, which should be matched to a capable runner", | ||
"type": "string" | ||
}, | ||
"uri": { | ||
"description": "The main reference to what needs to be run. This is free form, but commonly set to the path to a file containing the test or being the test, or an actual URI with multiple parts", | ||
"type": "string" | ||
}, | ||
"args": { | ||
"description": "Sequence of arguments to be interpreted by the runner. For instance, exec-test turns these into positional command line arguments", | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"uniqueItems": false | ||
}, | ||
"kwargs": { | ||
"description": "Keyword based arguments, that is, a sequence of key and values. The exec-test, for instance, will turn these into environment variables", | ||
"type": "object" | ||
}, | ||
"config": { | ||
"description": "Avocado settings that should be applied to this runnable. At least the ones declared as CONFIGURATION_USED in the runner specific for this kind should be present", | ||
"type": "object" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required": [ "kind" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import glob | ||
import json | ||
import os | ||
|
||
from avocado import Test, skipUnless | ||
from selftests.utils import BASEDIR | ||
|
||
try: | ||
import jsonschema | ||
|
||
JSONSCHEMA_AVAILABLE = True | ||
except ImportError: | ||
JSONSCHEMA_AVAILABLE = False | ||
|
||
|
||
BASE_SCHEMA_DIR = os.path.join(BASEDIR, "contrib", "schemas") | ||
BASE_RECIPE_DIR = os.path.join(BASEDIR, "examples", "nrunner", "recipes") | ||
|
||
|
||
@skipUnless(JSONSCHEMA_AVAILABLE, "jsonschema module not available") | ||
class Schema(Test): | ||
def _test(self, schema_filename, recipe_path): | ||
schema_path = os.path.join(BASE_SCHEMA_DIR, schema_filename) | ||
with open(schema_path, "r", encoding="utf-8") as schema: | ||
with open(recipe_path, "r", encoding="utf-8") as recipe: | ||
try: | ||
jsonschema.validate(json.load(recipe), json.load(schema)) | ||
except jsonschema.exceptions.ValidationError as details: | ||
self.fail(details) | ||
|
||
def test_runnable_recipes(self): | ||
for recipe_path in glob.glob( | ||
os.path.join(BASE_RECIPE_DIR, "runnables", "*.json") | ||
): | ||
self._test("runnable-recipe.schema.json", recipe_path) |