From 1ae82193f0b040b91c1aea4a19137797b2740f1d Mon Sep 17 00:00:00 2001 From: Leonid Shalupov Date: Sun, 14 Feb 2016 16:34:39 +0100 Subject: [PATCH] tests: do not remove %SYSTEMROOT% from environment variables, it's required to initialize crypto provider (which is required for std::rand) --- tests/common/util.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/common/util.rs b/tests/common/util.rs index 113e56b49..cf84a1abf 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -282,7 +282,19 @@ impl UCommand { let mut cmd = Command::new(arg.as_ref()); cmd.current_dir(curdir.as_ref()); if env_clear { - cmd.env_clear(); + if cfg!(windows) { + // %SYSTEMROOT% is required on Windows to initialize crypto provider + // ... and crypto provider is required for std::rand + // From procmon: RegQueryValue HKLM\SOFTWARE\Microsoft\Cryptography\Defaults\Provider\Microsoft Strong Cryptographic Provider\Image Path + // SUCCESS Type: REG_SZ, Length: 66, Data: %SystemRoot%\system32\rsaenh.dll" + for (key, _) in env::vars_os() { + if key.as_os_str() != "SYSTEMROOT" { + cmd.env_remove(key); + } + } + } else { + cmd.env_clear(); + } } cmd },