提交 a1480601 编写于 作者: A Adam Barth

Top-level files

上级 388568d2
# Defines the Chromium style for automatic reformatting.
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
BasedOnStyle: Chromium
# This defaults to 'Auto'. Explicitly set it for a while, so that
# 'vector<vector<int> >' in existing files gets formatted to
# 'vector<vector<int>>'. ('Auto' means that clang-format will only use
# 'int>>' if the file already contains at least one such instance.)
Standard: Cpp11
## This page intentionally left blank. ##
#
# Workaround for VS2013 automatically creating .gitattributes files with
# default settings that we don't want.
# See also:
# http://connect.microsoft.com/VisualStudio/feedback/details/804948/inappropriately-creates-gitattributes-file
# http://crbug.com/342064
# commonly generated files
*.pyc
*~
.*.sw?
.DS_Store
.classpath
.cproject
.gdb_history
.gdbinit
.landmines
.project
.pub
.pydevproject
.checkstyle
cscope.*
Session.vim
tags
Thumbs.db
v8.log
/build/util/LASTCHANGE*
# directories pulled in via deps or hooks
/build/linux/bin/eu-strip
/buildtools/
/dart/
/dart-pub-cache/
/native_client/
/out/
/out_*/
/sdch/open-vcdiff/
/testing/gmock/
/testing/gtest/
/third_party/android_tools/
/third_party/angle/
/third_party/appurify-python/
/third_party/boringssl/src/
/third_party/brotli/src/
/third_party/colorama/src/
/third_party/dart-sdk/
/third_party/dart-pkg/archive
/third_party/dart-pkg/args
/third_party/dart-pkg/box2d
/third_party/dart-pkg/cassowary
/third_party/dart-pkg/collection
/third_party/dart-pkg/crypto
/third_party/dart-pkg/newton
/third_party/dart-pkg/path
/third_party/dart-pkg/quiver
/third_party/dart-pkg/source_span
/third_party/dart-pkg/string_scanner
/third_party/dart-pkg/vector_math
/third_party/dart-pkg/vector_math
/third_party/dart-pkg/yaml
/third_party/dejavu-fonts-ttf-2.34/ttf/*.ttf
/third_party/freetype-android/src
/third_party/go/tool/
/third_party/icu/
/third_party/jsr-305/src/
/third_party/libc++/trunk/
/third_party/libc++abi/trunk/
/third_party/libjpeg_turbo/
/third_party/llvm/
/third_party/llvm-build/
/third_party/junit/src/
/third_party/mesa/src/
/third_party/mockito/src/
/third_party/pdfium/
/third_party/pywebsocket/src/
/third_party/requests/src/
/third_party/robolectric/src/
/third_party/skia/
/third_party/smhasher/src/
/third_party/yasm/binaries/
/third_party/yasm/source/patched-yasm/
/tools/grit/
/v8/
# dart packages directories and related.
/mojo/dart/apptest/packages
/mojo/dart/mojo_services/packages
/mojo/dart/mojo_services/pubspec.lock
/mojo/dart/mojom/bin/packages
/mojo/dart/mojom/packages
/mojo/dart/mojom/test/packages
/sky/examples/hello_world/packages
/sky/examples/stocks/packages
/sky/sdk/packages/mojo/packages
/sky/sdk/packages/mojo/pubspec.lock
/sky/sdk/packages/sky/packages
/sky/sdk/packages/sky/pubspec.lock
# sky tools
/sky/tools/skygo/linux64/sky_server
/sky/tools/skygo/mac/sky_server
# downloaded keyboard_native resources.
/services/keyboard_native/res/*.png
# This file is used by the experimental meta-buildsystem in src/tools/gn to
# find the root of the source tree and to set startup options.
# The location of the build configuration file.
buildconfig = "//build/config/BUILDCONFIG.gn"
# The secondary source root is a parallel directory tree where
# GN build files are placed when they can not be placed directly
# in the source tree, e.g. for third party source trees.
secondary_source = "//build/secondary/"
# The set of targets known to pass 'gn check'. When all targets pass, remove
# this.
check_targets = [
"//crypto/*",
"//dart/*",
"//mojo/*",
"//mojom/*",
"//skia/*",
"//sky/*",
"//ui/*",
"//url/*",
]
# Copyright 2014 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.
# This target will be built if no target is specified when invoking ninja.
group("default") {
testonly = true
deps = [
"//sky",
"//services/sky",
]
}
# This file is automatically processed to create .DEPS.git which is the file
# that gclient uses under git.
#
# See http://code.google.com/p/chromium/wiki/UsingGit
#
# To test manually, run:
# python tools/deps2git/deps2git.py -o .DEPS.git -w <gclientdir>
# where <gcliendir> is the absolute path to the directory containing the
# .gclient file (the parent of 'src').
#
# Then commit .DEPS.git locally (gclient doesn't like dirty trees) and run
# gclient sync
# Verify the thing happened you wanted. Then revert your .DEPS.git change
# DO NOT CHECK IN CHANGES TO .DEPS.git upstream. It will be automatically
# updated by a bot when you modify this one.
#
# When adding a new dependency, please update the top-level .gitignore file
# to list the dependency's destination directory.
vars = {
'chromium_git': 'https://chromium.googlesource.com',
'dart_svn': 'https://dart.googlecode.com',
'skia_revision': '2ced78866fcadd98895777c8dffe92e229775181',
'angle_revision': 'bdd419f9f5b006e913606e7363125942c8ae06bc',
'dart_revision': 'e5e3d161e70d862608e6597facdf5ac8ae9ab2c3',
'dart_observatory_packages_revision': '45565',
'boringssl_revision': '642f1498d056dbba3e50ed5a232ab2f482626dec',
'buildtools_revision': 'fa660d47fa1a6c649d5c29e001348447c55709e6',
'archive_dart_revision': '07ffd98c5403b7f9ae067b57dc9487611be420f5',
'args_dart_revision': 'e0e8377412ee6cd6a5a4a8632848181c1db91f44',
'box2d_dart_revision': 'c5e65d9546275e78ad2a1d51b459e7638f6e4323',
'cassowary_dart_revision': '7e5afc5b3956a18636d5b37b1dcba1705865564b',
'collection_dart_revision': '79ebc6fc2dae581cb23ad50a5c600c1b7dd132f8',
'crypto_dart_revision': 'd4558dea1639e5ad2a41d045265b8ece270c2d90',
'newton_dart_revision': '26da04f0c441d005a6ecbf62ae047cd02ec9abc5',
'path_dart_revision': '2f3dcdec32011f1bc41194ae3640d6d9292a7096',
'quiver_dart_revision': '6bab7dec34189eee579178eb16d3063c8ae69031',
'source_span_dart_revision': '5c6c13f62fc111adaace3aeb4a38853d64481d06',
'string_scanner_dart_revision': '9f00056b32f41efc376adecfb696a01bc7c593d7',
'vector_math_dart_revision': '65915583f7aa606cb47ed265f853c18c60102b81',
'yaml_dart_revision': 'd8c1ce75edf051ea1d5583b24474f8656abb4920',
}
# Only these hosts are allowed for dependencies in this DEPS file.
# If you need to add a new host, contact chrome infrastructure team.
allowed_hosts = [
'chromium.googlesource.com',
'dart.googlecode.com',
]
deps = {
'src/buildtools':
Var('chromium_git') + '/chromium/buildtools.git' + '@' + Var('buildtools_revision'),
'src/testing/gtest':
Var('chromium_git') + '/external/googletest.git' + '@' + 'be1868139ffe0ccd0e8e3b37292b84c821d9c8ad', # from svn revision 704
'src/testing/gmock':
Var('chromium_git') + '/external/googlemock.git' + '@' + '29763965ab52f24565299976b936d1265cb6a271', # from svn revision 501
'src/third_party/angle':
Var('chromium_git') + '/angle/angle.git' + '@' + Var('angle_revision'),
'src/third_party/icu':
Var('chromium_git') + '/chromium/deps/icu.git' + '@' + 'c3f79166089e5360c09e3053fce50e6e296c3204',
'src/dart':
Var('chromium_git') + '/external/github.com/dart-lang/sdk.git' + '@' + Var('dart_revision'),
'src/dart/third_party/observatory_pub_packages':
Var('dart_svn') + '/svn/third_party/observatory_pub_packages' + '@' +
Var('dart_observatory_packages_revision'),
'src/third_party/skia':
Var('chromium_git') + '/skia.git' + '@' + Var('skia_revision'),
'src/third_party/yasm/source/patched-yasm':
Var('chromium_git') + '/chromium/deps/yasm/patched-yasm.git' + '@' + '4671120cd8558ce62ee8672ebf3eb6f5216f909b',
'src/third_party/libjpeg_turbo':
Var('chromium_git') + '/chromium/deps/libjpeg_turbo.git' + '@' + '034e9a9747e0983bc19808ea70e469bc8342081f',
'src/third_party/smhasher/src':
Var('chromium_git') + '/external/smhasher.git' + '@' + 'e87738e57558e0ec472b2fc3a643b838e5b6e88f',
'src/third_party/mesa/src':
Var('chromium_git') + '/chromium/deps/mesa.git' + '@' + '071d25db04c23821a12a8b260ab9d96a097402f0',
'src/third_party/boringssl/src':
'https://boringssl.googlesource.com/boringssl.git' + '@' + Var('boringssl_revision'),
'src/third_party/requests/src':
Var('chromium_git') + '/external/github.com/kennethreitz/requests.git' + '@' + 'f172b30356d821d180fa4ecfa3e71c7274a32de4',
'src/third_party/dart-pkg/archive':
Var('chromium_git') + '/external/github.com/brendan-duncan/archive.git' + '@' + Var('archive_dart_revision'),
'src/third_party/dart-pkg/args':
Var('chromium_git') + '/external/github.com/dart-lang/args.git' + '@' + Var('args_dart_revision'),
'src/third_party/dart-pkg/box2d':
Var('chromium_git') + '/external/github.com/google/box2d.dart.git' + '@' + Var('box2d_dart_revision'),
'src/third_party/dart-pkg/cassowary':
Var('chromium_git') + '/external/github.com/domokit/cassowary.git' + '@' + Var('cassowary_dart_revision'),
'src/third_party/dart-pkg/collection':
Var('chromium_git') + '/external/github.com/dart-lang/collection.git' + '@' + Var('collection_dart_revision'),
'src/third_party/dart-pkg/crypto':
Var('chromium_git') + '/external/github.com/dart-lang/crypto.git' + '@' + Var('crypto_dart_revision'),
'src/third_party/dart-pkg/newton':
Var('chromium_git') + '/external/github.com/domokit/newton.git' + '@' + Var('newton_dart_revision'),
'src/third_party/dart-pkg/path':
Var('chromium_git') + '/external/github.com/dart-lang/path.git' + '@' + Var('path_dart_revision'),
'src/third_party/dart-pkg/quiver':
Var('chromium_git') + '/external/github.com/google/quiver-dart.git' + '@' + Var('quiver_dart_revision'),
'src/third_party/dart-pkg/source_span':
Var('chromium_git') + '/external/github.com/dart-lang/source_span.git' + '@' + Var('source_span_dart_revision'),
'src/third_party/dart-pkg/string_scanner':
Var('chromium_git') + '/external/github.com/dart-lang/string_scanner.git' + '@' + Var('string_scanner_dart_revision'),
'src/third_party/dart-pkg/vector_math':
Var('chromium_git') + '/external/github.com/google/vector_math.dart.git' + '@' + Var('vector_math_dart_revision'),
'src/third_party/dart-pkg/yaml':
Var('chromium_git') + '/external/github.com/dart-lang/yaml.git' + '@' + Var('yaml_dart_revision'),
}
deps_os = {
'android': {
'src/third_party/colorama/src':
Var('chromium_git') + '/external/colorama.git' + '@' + '799604a1041e9b3bc5d2789ecbd7e8db2e18e6b8',
'src/third_party/jsr-305/src':
Var('chromium_git') + '/external/jsr-305.git' + '@' + '642c508235471f7220af6d5df2d3210e3bfc0919',
'src/third_party/junit/src':
Var('chromium_git') + '/external/junit.git' + '@' + '45a44647e7306262162e1346b750c3209019f2e1',
'src/third_party/mockito/src':
Var('chromium_git') + '/external/mockito/mockito.git' + '@' + 'ed99a52e94a84bd7c467f2443b475a22fcc6ba8e',
'src/third_party/robolectric/lib':
Var('chromium_git') + '/chromium/third_party/robolectric.git' + '@' + '6b63c99a8b6967acdb42cbed0adb067c80efc810',
'src/third_party/appurify-python/src':
Var('chromium_git') + '/external/github.com/appurify/appurify-python.git' + '@' + 'ee7abd5c5ae3106f72b2a0b9d2cb55094688e867',
'src/third_party/freetype-android/src':
Var('chromium_git') + '/chromium/src/third_party/freetype.git' + '@' + 'd1028db70bea988d1022e4d463de66581c696160',
'src/third_party/requests/src':
Var('chromium_git') + '/external/github.com/kennethreitz/requests.git' + '@' + 'f172b30356d821d180fa4ecfa3e71c7274a32de4',
},
}
hooks = [
{
# This clobbers when necessary (based on get_landmines.py). It must be the
# first hook so that other things that get/generate into the output
# directory will not subsequently be clobbered.
'name': 'landmines',
'pattern': '.',
'action': [
'python',
'src/build/landmines.py',
],
},
{
# Pull clang if needed or requested via GYP_DEFINES.
'name': 'clang',
'pattern': '.',
'action': ['python', 'src/tools/clang/scripts/update.py', '--if-needed'],
},
{
# Pull dart sdk if needed
'name': 'dart',
'pattern': '.',
'action': ['python', 'src/tools/dart/update.py'],
},
{
# This downloads android_tools according to tools/android/VERSION_*.
'name': 'android_tools',
'pattern': '.',
'action': ['python', 'src/tools/android/download_android_tools.py'],
},
{
# This downloads SDK extras and puts them in the
# third_party/android_tools/sdk/extras directory on the bots. Developers
# need to manually install these packages and accept the ToS.
'name': 'sdkextras',
'pattern': '.',
# When adding a new sdk extras package to download, add the package
# directory and zip file to .gitignore in third_party/android_tools.
'action': ['python', 'src/build/download_sdk_extras.py'],
},
{
# Update LASTCHANGE. This is also run by export_tarball.py in
# src/tools/export_tarball - please keep them in sync.
'name': 'lastchange',
'pattern': '.',
'action': ['python', 'src/build/util/lastchange.py',
'-o', 'src/build/util/LASTCHANGE'],
},
# Pull GN binaries. This needs to be before running GYP below.
{
'name': 'gn_linux64',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=linux*',
'--no_auth',
'--bucket', 'chromium-gn',
'-s', 'src/buildtools/linux64/gn.sha1',
],
},
{
'name': 'gn_mac',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=darwin',
'--no_auth',
'--bucket', 'chromium-gn',
'-s', 'src/buildtools/mac/gn.sha1',
],
},
{
'name': 'gn_win',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=win*',
'--no_auth',
'--bucket', 'chromium-gn',
'-s', 'src/buildtools/win/gn.exe.sha1',
],
},
# Pull clang-format binaries using checked-in hashes.
{
'name': 'clang_format_linux',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=linux*',
'--no_auth',
'--bucket', 'chromium-clang-format',
'-s', 'src/buildtools/linux64/clang-format.sha1',
],
},
{
'name': 'clang_format_mac',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=darwin',
'--no_auth',
'--bucket', 'chromium-clang-format',
'-s', 'src/buildtools/mac/clang-format.sha1',
],
},
# Pull sky_server binaries using checked-in hashes.
{
'name': 'sky_server_linux',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=linux*',
'--no_auth',
'--bucket', 'mojo',
'-s', 'src/sky/tools/skygo/linux64/sky_server.sha1',
],
},
{
'name': 'sky_server_mac',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=darwin',
'--no_auth',
'--bucket', 'mojo',
'-s', 'src/sky/tools/skygo/mac/sky_server.sha1',
],
},
{
'name': 'material_design_icons',
'pattern': '.',
'action': [
'python',
'src/sky/sdk/lib/download_material_design_icons',
],
},
# Pull binutils for linux, enabled debug fission for faster linking /
# debugging when used with clang on Ubuntu Precise.
# https://code.google.com/p/chromium/issues/detail?id=352046
{
'name': 'binutils',
'pattern': 'src/third_party/binutils',
'action': [
'python',
'src/third_party/binutils/download.py',
],
},
# Pull eu-strip binaries using checked-in hashes.
{
'name': 'eu-strip',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=linux*',
'--no_auth',
'--bucket', 'chromium-eu-strip',
'-s', 'src/build/linux/bin/eu-strip.sha1',
],
},
# Run "pub get" on any directories with checked-in pubspec.yaml files
# (excluding sky/, whose pubspec.yaml files are not intended for supporting
# building in-place in the repo).
{
'name': 'run_dart_pub_get',
'pattern': '',
'action': [ 'python',
'src/mojo/public/tools/git/dart_pub_get.py',
'--repository-root', '../../../..',
'--dart-sdk-directory',
'../../../../third_party/dart-sdk/dart-sdk',
'--dirs-to-ignore', 'sky/',
],
},
{
# Ensure that we don't accidentally reference any .pyc files whose
# corresponding .py files have already been deleted.
'name': 'remove_stale_pyc_files',
'pattern': 'src/tools/.*\\.py',
'action': [
'python',
'src/tools/remove_stale_pyc_files.py',
'src/tools',
],
},
]
// Copyright 2014 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
此差异已折叠。
#!/usr/bin/env python
# Copyright (c) 2012 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 re
import unittest
import PRESUBMIT
from PRESUBMIT_test_mocks import MockChange, MockFile
from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi
_TEST_DATA_DIR = 'base/test/data/presubmit'
class IncludeOrderTest(unittest.TestCase):
def testSystemHeaderOrder(self):
scope = [(1, '#include <csystem.h>'),
(2, '#include <cppsystem>'),
(3, '#include "acustom.h"')]
all_linenums = [linenum for (linenum, _) in scope]
mock_input_api = MockInputApi()
warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
'', all_linenums)
self.assertEqual(0, len(warnings))
def testSystemHeaderOrderMismatch1(self):
scope = [(10, '#include <cppsystem>'),
(20, '#include <csystem.h>'),
(30, '#include "acustom.h"')]
all_linenums = [linenum for (linenum, _) in scope]
mock_input_api = MockInputApi()
warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
'', all_linenums)
self.assertEqual(1, len(warnings))
self.assertTrue('20' in warnings[0])
def testSystemHeaderOrderMismatch2(self):
scope = [(10, '#include <cppsystem>'),
(20, '#include "acustom.h"'),
(30, '#include <csystem.h>')]
all_linenums = [linenum for (linenum, _) in scope]
mock_input_api = MockInputApi()
warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
'', all_linenums)
self.assertEqual(1, len(warnings))
self.assertTrue('30' in warnings[0])
def testSystemHeaderOrderMismatch3(self):
scope = [(10, '#include "acustom.h"'),
(20, '#include <csystem.h>'),
(30, '#include <cppsystem>')]
all_linenums = [linenum for (linenum, _) in scope]
mock_input_api = MockInputApi()
warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
'', all_linenums)
self.assertEqual(2, len(warnings))
self.assertTrue('20' in warnings[0])
self.assertTrue('30' in warnings[1])
def testAlphabeticalOrderMismatch(self):
scope = [(10, '#include <csystem.h>'),
(15, '#include <bsystem.h>'),
(20, '#include <cppsystem>'),
(25, '#include <bppsystem>'),
(30, '#include "bcustom.h"'),
(35, '#include "acustom.h"')]
all_linenums = [linenum for (linenum, _) in scope]
mock_input_api = MockInputApi()
warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
'', all_linenums)
self.assertEqual(3, len(warnings))
self.assertTrue('15' in warnings[0])
self.assertTrue('25' in warnings[1])
self.assertTrue('35' in warnings[2])
def testSpecialFirstInclude1(self):
mock_input_api = MockInputApi()
contents = ['#include "some/path/foo.h"',
'#include "a/header.h"']
mock_file = MockFile('some/path/foo.cc', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
def testSpecialFirstInclude2(self):
mock_input_api = MockInputApi()
contents = ['#include "some/other/path/foo.h"',
'#include "a/header.h"']
mock_file = MockFile('some/path/foo.cc', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
def testSpecialFirstInclude3(self):
mock_input_api = MockInputApi()
contents = ['#include "some/path/foo.h"',
'#include "a/header.h"']
mock_file = MockFile('some/path/foo_platform.cc', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
def testSpecialFirstInclude4(self):
mock_input_api = MockInputApi()
contents = ['#include "some/path/bar.h"',
'#include "a/header.h"']
mock_file = MockFile('some/path/foo_platform.cc', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(1, len(warnings))
self.assertTrue('2' in warnings[0])
def testSpecialFirstInclude5(self):
mock_input_api = MockInputApi()
contents = ['#include "some/other/path/foo.h"',
'#include "a/header.h"']
mock_file = MockFile('some/path/foo-suffix.h', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
def testSpecialFirstInclude6(self):
mock_input_api = MockInputApi()
contents = ['#include "some/other/path/foo_win.h"',
'#include <set>',
'#include "a/header.h"']
mock_file = MockFile('some/path/foo_unittest_win.h', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
def testOrderAlreadyWrong(self):
scope = [(1, '#include "b.h"'),
(2, '#include "a.h"'),
(3, '#include "c.h"')]
mock_input_api = MockInputApi()
warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
'', [3])
self.assertEqual(0, len(warnings))
def testConflictAdded1(self):
scope = [(1, '#include "a.h"'),
(2, '#include "c.h"'),
(3, '#include "b.h"')]
mock_input_api = MockInputApi()
warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
'', [2])
self.assertEqual(1, len(warnings))
self.assertTrue('3' in warnings[0])
def testConflictAdded2(self):
scope = [(1, '#include "c.h"'),
(2, '#include "b.h"'),
(3, '#include "d.h"')]
mock_input_api = MockInputApi()
warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
'', [2])
self.assertEqual(1, len(warnings))
self.assertTrue('2' in warnings[0])
def testIfElifElseEndif(self):
mock_input_api = MockInputApi()
contents = ['#include "e.h"',
'#define foo',
'#include "f.h"',
'#undef foo',
'#include "e.h"',
'#if foo',
'#include "d.h"',
'#elif bar',
'#include "c.h"',
'#else',
'#include "b.h"',
'#endif',
'#include "a.h"']
mock_file = MockFile('', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
def testExcludedIncludes(self):
# #include <sys/...>'s can appear in any order.
mock_input_api = MockInputApi()
contents = ['#include <sys/b.h>',
'#include <sys/a.h>']
mock_file = MockFile('', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
contents = ['#include <atlbase.h>',
'#include <aaa.h>']
mock_file = MockFile('', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
contents = ['#include "build/build_config.h"',
'#include "aaa.h"']
mock_file = MockFile('', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(0, len(warnings))
def testCheckOnlyCFiles(self):
mock_input_api = MockInputApi()
mock_output_api = MockOutputApi()
contents = ['#include <b.h>',
'#include <a.h>']
mock_file_cc = MockFile('something.cc', contents)
mock_file_h = MockFile('something.h', contents)
mock_file_other = MockFile('something.py', contents)
mock_input_api.files = [mock_file_cc, mock_file_h, mock_file_other]
warnings = PRESUBMIT._CheckIncludeOrder(mock_input_api, mock_output_api)
self.assertEqual(1, len(warnings))
self.assertEqual(2, len(warnings[0].items))
self.assertEqual('promptOrNotify', warnings[0].type)
def testUncheckableIncludes(self):
mock_input_api = MockInputApi()
contents = ['#include <windows.h>',
'#include "b.h"',
'#include "a.h"']
mock_file = MockFile('', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(1, len(warnings))
contents = ['#include "gpu/command_buffer/gles_autogen.h"',
'#include "b.h"',
'#include "a.h"']
mock_file = MockFile('', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(1, len(warnings))
contents = ['#include "gl_mock_autogen.h"',
'#include "b.h"',
'#include "a.h"']
mock_file = MockFile('', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(1, len(warnings))
contents = ['#include "ipc/some_macros.h"',
'#include "b.h"',
'#include "a.h"']
mock_file = MockFile('', contents)
warnings = PRESUBMIT._CheckIncludeOrderInFile(
mock_input_api, mock_file, range(1, len(contents) + 1))
self.assertEqual(1, len(warnings))
class VersionControlConflictsTest(unittest.TestCase):
def testTypicalConflict(self):
lines = ['<<<<<<< HEAD',
' base::ScopedTempDir temp_dir_;',
'=======',
' ScopedTempDir temp_dir_;',
'>>>>>>> master']
errors = PRESUBMIT._CheckForVersionControlConflictsInFile(
MockInputApi(), MockFile('some/path/foo_platform.cc', lines))
self.assertEqual(3, len(errors))
self.assertTrue('1' in errors[0])
self.assertTrue('3' in errors[1])
self.assertTrue('5' in errors[2])
class BadExtensionsTest(unittest.TestCase):
def testBadRejFile(self):
mock_input_api = MockInputApi()
mock_input_api.files = [
MockFile('some/path/foo.cc', ''),
MockFile('some/path/foo.cc.rej', ''),
MockFile('some/path2/bar.h.rej', ''),
]
results = PRESUBMIT._CheckPatchFiles(mock_input_api, MockOutputApi())
self.assertEqual(1, len(results))
self.assertEqual(2, len(results[0].items))
self.assertTrue('foo.cc.rej' in results[0].items[0])
self.assertTrue('bar.h.rej' in results[0].items[1])
def testBadOrigFile(self):
mock_input_api = MockInputApi()
mock_input_api.files = [
MockFile('other/path/qux.h.orig', ''),
MockFile('other/path/qux.h', ''),
MockFile('other/path/qux.cc', ''),
]
results = PRESUBMIT._CheckPatchFiles(mock_input_api, MockOutputApi())
self.assertEqual(1, len(results))
self.assertEqual(1, len(results[0].items))
self.assertTrue('qux.h.orig' in results[0].items[0])
def testGoodFiles(self):
mock_input_api = MockInputApi()
mock_input_api.files = [
MockFile('other/path/qux.h', ''),
MockFile('other/path/qux.cc', ''),
]
results = PRESUBMIT._CheckPatchFiles(mock_input_api, MockOutputApi())
self.assertEqual(0, len(results))
def testNoFiles(self):
mock_change = MockChange([])
results = PRESUBMIT.GetPreferredTryMasters(None, mock_change)
self.assertEqual({}, results)
class InvalidOSMacroNamesTest(unittest.TestCase):
def testInvalidOSMacroNames(self):
lines = ['#if defined(OS_WINDOWS)',
' #elif defined(OS_WINDOW)',
' # if defined(OS_MACOSX) || defined(OS_CHROME)',
'# else // defined(OS_MAC)',
'#endif // defined(OS_MACOS)']
errors = PRESUBMIT._CheckForInvalidOSMacrosInFile(
MockInputApi(), MockFile('some/path/foo_platform.cc', lines))
self.assertEqual(len(lines), len(errors))
self.assertTrue(':1 OS_WINDOWS' in errors[0])
self.assertTrue('(did you mean OS_WIN?)' in errors[0])
def testValidOSMacroNames(self):
lines = ['#if defined(%s)' % m for m in PRESUBMIT._VALID_OS_MACROS]
errors = PRESUBMIT._CheckForInvalidOSMacrosInFile(
MockInputApi(), MockFile('some/path/foo_platform.cc', lines))
self.assertEqual(0, len(errors))
class InvalidIfDefinedMacroNamesTest(unittest.TestCase):
def testInvalidIfDefinedMacroNames(self):
lines = ['#if defined(TARGET_IPHONE_SIMULATOR)',
'#if !defined(TARGET_IPHONE_SIMULATOR)',
'#elif defined(TARGET_IPHONE_SIMULATOR)',
'#ifdef TARGET_IPHONE_SIMULATOR',
' # ifdef TARGET_IPHONE_SIMULATOR',
'# if defined(VALID) || defined(TARGET_IPHONE_SIMULATOR)',
'# else // defined(TARGET_IPHONE_SIMULATOR)',
'#endif // defined(TARGET_IPHONE_SIMULATOR)',]
errors = PRESUBMIT._CheckForInvalidIfDefinedMacrosInFile(
MockInputApi(), MockFile('some/path/source.mm', lines))
self.assertEqual(len(lines), len(errors))
def testValidIfDefinedMacroNames(self):
lines = ['#if defined(FOO)',
'#ifdef BAR',]
errors = PRESUBMIT._CheckForInvalidIfDefinedMacrosInFile(
MockInputApi(), MockFile('some/path/source.cc', lines))
self.assertEqual(0, len(errors))
if __name__ == '__main__':
unittest.main()
# Copyright 2014 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 json
import os
import re
import subprocess
import sys
class MockInputApi(object):
"""Mock class for the InputApi class.
This class can be used for unittests for presubmit by initializing the files
attribute as the list of changed files.
"""
def __init__(self):
self.json = json
self.re = re
self.os_path = os.path
self.python_executable = sys.executable
self.subprocess = subprocess
self.files = []
self.is_committing = False
def AffectedFiles(self, file_filter=None):
return self.files
def PresubmitLocalPath(self):
return os.path.dirname(__file__)
def ReadFile(self, filename, mode='rU'):
for file_ in self.files:
if file_.LocalPath() == filename:
return '\n'.join(file_.NewContents())
# Otherwise, file is not in our mock API.
raise IOError, "No such file or directory: '%s'" % filename
class MockOutputApi(object):
"""Mock class for the OutputApi class.
An instance of this class can be passed to presubmit unittests for outputing
various types of results.
"""
class PresubmitResult(object):
def __init__(self, message, items=None, long_text=''):
self.message = message
self.items = items
self.long_text = long_text
class PresubmitError(PresubmitResult):
def __init__(self, message, items, long_text=''):
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
self.type = 'error'
class PresubmitPromptWarning(PresubmitResult):
def __init__(self, message, items, long_text=''):
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
self.type = 'warning'
class PresubmitNotifyResult(PresubmitResult):
def __init__(self, message, items, long_text=''):
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
self.type = 'notify'
class PresubmitPromptOrNotify(PresubmitResult):
def __init__(self, message, items, long_text=''):
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
self.type = 'promptOrNotify'
class MockFile(object):
"""Mock class for the File class.
This class can be used to form the mock list of changed files in
MockInputApi for presubmit unittests.
"""
def __init__(self, local_path, new_contents):
self._local_path = local_path
self._new_contents = new_contents
self._changed_contents = [(i + 1, l) for i, l in enumerate(new_contents)]
def ChangedContents(self):
return self._changed_contents
def NewContents(self):
return self._new_contents
def LocalPath(self):
return self._local_path
class MockChange(object):
"""Mock class for Change class.
This class can be used in presubmit unittests to mock the query of the
current change.
"""
def __init__(self, changed_files):
self._changed_files = changed_files
def LocalPaths(self):
return self._changed_files
# Copyright 2014 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.
# Watchlist Rules
# Refer: http://dev.chromium.org/developers/contributing-code/watchlists
# IMPORTANT: The regular expression filepath is tested against each path using
# re.search, so it is not usually necessary to add .*.
{
'WATCHLIST_DEFINITIONS': {
'mojo': {
'filepath': 'mojo',
},
'services': {
'filepath': 'services',
},
'shell': {
'filepath': 'shell',
},
'sky': {
'filepath': 'sky',
},
},
'WATCHLISTS': {
'mojo': ['aa@chromium.org',
'abarth@chromium.org',
'ben+mojo@chromium.org',
'darin@chromium.org',
'qsr+mojo@chromium.org',
'viettrungluu+watch@chromium.org',
'gregsimon@chromium.org',
'yzshen+watch@chromium.org'],
'services': ['qsr+mojo@chromium.org',
'yzshen+watch@chromium.org'],
'shell': ['qsr+mojo@chromium.org',
'yzshen+watch@chromium.org'],
'sky': ['abarth@chromium.org',
'gregsimon@chromium.org',
'jackson@chromium.org',
'qsr+mojo@chromium.org'],
},
}
# This file is used by gcl to get repository specific information.
CODE_REVIEW_SERVER: codereview.chromium.org
CC_LIST: mojo-reviews@chromium.org
VIEW_VC: https://chromium.googlesource.com/external/mojo/+/
PROJECT: mojo
RUN_POST_UPLOAD_HOOK: True
# Copyright 2014 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.
if (is_android) {
import("//build/config/android/config.gni")
}
declare_args() {
# Uses system libjpeg. If true, overrides use_libjpeg_turbo.
use_system_libjpeg = false
# Uses libjpeg_turbo as the jpeg implementation. Has no effect if
# use_system_libjpeg is set.
use_libjpeg_turbo = true
}
config("system_libjpeg_config") {
defines = [ "USE_SYSTEM_LIBJPEG" ]
}
config("libjpeg_turbo_config") {
defines = [ "USE_LIBJPEG_TURBO" ]
}
# This is a meta target that forwards to the system's libjpeg,
# third_party/libjpeg, or third_party/libjpeg_turbo depending on the build args
# declared in this file.
group("jpeg") {
if (use_system_libjpeg) {
libs = [ "jpeg" ]
public_configs = [ ":system_libjpeg_config" ]
} else if (use_libjpeg_turbo) {
deps = [
"//third_party/libjpeg_turbo:libjpeg",
]
public_configs = [ ":libjpeg_turbo_config" ]
} else {
deps = [
"//third_party/libjpeg:libjpeg",
]
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册