diff --git a/tests/.pcvs/profile/default.yml b/tests/.pcvs/profile/default.yml new file mode 100644 index 0000000000000000000000000000000000000000..9d750043f637b835e1c3e44d4e0a7616447c7590 --- /dev/null +++ b/tests/.pcvs/profile/default.yml @@ -0,0 +1,3 @@ +compiler: + commands: {cc: clang} +machine: {concurrent_run: 4, cores_per_node: 4, name: localhost, nodes: 4} diff --git a/tests/invalid/data1.vvs b/tests/invalid/data1.vvs new file mode 100644 index 0000000000000000000000000000000000000000..2a971b1f9e36472fb99b53ad69ea18b0b1d29eb4 --- /dev/null +++ b/tests/invalid/data1.vvs @@ -0,0 +1,3 @@ +-- vim: ft=lua +-- Invalid: data not specified (default value + the type) +data "syllabe:toto" diff --git a/tests/invalid/data2.vvs b/tests/invalid/data2.vvs new file mode 100644 index 0000000000000000000000000000000000000000..e4cd0cbffe21da3d7325afc00b64a8a77c401894 --- /dev/null +++ b/tests/invalid/data2.vvs @@ -0,0 +1,3 @@ +-- vim: ft=lua +-- Invalid: incorrect ASS type +data "syllabes:toto" { type = "number", default = 500 } diff --git a/tests/micro/main1.vvs b/tests/micro/main1.vvs new file mode 100644 index 0000000000000000000000000000000000000000..f294c4b876d9bd257b30f46ce937c4de910d5090 --- /dev/null +++ b/tests/micro/main1.vvs @@ -0,0 +1,2 @@ +-- vim: ft=lua +main { "INIT" } diff --git a/tests/micro/main2.vvs b/tests/micro/main2.vvs new file mode 100644 index 0000000000000000000000000000000000000000..f294c4b876d9bd257b30f46ce937c4de910d5090 --- /dev/null +++ b/tests/micro/main2.vvs @@ -0,0 +1,2 @@ +-- vim: ft=lua +main { "INIT" } diff --git a/tests/pcvs.inc.yml b/tests/pcvs.inc.yml new file mode 100644 index 0000000000000000000000000000000000000000..62f502d5285e653b71e49b372b9d4503e143c508 --- /dev/null +++ b/tests/pcvs.inc.yml @@ -0,0 +1,4 @@ +compiles: { build: { files: '@SRCPATH@/Makefile', make: { target: 'build' } } } +utests: { build: { files: '@SRCPATH@/Makefile', make: { target: 'utests' }, depends_on: [ "compiles" ] } } +documentation: { build: { files: '@SRCPATH@/Makefile', make: { target: 'doc' }, depends_on: [ "compiles" ] } } + diff --git a/tests/pcvs.setup b/tests/pcvs.setup new file mode 100755 index 0000000000000000000000000000000000000000..c8ec8730f0db94974c0877277f1b1d8608e44000 --- /dev/null +++ b/tests/pcvs.setup @@ -0,0 +1,96 @@ +#!/usr/bin/env python + +from pathlib import Path +import subprocess +import textwrap +import shutil +import json +import os + +pcvs_src = os.getenv("pcvs_src") +rust_src = f"{pcvs_src}/../src/Rust" +cargo_bin = shutil.which("cargo") + +def read_src_folder(folder): + src = [] + for file in os.listdir(f"{pcvs_src}/{folder}"): + (name, ext) = os.path.splitext(file) + toml_file = f"{pcvs_src}/{folder}/{name}.toml" + toml_isok = os.path.exists(toml_file) and os.path.isfile(toml_file) + if ext == ".vvs": + src.append({ + "name": name, + "file": file, + "opts": toml_file, + } if toml_isok else { + "name": name, + "file": file, + }) + return src + +def assert_executable(path, name): + if path is None: + raise Exception(f"the {name} executable was not found") + +######################################## +# Get the target dir & the executables # +######################################## + +for cargo_msg_line in subprocess.run( + ["cargo", "build", "--message-format=json-render-diagnostics"], + stdout=subprocess.PIPE, + cwd=rust_src, + text=True, + ).stdout.split('\n'): + msg = json.loads(cargo_msg_line) + if msg["reason"] != "compiler-artifact" or msg["target"]["name"] != "vvcc": + continue + elif vvcc_bin := msg["executable"]: + break + +assert_executable(vvcc_bin, "vvcc") +assert_executable(cargo_bin, "cargo") + +################## +# Generate tests # +################## + +with open(f"{pcvs_src}/pcvs.inc.yml", mode='r') as file: + print(file.read()) + +print(textwrap.dedent(f"""\ +help_long: + run: + program: '{vvcc_bin} --help' + depends_on: [ "compiles", "utests" ] + cwd: '@SRCPATH@' +help_short: + run: + program: '{vvcc_bin} -h' + depends_on: [ "compiles", "utests" ] + cwd: '@SRCPATH@' +""")) + +for micro in read_src_folder("micro"): + name, file, opts = micro["name"], micro["file"], micro.get("opts", "") + print(textwrap.dedent(f"""\ + micro_ok_{name}: + run: + program: '{vvcc_bin} -P {file} {opts}' + depends_on: [ "compiles", "utests" ] + cwd: '@SRCPATH@/micro' + """)) + +for ack in read_src_folder("invalid"): + name, file, opts = ack["name"], ack["file"], ack.get("opts", "") + print(textwrap.dedent(f"""\ + micro_ack_{name}: + run: + program: '{vvcc_bin} -P {file} {opts}' + depends_on: [ "compiles", "utests" ] + cwd: '@SRCPATH@/micro' + validate: + expect_exit: 1 + """)) + +# vim: ft=python