Skip to content

Commit

Permalink
add TestStamp builder
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisnc committed Nov 20, 2022
1 parent 69f2bfd commit a9dc94c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 31 deletions.
23 changes: 23 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import platform
import subprocess

import SCons.Errors

Expand Down Expand Up @@ -168,6 +169,28 @@ else:
if "TERM" in os.environ:
env["ENV"]["TERM"] = os.environ["TERM"]


def test_stamp(target, source, env):
try:
subprocess.run([source[0].path]).check_returncode()
except subprocess.CalledProcessError as e:
raise SCons.Errors.BuildError(
errstr=f"test failed with exit code {e.returncode}"
)
with open(target[0].path, "w") as f:
pass


env.Append(
BUILDERS={
"TestStamp": SCons.Builder.Builder(
action=test_stamp,
suffix=".stamp",
src_builder="Program",
)
}
)

if "host" in targets:

if platform.system() != "Windows":
Expand Down
19 changes: 1 addition & 18 deletions hydro/test/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,4 @@

Import("env")

import SCons.Errors

import subprocess


def test_and_stamp(target, source, env):
try:
subprocess.run([source[0].path]).check_returncode()
except subprocess.CalledProcessError as e:
raise SCons.Errors.BuildError(
errstr=f"test failed with exit code {e.returncode}"
)
with open(target[0].path, "w") as f:
pass


test_hydro = env.Program("test_hydro.c")
env.Command(target="test_hydro.stamp", source=test_hydro, action=test_and_stamp)
env.TestStamp("test_hydro.c")
14 changes: 1 addition & 13 deletions test/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Import("env")

import SCons.Errors

import subprocess
from difflib import unified_diff


Expand Down Expand Up @@ -35,20 +34,9 @@ test_kat("test_lwc_hash_kat", "LWC_HASH_KAT_256.txt")
test_kat("test_lwc_aead_kat", "LWC_AEAD_KAT_256_128.txt")


def test_and_stamp(target, source, env):
try:
subprocess.run([source[0].path]).check_returncode()
except subprocess.CalledProcessError as e:
raise SCons.Errors.BuildError(
errstr=f"test failed with exit code {e.returncode}"
)
with open(target[0].path, "w") as f:
pass


def test(name, extra_sources=[]):
prog = env.Program(target=name, source=[name + ".c"] + extra_sources)
env.Command(target=name + ".stamp", source=prog, action=test_and_stamp)
env.TestStamp(prog)


env_ed25519 = env.Clone()
Expand Down

0 comments on commit a9dc94c

Please sign in to comment.