From dce253ee01952450dc59f19a67a5301022f0d7e7 Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Wed, 13 Mar 2024 22:03:42 -0700 Subject: [PATCH] burn it all Change-Id: I0db6eee7d6aae3e02ea0155c04a55a7142e456c3 --- tests/functional/local.mk | 4 +++- tests/functional/repl_characterization/local.mk | 6 +----- .../repl_characterization/repl_characterization.cc | 5 ++++- tests/functional/repl_characterization/test-session.cc | 3 ++- tests/functional/test-repl-characterization.sh | 3 +++ 5 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 tests/functional/test-repl-characterization.sh diff --git a/tests/functional/local.mk b/tests/functional/local.mk index 39ea405a2..417c78509 100644 --- a/tests/functional/local.mk +++ b/tests/functional/local.mk @@ -131,7 +131,7 @@ ifeq ($(HAVE_LIBCPUID), 1) endif ifeq ($(ENABLE_BUILD), yes) - nix_tests += test-libstoreconsumer.sh + nix_tests += test-libstoreconsumer.sh test-repl-characterization.sh ifeq ($(BUILD_SHARED_LIBS), 1) nix_tests += plugins.sh @@ -143,6 +143,8 @@ $(d)/test-libstoreconsumer.sh.test $(d)/test-libstoreconsumer.sh.test-debug: \ $(d)/plugins.sh.test $(d)/plugins.sh.test-debug: \ $(buildprefix)$(d)/plugins/libplugintest.$(SO_EXT) \ $(buildprefix)$(d)/plugins/libplugintestfail.$(SO_EXT) +$(d)/test-repl-characterization.sh.test $(d)/test-repl-characterization.sh.test-debug: \ + $(buildprefix)$(d)/repl_characterization/test-repl-characterization install-tests += $(foreach x, $(nix_tests), $(d)/$(x)) diff --git a/tests/functional/repl_characterization/local.mk b/tests/functional/repl_characterization/local.mk index 6eacb96d0..aa0cf3615 100644 --- a/tests/functional/repl_characterization/local.mk +++ b/tests/functional/repl_characterization/local.mk @@ -1,18 +1,14 @@ programs += test-repl-characterization -installcheck: test-repl-characterization_RUN - test-repl-characterization_DIR := $(d) -test-repl-characterization_ENV := _NIX_TEST_UNIT_DATA=$(shell realpath "$(d)")/data - # do not install test-repl-characterization_INSTALL_DIR := test-repl-characterization_SOURCES := \ $(wildcard $(d)/*.cc) \ -test-repl-characterization_CXXFLAGS += -I src/libutil -I tests/unit/libutil-support +test-repl-characterization_CXXFLAGS += -I src/libutil -I tests/unit/libutil-support -DNIX_BIN_DIR="\"$(bindir)\"" test-repl-characterization_LIBS = libutil libutil-test-support diff --git a/tests/functional/repl_characterization/repl_characterization.cc b/tests/functional/repl_characterization/repl_characterization.cc index 5ba034869..162777d60 100644 --- a/tests/functional/repl_characterization/repl_characterization.cc +++ b/tests/functional/repl_characterization/repl_characterization.cc @@ -1,3 +1,4 @@ +#include #include #include @@ -47,8 +48,10 @@ public: Strings args{"--quiet", "repl", "--quiet", "--extra-experimental-features", "repl-automation"}; args.insert(args.end(), extraArgs.begin(), extraArgs.end()); + auto nixBin = canonPath(getEnvNonEmpty("NIX_BIN_DIR").value_or(NIX_BIN_DIR)); + // TODO: why the fuck does this need two --quiets - auto process = RunningProcess::start("nix", args); + auto process = RunningProcess::start(nixBin + "/nix", args); auto session = TestSession{AUTOMATION_PROMPT, std::move(process)}; for (auto & bit : syntax) { diff --git a/tests/functional/repl_characterization/test-session.cc b/tests/functional/repl_characterization/test-session.cc index e4532a5b7..64d0eaee1 100644 --- a/tests/functional/repl_characterization/test-session.cc +++ b/tests/functional/repl_characterization/test-session.cc @@ -1,4 +1,5 @@ #include +#include #include "test-session.hh" #include "util.hh" @@ -28,7 +29,7 @@ RunningProcess RunningProcess::start(std::string executable, Strings args) procStdout.readSide.close(); if (dup2(STDOUT_FILENO, STDERR_FILENO) == -1) throw SysError("dupping stderr"); - execvp(executable.c_str(), stringsToCharPtrs(args).data()); + execve(executable.c_str(), stringsToCharPtrs(args).data(), environ); throw SysError("exec did not happen"); }); diff --git a/tests/functional/test-repl-characterization.sh b/tests/functional/test-repl-characterization.sh new file mode 100644 index 000000000..cd6368add --- /dev/null +++ b/tests/functional/test-repl-characterization.sh @@ -0,0 +1,3 @@ +source common.sh + +_NIX_TEST_UNIT_DATA=$(pwd)/repl_characterization/data ./repl_characterization/test-repl-characterization