On Windows we have to take UTF16 encoded env vars and convert them to UTF8. This patch fixes CopyEnvironment helper function used by process unit tests.
Details
Details
Diff Detail
Diff Detail
Event Timeline
unittests/Support/ProgramTest.cpp | ||
---|---|---|
64 | Will this unit test never run multithreaded? |
unittests/Support/ProgramTest.cpp | ||
---|---|---|
64 | That is the weak point. What do you think about extracting storage as a function argument? |
Comment Actions
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.
Will this unit test never run multithreaded?