From e89c84feb8ec7c749c9e4091568e2594c0062019 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Sep 25 2023 15:23:18 +0000 Subject: [PATCH 1/2] tests: fix logic to determine local MACRO_DIR This determines the path to the local macro directory relative to the test file's directory as opposed to the directory where pytest is executed from. --- diff --git a/tests/conftest.py b/tests/conftest.py index 7032c84..8f8e0b7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,9 +5,10 @@ from pathlib import Path import pytest -PARENT = Path.cwd() +HERE = Path(__file__).resolve().parent +ROOT = HERE.parent # e.g. MACRO_DIR=%{buildroot}%{_rpmmacrodir} %pytest -MACRO_DIR = Path(os.environ.get("MACRO_DIR") or PARENT.joinpath("macros.d")) +MACRO_DIR = Path(os.environ.get("MACRO_DIR") or ROOT.joinpath("macros.d")) @pytest.fixture(scope="session") From 0d95c82a3de704a644fdd1d0f964b20b372a7658 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Sep 25 2023 15:23:22 +0000 Subject: [PATCH 2/2] test_cargo_install: handle different %__awk definitions %__awk expands to `gawk` on Fedora 38 and `/usr/bin/awk` on Fedora 40. --- diff --git a/tests/test_macros_cargo.py b/tests/test_macros_cargo.py index bc59e7f..d3438e3 100644 --- a/tests/test_macros_cargo.py +++ b/tests/test_macros_cargo.py @@ -242,6 +242,8 @@ def test_cargo_install(evaluater): cargo_is_lib = evaluater("%__cargo_is_lib")[0] cargo_registry = evaluater("%cargo_registry")[0] cargo_to_rpm = evaluater("%__cargo_to_rpm")[0] + # awk is gawk on some systems and /usr/bin/awk on others. + awk = evaluater("%__awk")[0] assert [line.rstrip() for line in evaluater("%cargo_install")[0].splitlines()] == [ f"(", @@ -251,7 +253,7 @@ def test_cargo_install(evaluater): f" CRATE_VERSION=$({cargo_to_rpm} --path Cargo.toml version)", f" REG_DIR={buildroot}{cargo_registry}/$CRATE_NAME-$CRATE_VERSION", f" /usr/bin/mkdir -p $REG_DIR", - f" /usr/bin/awk -i inplace -v INPLACE_SUFFIX=.deps '/^\\[((.+\\.)?((dev|build)-)?dependencies|features)/{{f=1;next}} /^\\[/{{f=0}}; !f' Cargo.toml", + f" {awk} -i inplace -v INPLACE_SUFFIX=.deps '/^\\[((.+\\.)?((dev|build)-)?dependencies|features)/{{f=1;next}} /^\\[/{{f=0}}; !f' Cargo.toml", f" {cargo} package -l | grep -w -E -v 'Cargo.(lock|toml.orig)' | xargs -d '\\n' /usr/bin/cp --parents -a -t $REG_DIR", f" /usr/bin/mv Cargo.toml{{.deps,}}", f" /usr/bin/cp -a Cargo.toml $REG_DIR/Cargo.toml",