MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / processEnvironmentNewVar

Method processEnvironmentNewVar

Tests/Libraries/Process/ProcessTest.cpp:327–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325}
326
327void SC::ProcessTest::processEnvironmentNewVar()
328{
329 //! [ProcessEnvironmentNewVar]
330 Process process(commandArena.toSpan(), environmentArena.toSpan());
331 // This child process will inherit parent environment variables plus NewEnvVar
332 SC_TEST_EXPECT(process.setEnvironment("NewEnvVar", "SomeValue"));
333 String output;
334 // Spawn the child process writing all env variables as KEY=VALUE\n to stdout, redirected to output
335 SC_TEST_EXPECT(spawnChildAndPrintEnvironmentVars(process, output));
336 // We can check that the NewEnvVar has been set to SomeValue
337 StringView out = output.view();
338 SC_TEST_EXPECT(out.containsString("NewEnvVar=SomeValue"));
339 // PATH env var exists because we are inheriting environment
340 SC_TEST_EXPECT(out.containsString("PATH="));
341 //! [ProcessEnvironmentNewVar]
342}
343
344void SC::ProcessTest::processEnvironmentRedefineParentVar()
345{

Callers

nothing calls this directly

Calls 3

toSpanMethod · 0.80
setEnvironmentMethod · 0.80
viewMethod · 0.45

Tested by

no test coverage detected