Fix incorrect 'test' statement in unit test
authorChip Turner <chip@fb.com>
Tue, 23 Dec 2014 18:40:17 +0000 (10:40 -0800)
committerDave Watson <davejwatson@fb.com>
Mon, 29 Dec 2014 18:40:18 +0000 (10:40 -0800)
Summary:
The 'test' command uses one equal sign for string equality, not
two.  bash apparently is okay with two, but zsh isn't, causing this test
to pass if your shell was bash and fail if it was zsh.  The test now
passes with bash, bash in sh mode, zsh, and even dash.

Test Plan:
runtests, also, these pass (zsh failed before):

SHELL=/bin/bash _build/dbg/folly/test/subprocess_test
SHELL=/bin/sh _build/dbg/folly/test/subprocess_test
SHELL=/bin/zsh _build/dbg/folly/test/subprocess_test
SHELL=/bin/dash _build/dbg/folly/test/subprocess_test

Reviewed By: njormrod@fb.com

Subscribers: lins, anca, folly-diffs@

FB internal diff: D1756090

Signature: t1:1756090:1419360674:8576e61a6e0ee102612c5eae0e1fbd79cc397bfa

folly/test/SubprocessTest.cpp

index 452b8626bb86101daa93ba0655816b57dc1a0b5a..d883c765fc39d21b21d13ecf7c98c33a4ce4ba77 100644 (file)
@@ -257,7 +257,7 @@ TEST(CommunicateSubprocessTest, Duplex) {
 }
 
 TEST(CommunicateSubprocessTest, ProcessGroupLeader) {
-  const auto testIsLeader = "test $(cut -d ' ' -f 5 /proc/$$/stat) == $$";
+  const auto testIsLeader = "test $(cut -d ' ' -f 5 /proc/$$/stat) = $$";
   Subprocess nonLeader(testIsLeader);
   EXPECT_THROW(nonLeader.waitChecked(), CalledProcessError);
   Subprocess leader(testIsLeader, Subprocess::Options().processGroupLeader());