Skip to content
Extraits de code Groupes Projets
Vérifiée Valider dc3dad9e rédigé par Kubat's avatar Kubat
Parcourir les fichiers

VVS: Add tests

parent e2ea107d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!31Draft: VivyScript V4
Pipeline #3746 en échec
compiler:
commands: {cc: clang}
machine: {concurrent_run: 4, cores_per_node: 4, name: localhost, nodes: 4}
-- vim: ft=lua
-- Invalid: data not specified (default value + the type)
data "syllabe:toto"
-- vim: ft=lua
-- Invalid: incorrect ASS type
data "syllabes:toto" { type = "number", default = 500 }
-- vim: ft=lua
main { "INIT" }
-- vim: ft=lua
main { "INIT" }
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" ] } }
#!/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
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter