mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] andschwa closed pull request #289: Fixtestflags
Date Mon, 27 Aug 2018 18:04:02 GMT
andschwa closed pull request #289: Fixtestflags
URL: https://github.com/apache/mesos/pull/289
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/3rdparty/libprocess/src/tests/CMakeLists.txt b/3rdparty/libprocess/src/tests/CMakeLists.txt
index 1b2d75d2b5..8c1353b442 100644
--- a/3rdparty/libprocess/src/tests/CMakeLists.txt
+++ b/3rdparty/libprocess/src/tests/CMakeLists.txt
@@ -87,14 +87,25 @@ target_link_libraries(libprocess-tests PRIVATE process-interface)
 # NOTE: This is for the generated gRPC headers.
 target_include_directories(libprocess-tests PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
 
-target_compile_definitions(
-  libprocess-tests PRIVATE
-  BUILD_DIR="${CMAKE_CURRENT_BINARY_DIR}")
+if (CMAKE_GENERATOR MATCHES "Visual Studio")
+  target_compile_definitions(
+    libprocess-tests PRIVATE
+    BUILD_DIR="${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>")
+else ()
+  target_compile_definitions(
+    libprocess-tests PRIVATE
+    BUILD_DIR="${CMAKE_CURRENT_BINARY_DIR}")
+endif ()
 
 add_executable(test-linkee EXCLUDE_FROM_ALL test_linkee.cpp)
 target_link_libraries(test-linkee PRIVATE process-interface)
 add_dependencies(libprocess-tests test-linkee)
 
+if (WIN32)
+  add_executable(test-echo EXCLUDE_FROM_ALL test_echo.cpp)
+  add_dependencies(libprocess-tests test-echo)
+endif ()
+
 if (ENABLE_SSL)
   add_executable(ssl-client EXCLUDE_FROM_ALL ssl_client.cpp)
   target_link_libraries(ssl-client PRIVATE process-interface)
diff --git a/3rdparty/libprocess/src/tests/subprocess_tests.cpp b/3rdparty/libprocess/src/tests/subprocess_tests.cpp
index 269918e7f7..2127429e44 100644
--- a/3rdparty/libprocess/src/tests/subprocess_tests.cpp
+++ b/3rdparty/libprocess/src/tests/subprocess_tests.cpp
@@ -782,10 +782,35 @@ TEST_F(SubprocessTest, Flags)
 
   string out = path::join(os::getcwd(), "stdout");
 
+#ifdef __WINDOWS__
+  // The Windows version of `echo` is a built-in of the command
+  // prompt, and it simply reproduces the entire command line string.
+  // However, the flags class (and thus this test) is expecting the
+  // semantics of a native binary interpreting the command line
+  // arguments via the Windows API `CommandLineToArgv`. When a regular
+  // Windows application (in contrast to `echo`) gets command line
+  // arguments, the text is processed automatically by
+  // `CommandLineToArgv`, which converts the command line string into
+  // an array. For example, this is the output of `echo`:
+  //
+  //    > cmd.exe /c echo "--s3=\"geek\""
+  //    "--s3=\"geek\""
+  //
+  // With `test-echo.exe`, a small native binary that just prints its
+  // arguments, the output is:
+  //
+  //     > test-echo.exe "--s3=\"geek\""
+  //     --s3="geek"
+  //
+  // This is the behavior expected by the test as the POSIX version of
+  // `echo` is a native binary.
+  string test_exe_path = path::join(BUILD_DIR, "test-echo.exe");
+#endif
+
   Try<Subprocess> s = subprocess(
 #ifdef __WINDOWS__
-      os::Shell::name,
-      {os::Shell::arg0, os::Shell::arg1, "echo"},
+	  test_exe_path,
+	  { test_exe_path },
 #else
       "/bin/echo",
       vector<string>(1, "echo"),
@@ -831,18 +856,10 @@ TEST_F(SubprocessTest, Flags)
   EXPECT_EQ(flags.i, flags2.i);
   EXPECT_EQ(flags.s, flags2.s);
   EXPECT_EQ(flags.s2, flags2.s2);
-  // TODO(andschwa): Fix the `flags.load()` or `stringify_args` logic.
-  // Currently, this gets escaped to `"\"--s3=\\\"geek\\\"\""` because
-  // it has double quotes in it. See MESOS-8857.
-#ifndef __WINDOWS__
   EXPECT_EQ(flags.s3, flags2.s3);
-#endif // __WINDOWS__
   EXPECT_EQ(flags.d, flags2.d);
   EXPECT_EQ(flags.y, flags2.y);
-  // TODO(andschwa): Same problem as above.
-#ifndef __WINDOWS__
   EXPECT_EQ(flags.j, flags2.j);
-#endif // __WINDOWS__
 
   for (int i = 1; i < argc; i++) {
     ::free(argv[i]);
diff --git a/3rdparty/libprocess/src/tests/test_echo.cpp b/3rdparty/libprocess/src/tests/test_echo.cpp
new file mode 100644
index 0000000000..30592f8c31
--- /dev/null
+++ b/3rdparty/libprocess/src/tests/test_echo.cpp
@@ -0,0 +1,28 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License
+
+// This process provides a target for testing flags
+// in libprocess.
+// It prints out argv separated by spaces.
+
+#include <stdio.h>
+
+int main(int argc, char** argv)
+{
+  printf("\n");
+  for (int i = 1; i < argc; i++) {
+    printf("%s ", argv[i]);
+  }
+  printf("\n");
+
+  return 0;
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message