Skip to content

Commit a7859c5

Browse files
committed
Process: Improve ProcessTest compatibility
1 parent b2e3cef commit a7859c5

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

Libraries/Process/Internal/ProcessPosix.inl

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -333,21 +333,3 @@ bool SC::ProcessEnvironment::get(size_t index, StringView& name, StringView& val
333333
}
334334
return true;
335335
}
336-
337-
bool SC::ProcessEnvironment::contains(StringView variableName, size_t* index)
338-
{
339-
for (size_t idx = 0; idx < numberOfEnvironment; ++idx)
340-
{
341-
StringView name, value;
342-
SC_TRY(get(idx, name, value));
343-
if (name == variableName)
344-
{
345-
if (index != nullptr)
346-
{
347-
*index = idx;
348-
}
349-
return true;
350-
}
351-
}
352-
return false;
353-
}

Libraries/Process/Process.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,25 @@ SC::Result SC::Process::setEnvironment(StringView name, StringView value)
234234
StringsArena table = {environment, environmentNumber, environmentByteOffset};
235235
return table.appendAsSingleString({name, SC_NATIVE_STR("="), value});
236236
}
237+
238+
//-------------------------------------------------------------------------------------------------------
239+
// ProcessEnvironment
240+
//-------------------------------------------------------------------------------------------------------
241+
242+
bool SC::ProcessEnvironment::contains(StringView variableName, size_t* index)
243+
{
244+
for (size_t idx = 0; idx < numberOfEnvironment; ++idx)
245+
{
246+
StringView name, value;
247+
SC_TRY(get(idx, name, value));
248+
if (name == variableName)
249+
{
250+
if (index != nullptr)
251+
{
252+
*index = idx;
253+
}
254+
return true;
255+
}
256+
}
257+
return false;
258+
}

Libraries/Process/Tests/ProcessTest.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void SC::ProcessTest::processInheritStdout()
109109
}
110110
break;
111111
default: { // Posix
112-
SC_TEST_EXPECT(Process().exec({"which", "sudo"}));
112+
SC_TEST_EXPECT(Process().exec({"which", "su"}));
113113
}
114114
break;
115115
}
@@ -127,7 +127,7 @@ void SC::ProcessTest::processIgnoreStdout()
127127
}
128128
break;
129129
default: { // Posix
130-
SC_TEST_EXPECT(Process().exec({"which", "sudo"}, Process::StdOut::Ignore()));
130+
SC_TEST_EXPECT(Process().exec({"which", "su"}, Process::StdOut::Ignore()));
131131
}
132132
break;
133133
}
@@ -146,8 +146,8 @@ void SC::ProcessTest::processRedirectStdout()
146146
}
147147
break;
148148
default: { // Posix
149-
SC_TEST_EXPECT(Process().exec({"which", "sudo"}, output));
150-
SC_TEST_EXPECT(output.view() == "/usr/bin/sudo\n");
149+
SC_TEST_EXPECT(Process().exec({"which", "su"}, output));
150+
SC_TEST_EXPECT(output.view() == "/bin/su\n" or output.view() == "/usr/bin/su\n");
151151
}
152152
break;
153153
}

0 commit comments

Comments
 (0)