<commit_before>// Copyright (c) 2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Cocoa/Cocoa.h>
#include <sys/syslimits.h>
#include <unistd.h>

#include <string>

#include "base/at_exit.h"
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/icu_util.h"
#include "base/memory_debug.h"
#include "base/path_service.h"
#include "base/string_util.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
#include "webkit/tools/test_shell/test_shell.h"
#include "webkit/tools/test_shell/test_shell_switches.h"

#include "webkit/tools/test_shell/mac/temp/WebSystemInterface.h"

static char g_currentTestName[PATH_MAX];

// Extracts the name of the test from the given path and sets the test name
// global.
void SetCurrentTestName(char* path) {
  char* lastSlash = strrchr(path, '/');
  if (lastSlash) {
    ++lastSlash;
  } else {
    lastSlash = path;
  }
  
  strncpy(g_currentTestName, lastSlash, PATH_MAX);
  g_currentTestName[PATH_MAX-1] = '\0';
}



int main(const int argc, const char *argv[]) {
  InitWebCoreSystemInterface();
  
  // Some tests may use base::Singleton<>, thus we need to instantiate
  // the AtExitManager or else we will leak objects.
  base::AtExitManager at_exit_manager;  

  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

  // Force AppKit to init itself, but don't start the runloop yet
  [NSApplication sharedApplication];
  [NSBundle loadNibNamed:@"MainMenu" owner:NSApp];

  // Interpret the same flags as
  // the windows version, so that we can run the same test scripts. stop
  // if we hit something that's not a switch (like, oh, a URL).

  CommandLine parsed_command_line(argc, argv);

  if (parsed_command_line.HasSwitch(test_shell::kStartupDialog)) {
    //TODO: add alert to allow attaching via gdb before things really get going
  }

  if (parsed_command_line.HasSwitch(test_shell::kCrashDumps)) {
      std::wstring dir =
          parsed_command_line.GetSwitchValue(test_shell::kCrashDumps);
      // TODO: enable breakpad
      // new google_breakpad::ExceptionHandler(dir, 0, &MinidumpCallback, 0, true);
  }

  bool suppress_error_dialogs = (getenv("CHROME_HEADLESS") != NULL) ||
      parsed_command_line.HasSwitch(test_shell::kNoErrorDialogs) ||
      parsed_command_line.HasSwitch(test_shell::kLayoutTests);
  TestShell::InitLogging(suppress_error_dialogs);
		 
  bool layout_test_mode =
      parsed_command_line.HasSwitch(test_shell::kLayoutTests);
  bool interactive = !layout_test_mode;
  TestShell::InitializeTestShell(interactive);

  bool no_tree = parsed_command_line.HasSwitch(test_shell::kNoTree);
  
  bool dump_pixels = parsed_command_line.HasSwitch(test_shell::kDumpPixels);
  std::wstring pixel_file_name;<commit_msg>initialize the command line singleton Review URL: http://codereview.chromium.org/4038<commit_after>// Copyright (c) 2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Cocoa/Cocoa.h>
#include <sys/syslimits.h>
#include <unistd.h>

#include <string>

#include "base/at_exit.h"
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/icu_util.h"
#include "base/memory_debug.h"
#include "base/path_service.h"
#include "base/string_util.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
#include "webkit/tools/test_shell/test_shell.h"
#include "webkit/tools/test_shell/test_shell_switches.h"

#include "webkit/tools/test_shell/mac/temp/WebSystemInterface.h"

static char g_currentTestName[PATH_MAX];

// Extracts the name of the test from the given path and sets the test name
// global.
void SetCurrentTestName(char* path) {
  char* lastSlash = strrchr(path, '/');
  if (lastSlash) {
    ++lastSlash;
  } else {
    lastSlash = path;
  }
  
  strncpy(g_currentTestName, lastSlash, PATH_MAX);
  g_currentTestName[PATH_MAX-1] = '\0';
}



int main(const int argc, const char *argv[]) {
  InitWebCoreSystemInterface();
  
  // Some tests may use base::Singleton<>, thus we need to instantiate
  // the AtExitManager or else we will leak objects.
  base::AtExitManager at_exit_manager;  

  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

  // Force AppKit to init itself, but don't start the runloop yet
  [NSApplication sharedApplication];
  [NSBundle loadNibNamed:@"MainMenu" owner:NSApp];

  // Interpret the same flags as
  // the windows version, so that we can run the same test scripts. stop
  // if we hit something that's not a switch (like, oh, a URL).

  CommandLine::SetArgcArgv(argc, argv);
  CommandLine parsed_command_line(argc, argv);

  if (parsed_command_line.HasSwitch(test_shell::kStartupDialog)) {
    //TODO: add alert to allow attaching via gdb before things really get going
  }

  if (parsed_command_line.HasSwitch(test_shell::kCrashDumps)) {
      std::wstring dir =
          parsed_command_line.GetSwitchValue(test_shell::kCrashDumps);
      // TODO: enable breakpad
      // new google_breakpad::ExceptionHandler(dir, 0, &MinidumpCallback, 0, true);
  }

  bool suppress_error_dialogs = (getenv("CHROME_HEADLESS") != NULL) ||
      parsed_command_line.HasSwitch(test_shell::kNoErrorDialogs) ||
      parsed_command_line.HasSwitch(test_shell::kLayoutTests);
  TestShell::InitLogging(suppress_error_dialogs);
		 
  bool layout_test_mode =
      parsed_command_line.HasSwitch(test_shell::kLayoutTests);
  bool interactive = !layout_test_mode;
  TestShell::InitializeTestShell(interactive);

  bool no_tree = parsed_command_line.HasSwitch(test_shell::kNoTree);
  
  bool dump_pixels = parsed_command_line.HasSwitch(test_shell::kDumpPixels);
  std::wstring pixel_file_name;
{'fraction_non_alphanumeric': 0.1112424037812289, 'fraction_numerical': 0.00337609723160027, 'mean_word_length': 4.746847720659554, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5090776', 'n_tokens_mistral': 2036, 'n_tokens_neox': 1978, 'n_words': 472}