Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: tools/gn/exec_process_unittest.cc

Issue 1284533002: clang/win: Try to fix 64-bit build after https://codereview.chromium.org/1261953003. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sandbox/win/src/process_mitigations_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "tools/gn/exec_process.h" 9 #include "tools/gn/exec_process.h"
10 10
11 #if defined(OS_WIN) 11 #if defined(OS_WIN)
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #endif 13 #endif
14 14
15 namespace internal { 15 namespace internal {
16 16
17 // TODO(cjhopman): Enable these tests when windows ExecProcess handles stderr.
18 // 'python' is not runnable on Windows. Adding ["cmd", "/c"] fails because
19 // CommandLine does unusual reordering of args.
20 #if !defined(OS_WIN)
17 namespace { 21 namespace {
18 bool ExecPython(const std::string& command, 22 bool ExecPython(const std::string& command,
19 std::string* std_out, 23 std::string* std_out,
20 std::string* std_err, 24 std::string* std_err,
21 int* exit_code) { 25 int* exit_code) {
22 base::ScopedTempDir temp_dir; 26 base::ScopedTempDir temp_dir;
23 base::CommandLine::StringVector args; 27 base::CommandLine::StringVector args;
24 #if defined(OS_WIN) 28 #if defined(OS_WIN)
25 args.push_back(L"python"); 29 args.push_back(L"python");
26 args.push_back(L"-c"); 30 args.push_back(L"-c");
27 args.push_back(base::UTF8ToUTF16(command)); 31 args.push_back(base::UTF8ToUTF16(command));
28 #else 32 #else
29 args.push_back("python"); 33 args.push_back("python");
30 args.push_back("-c"); 34 args.push_back("-c");
31 args.push_back(command); 35 args.push_back(command);
32 #endif 36 #endif
33 return ExecProcess( 37 return ExecProcess(
34 base::CommandLine(args), temp_dir.path(), std_out, std_err, exit_code); 38 base::CommandLine(args), temp_dir.path(), std_out, std_err, exit_code);
35 } 39 }
36 } // namespace 40 } // namespace
37 41
38 // TODO(cjhopman): Enable these tests when windows ExecProcess handles stderr.
39 // 'python' is not runnable on Windows. Adding ["cmd", "/c"] fails because
40 // CommandLine does unusual reordering of args.
41 #if !defined(OS_WIN)
42 TEST(ExecProcessTest, TestExitCode) { 42 TEST(ExecProcessTest, TestExitCode) {
43 std::string std_out, std_err; 43 std::string std_out, std_err;
44 int exit_code; 44 int exit_code;
45 45
46 ASSERT_TRUE( 46 ASSERT_TRUE(
47 ExecPython("import sys; sys.exit(0)", &std_out, &std_err, &exit_code)); 47 ExecPython("import sys; sys.exit(0)", &std_out, &std_err, &exit_code));
48 EXPECT_EQ(0, exit_code); 48 EXPECT_EQ(0, exit_code);
49 49
50 ASSERT_TRUE( 50 ASSERT_TRUE(
51 ExecPython("import sys; sys.exit(1)", &std_out, &std_err, &exit_code)); 51 ExecPython("import sys; sys.exit(1)", &std_out, &std_err, &exit_code));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 "import sys; sys.stdout.close(); print >>sys.stderr, 'e' * 10000", 119 "import sys; sys.stdout.close(); print >>sys.stderr, 'e' * 10000",
120 &std_out, 120 &std_out,
121 &std_err, 121 &std_err,
122 &exit_code)); 122 &exit_code));
123 EXPECT_EQ(0, exit_code); 123 EXPECT_EQ(0, exit_code);
124 EXPECT_EQ(0u, std_out.size()); 124 EXPECT_EQ(0u, std_out.size());
125 EXPECT_EQ(10001u, std_err.size()); 125 EXPECT_EQ(10001u, std_err.size());
126 } 126 }
127 #endif 127 #endif
128 } // namespace internal 128 } // namespace internal
OLDNEW
« no previous file with comments | « sandbox/win/src/process_mitigations_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698