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

Side by Side Diff: base/test/test_launcher.cc

Issue 17910005: Fix handling of BROWSER_WRAPPER in the test launcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « base/test/test_launcher.h ('k') | content/public/test/test_launcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/test/test_launcher.h" 5 #include "base/test/test_launcher.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/environment.h" 10 #include "base/environment.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/format_macros.h" 13 #include "base/format_macros.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/process_util.h" 16 #include "base/process_util.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/utf_string_conversions.h"
18 #include "base/test/test_timeouts.h" 19 #include "base/test/test_timeouts.h"
19 #include "base/time.h" 20 #include "base/time.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 #if defined(OS_MACOSX) 23 #if defined(OS_MACOSX)
23 #include "base/mac/scoped_nsautorelease_pool.h" 24 #include "base/mac/scoped_nsautorelease_pool.h"
24 #endif 25 #endif
25 26
26 namespace base { 27 namespace base {
27 28
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 344
344 const char kHelpFlag[] = "help"; 345 const char kHelpFlag[] = "help";
345 346
346 TestResult::TestResult() { 347 TestResult::TestResult() {
347 } 348 }
348 349
349 TestLauncherDelegate::~TestLauncherDelegate() { 350 TestLauncherDelegate::~TestLauncherDelegate() {
350 } 351 }
351 352
352 int LaunchChildGTestProcess(const CommandLine& command_line, 353 int LaunchChildGTestProcess(const CommandLine& command_line,
354 const std::string& wrapper,
353 base::TimeDelta timeout, 355 base::TimeDelta timeout,
354 bool* was_timeout) { 356 bool* was_timeout) {
355 CommandLine new_command_line(command_line.GetProgram()); 357 CommandLine new_command_line(command_line.GetProgram());
356 CommandLine::SwitchMap switches = command_line.GetSwitches(); 358 CommandLine::SwitchMap switches = command_line.GetSwitches();
357 359
358 // Strip out gtest_output flag because otherwise we would overwrite results 360 // Strip out gtest_output flag because otherwise we would overwrite results
359 // of the other tests. 361 // of the other tests.
360 switches.erase(kGTestOutputFlag); 362 switches.erase(kGTestOutputFlag);
361 363
362 // Strip out gtest_repeat flag - this is handled by the launcher process. 364 // Strip out gtest_repeat flag - this is handled by the launcher process.
363 switches.erase(kGTestRepeatFlag); 365 switches.erase(kGTestRepeatFlag);
364 366
365 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); 367 for (CommandLine::SwitchMap::const_iterator iter = switches.begin();
366 iter != switches.end(); ++iter) { 368 iter != switches.end(); ++iter) {
367 new_command_line.AppendSwitchNative((*iter).first, (*iter).second); 369 new_command_line.AppendSwitchNative((*iter).first, (*iter).second);
368 } 370 }
369 371
372 // Prepend wrapper after last CommandLine quasi-copy operation. CommandLine
373 // does not really support removing switches well, and trying to do that
374 // on a CommandLine with a wrapper is known to break.
375 // TODO(phajdan.jr): Give it a try to support CommandLine removing switches.
376 #if defined(OS_WIN)
377 new_command_line.PrependWrapper(ASCIIToWide(wrapper));
378 #elif defined(OS_POSIX)
379 new_command_line.PrependWrapper(wrapper);
380 #endif
381
370 base::ProcessHandle process_handle; 382 base::ProcessHandle process_handle;
371 base::LaunchOptions options; 383 base::LaunchOptions options;
372 384
373 #if defined(OS_POSIX) 385 #if defined(OS_POSIX)
374 // On POSIX, we launch the test in a new process group with pgid equal to 386 // On POSIX, we launch the test in a new process group with pgid equal to
375 // its pid. Any child processes that the test may create will inherit the 387 // its pid. Any child processes that the test may create will inherit the
376 // same pgid. This way, if the test is abruptly terminated, we can clean up 388 // same pgid. This way, if the test is abruptly terminated, we can clean up
377 // any orphaned child processes it may have left behind. 389 // any orphaned child processes it may have left behind.
378 options.new_process_group = true; 390 options.new_process_group = true;
379 #endif 391 #endif
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 441
430 // Special value "-1" means "repeat indefinitely". 442 // Special value "-1" means "repeat indefinitely".
431 if (cycles != -1) 443 if (cycles != -1)
432 cycles--; 444 cycles--;
433 } 445 }
434 446
435 return exit_code; 447 return exit_code;
436 } 448 }
437 449
438 } // namespace base 450 } // namespace base
OLDNEW
« no previous file with comments | « base/test/test_launcher.h ('k') | content/public/test/test_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698