REGRESSION (r214553): Allow layout-tests to be run from Xcode without re-directing...
authorjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Apr 2017 19:07:33 +0000 (19:07 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Apr 2017 19:07:33 +0000 (19:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=170601
<rdar://problem/31492696>

Reviewed by Simon Fraser.

* TestRunnerShared/IOSLayoutTestCommunication.cpp:
(setUpIOSLayoutTestCommunication): Skip TCP setup if no port is in the environment.
(tearDownIOSLayoutTestCommunication): Only teardown if TCP was used.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215109 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/TestRunnerShared/IOSLayoutTestCommunication.cpp

index 72e0db9..3547265 100644 (file)
@@ -1,3 +1,15 @@
+2017-04-07  Jonathan Bedard  <jbedard@apple.com>
+
+        REGRESSION (r214553): Allow layout-tests to be run from Xcode without re-directing stdout, stdin and stderr
+        https://bugs.webkit.org/show_bug.cgi?id=170601
+        <rdar://problem/31492696>
+
+        Reviewed by Simon Fraser.
+
+        * TestRunnerShared/IOSLayoutTestCommunication.cpp:
+        (setUpIOSLayoutTestCommunication): Skip TCP setup if no port is in the environment.
+        (tearDownIOSLayoutTestCommunication): Only teardown if TCP was used.
+
 2017-04-07  Aakash Jain  <aakash_jain@apple.com>
 
         Add support for test262 JavaScriptCore tests
index 0a01ddf..bc312bf 100644 (file)
@@ -36,6 +36,7 @@
 static int stdinSocket;
 static int stdoutSocket;
 static int stderrSocket;
+static bool isUsingTCP = false;
 
 static int connectToServer(sockaddr_in& serverAddress)
 {
@@ -47,8 +48,12 @@ static int connectToServer(sockaddr_in& serverAddress)
 
 void setUpIOSLayoutTestCommunication()
 {
-    int port = atoi(getenv("PORT"));
+    char* portFromEnvironment = getenv("PORT");
+    if (!portFromEnvironment)
+        return;
+    int port = atoi(portFromEnvironment);
     RELEASE_ASSERT(port > 0);
+    isUsingTCP = true;
 
     struct hostent* host = gethostbyname("127.0.0.1");
     struct sockaddr_in serverAddress;
@@ -73,6 +78,8 @@ void setUpIOSLayoutTestCommunication()
 
 void tearDownIOSLayoutTestCommunication()
 {
+    if (!isUsingTCP)
+        return;
     close(stdinSocket);
     close(stdoutSocket);
     close(stderrSocket);