icestorm: add examples as integration tests

This commit is contained in:
Max Wipfli
2025-08-05 13:32:47 +02:00
parent 61b00afc45
commit bffa59d5bc
2 changed files with 40 additions and 5 deletions
+11 -5
View File
@@ -1,6 +1,7 @@
{
lib,
stdenv,
callPackage,
fetchFromGitHub,
pkg-config,
libftdi1,
@@ -18,13 +19,18 @@
usePyPy ? stdenv.hostPlatform.system == "x86_64-linux",
}:
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "icestorm";
version = "0-unstable-2025-06-03";
passthru = rec {
pythonPkg = if (false && usePyPy) then pypy3 else python3;
pythonInterp = pythonPkg.interpreter;
tests.examples = callPackage ./tests.nix {
inherit (finalAttrs) pname src;
icestorm = finalAttrs.finalPackage;
};
};
src = fetchFromGitHub {
@@ -36,12 +42,12 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ pkg-config ];
buildInputs = [
passthru.pythonPkg
finalAttrs.passthru.pythonPkg
libftdi1
];
makeFlags = [
"PREFIX=$(out)"
"PYTHON3=${passthru.pythonInterp}"
"PYTHON3=${finalAttrs.passthru.pythonInterp}"
];
enableParallelBuilding = true;
@@ -51,7 +57,7 @@ stdenv.mkDerivation rec {
patchPhase = ''
for x in $(find . -type f -iname '*.py' -executable); do
substituteInPlace "$x" \
--replace-fail '/usr/bin/env python3' '${passthru.pythonInterp}'
--replace-fail '/usr/bin/env python3' '${finalAttrs.passthru.pythonInterp}'
done
# We use GNU sed on Darwin, while icebox/Makefile assumed BSD sed (which
@@ -75,4 +81,4 @@ stdenv.mkDerivation rec {
];
platforms = lib.platforms.all;
};
}
})
+29
View File
@@ -0,0 +1,29 @@
# Run the examples from $src/examples/ as simple integration tests. They require
# yosys and nextpnr (which itself depends on this package), so they cannot be
# ran during the check phase.
{
runCommand,
icestorm,
nextpnr,
yosys,
pname,
src,
}:
runCommand "${pname}-test-examples"
{
nativeBuildInputs = [
icestorm
nextpnr
yosys
];
}
''
cp -r ${src}/examples .
chmod -R +w examples
for example in examples/*; do
make -C $example
done
touch $out
''