commit dee58f7148491d562790db2b0702aa611ed2c218
parent d92411b8e40a9db9ed38dc310df80cbba40db003
Author: triesap <tyson@radroots.org>
Date: Fri, 10 Apr 2026 15:12:43 +0000
tests: make repo-local contract lane self-contained
- self-seed repo-local env inside the mounted process proof
- keep src/main.mojo exercised under the real repo_local profile
- remove the parent-process env requirement from the standalone pixi lane
- preserve fail-closed runtime semantics outside test-owned setup
Diffstat:
1 file changed, 53 insertions(+), 57 deletions(-)
diff --git a/tests/test_repo_local_process_contract.mojo b/tests/test_repo_local_process_contract.mojo
@@ -1,21 +1,16 @@
-import std.os
from std.testing import TestSuite, assert_equal, assert_true
+from std.tempfile import TemporaryDirectory
from mojson import Value
from fixture_assertions import load_scenario_request_json
from stdio_process_helper import (
HYF_PATHS_PROFILE_ENV,
HYF_PATHS_REPO_LOCAL_ROOT_ENV,
+ ScopedEnvVar,
run_stdio_entrypoint,
)
-def _required_env(name: String) raises -> String:
- var value = std.os.getenv(name)
- assert_true(value != "")
- return value^
-
-
def _assert_under_repo_local_root(repo_local_root: String, path: String) raises:
assert_true(path.startswith(repo_local_root + "/"))
@@ -29,58 +24,59 @@ def _assert_runtime_status_path_under_repo_local_root(
)
-def test_src_main_consumes_root_wrapper_repo_local_env() raises:
- var paths_profile = _required_env(HYF_PATHS_PROFILE_ENV)
- var repo_local_root = _required_env(HYF_PATHS_REPO_LOCAL_ROOT_ENV)
- assert_equal(paths_profile, "repo_local")
+def test_src_main_consumes_repo_local_env_without_outer_wrapper() raises:
+ with TemporaryDirectory() as repo_local_root:
+ with ScopedEnvVar(HYF_PATHS_PROFILE_ENV, "repo_local"):
+ with ScopedEnvVar(HYF_PATHS_REPO_LOCAL_ROOT_ENV, repo_local_root):
+ var response = run_stdio_entrypoint(
+ "src/main.mojo",
+ load_scenario_request_json("scenarios/status_ok.json"),
+ )
- var response = run_stdio_entrypoint(
- "src/main.mojo",
- load_scenario_request_json("scenarios/status_ok.json"),
- )
-
- var runtime_status = response["output"]["runtime"].clone()
- assert_equal(runtime_status["paths_profile"].string_value(), "repo_local")
- assert_equal(
- runtime_status["repo_local_base_root"].string_value(),
- repo_local_root,
- )
+ var runtime_status = response["output"]["runtime"].clone()
+ assert_equal(
+ runtime_status["paths_profile"].string_value(), "repo_local"
+ )
+ assert_equal(
+ runtime_status["repo_local_base_root"].string_value(),
+ repo_local_root,
+ )
- _assert_runtime_status_path_under_repo_local_root(
- runtime_status, "config_dir", repo_local_root
- )
- _assert_runtime_status_path_under_repo_local_root(
- runtime_status, "config_path", repo_local_root
- )
- _assert_runtime_status_path_under_repo_local_root(
- runtime_status, "data_dir", repo_local_root
- )
- _assert_runtime_status_path_under_repo_local_root(
- runtime_status, "cache_dir", repo_local_root
- )
- _assert_runtime_status_path_under_repo_local_root(
- runtime_status, "logs_dir", repo_local_root
- )
- _assert_runtime_status_path_under_repo_local_root(
- runtime_status, "diagnostics_dir", repo_local_root
- )
- _assert_runtime_status_path_under_repo_local_root(
- runtime_status, "run_dir", repo_local_root
- )
- _assert_runtime_status_path_under_repo_local_root(
- runtime_status, "secrets_dir", repo_local_root
- )
- _assert_runtime_status_path_under_repo_local_root(
- runtime_status, "identity_path", repo_local_root
- )
- _assert_under_repo_local_root(
- repo_local_root,
- runtime_status["config"]["artifact_path"].string_value(),
- )
- assert_equal(
- runtime_status["config"]["artifact_path_source"].string_value(),
- "canonical_runtime_path",
- )
+ _assert_runtime_status_path_under_repo_local_root(
+ runtime_status, "config_dir", repo_local_root
+ )
+ _assert_runtime_status_path_under_repo_local_root(
+ runtime_status, "config_path", repo_local_root
+ )
+ _assert_runtime_status_path_under_repo_local_root(
+ runtime_status, "data_dir", repo_local_root
+ )
+ _assert_runtime_status_path_under_repo_local_root(
+ runtime_status, "cache_dir", repo_local_root
+ )
+ _assert_runtime_status_path_under_repo_local_root(
+ runtime_status, "logs_dir", repo_local_root
+ )
+ _assert_runtime_status_path_under_repo_local_root(
+ runtime_status, "diagnostics_dir", repo_local_root
+ )
+ _assert_runtime_status_path_under_repo_local_root(
+ runtime_status, "run_dir", repo_local_root
+ )
+ _assert_runtime_status_path_under_repo_local_root(
+ runtime_status, "secrets_dir", repo_local_root
+ )
+ _assert_runtime_status_path_under_repo_local_root(
+ runtime_status, "identity_path", repo_local_root
+ )
+ _assert_under_repo_local_root(
+ repo_local_root,
+ runtime_status["config"]["artifact_path"].string_value(),
+ )
+ assert_equal(
+ runtime_status["config"]["artifact_path_source"].string_value(),
+ "canonical_runtime_path",
+ )
def main() raises: