[PATCH] D14278: Fix unit tests on Windows: handle env vars with non-ASCII chars.
Yaron Keren via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 3 06:09:21 PST 2015
yaron.keren added a comment.
I see the usage pattern is CopyEnvironment, push_back something, use std::vector<const char *> with ExecuteAndWait. For this you must have a consecutive vector of char * in memory, so someone will have to manage their lifetime. It's better not to leave this to the caller or split responsibility so you could objectize CopyEnvironment to do everything required:
class CopyEnvironment {
std::vector<const char *> env;
public:
CopyEnvironment() { copy environment into newly allocated copies, even on unix }
push_back() { env.push_back an allocated copy }
const char *get() { env.push_back(nullptr); return env[0]; }
~CopyEnvironment() { release memory }
};
so the usage pattern is
CopyEnvironment CE;
CE.push_back("LLVM_PROGRAM_TEST_LONG_PATH=1");
ExecuteAndWait(... CE.get()...);
this is not very efficient especially on Unix but for a unittest where CopyEnvironment runs just once per test it should not matter at all.
Repository:
rL LLVM
http://reviews.llvm.org/D14278
More information about the llvm-commits
mailing list