From 13e3d8b87e46c9d24007f4c2284e5c0c1f3f1fcf Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Tue, 15 Nov 2022 13:35:23 +0100 Subject: [PATCH] pve: build test stub of Proxmox::Lib::PVE for tests this replaces the libdirs() sub with one containing: - ../target (for when run from build/pve-rs) - ../../target (for when run from toplevel/pve-rs This way we can run 'make check' both from within `pve-rs` as well as from the package building process. Signed-off-by: Wolfgang Bumiller --- pve-rs/Makefile | 10 ++++++++++ pve-rs/test/Makefile | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/pve-rs/Makefile b/pve-rs/Makefile index 68ff6dc..e452772 100644 --- a/pve-rs/Makefile +++ b/pve-rs/Makefile @@ -20,11 +20,18 @@ PM_DIR := PVE ifeq ($(BUILD_MODE), release) CARGO_BUILD_ARGS += --release +TARGET_DIR=release +else +TARGET_DIR=debug endif all: PVE Proxmox/Lib/PVE.pm ifneq ($(BUILD_MODE), skip) cargo build $(CARGO_BUILD_ARGS) + mkdir -p test/Proxmox/Lib + sed -r -e \ + 's@^sub libdirs.*$$@sub libdirs { return ("../target/$(TARGET_DIR)", "../../target/$(TARGET_DIR)"); }@' \ + Proxmox/Lib/PVE.pm >test/Proxmox/Lib/PVE.pm endif PVE: ../scripts/genpackage.pl @@ -38,6 +45,9 @@ Proxmox/Lib/PVE.pm: ../Proxmox/Lib/template.pm mkdir -p Proxmox/Lib $(call package_template,PVE,pve_rs,../) +check: all + $(MAKE) -C test test + # always re-create this dir # but also copy the local target/ and PVE/ dirs as a build-cache .PHONY: build diff --git a/pve-rs/test/Makefile b/pve-rs/test/Makefile index dc0a5bd..29dc955 100644 --- a/pve-rs/test/Makefile +++ b/pve-rs/test/Makefile @@ -1,4 +1,9 @@ .PHONY: test -test: +test: Proxmox/Lib/PVE.pm @echo "-- running pve-rs tests --" - ./resource_scheduling.pl + perl -I. -I.. -I../.. ./resource_scheduling.pl + +# The test stub, we don't know where to look for the library from in here! +Proxmox/Lib/PVE.pm: + @echo "run 'make' in the pve-rs/ dir first" + @exit 1