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

Side by Side Diff: build/nocompile.gypi

Issue 7458012: Create a "no compile" drivers script in python to unittest compile time asserts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: increase timeouts Created 9 years, 3 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
OLDNEW
(Empty)
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 # This file is meant to be included into an target to create a unittest that
6 # invokes a set of no-compile tests. A no-compile test is a test that asserts
7 # a particular construct will not compile.
8 #
9 # To use this, create a gyp target with the following form:
10 # {
11 # 'target_name': 'my_module_nc_unittests',
12 # 'type': 'executable',
13 # 'sources': [
14 # 'nc_testset_1.nc',
15 # 'nc_testset_2.nc',
16 # ],
17 # 'includes': ['path/to/this/gypi/file'],
18 # }
19 #
20 # The .nc files are C++ files that contain code we wish to assert will not
21 # compile. Each individual test case in the file should be put in its own
22 # #ifdef section. The expected output should be appended with a C++-style
23 # comment that has a python list of regular expressions. This will likely
24 # be greater than 80-characters. Giving a solid expected output test is
25 # important so that random compile failures do not cause the test to pass.
26 #
27 # Example .nc file:
28 #
29 # #if defined(TEST_NEEDS_SEMICOLON) // [r"expected ',' or ';' at end of input "]
30 #
31 # int a = 1
32 #
33 # #elif defined(TEST_NEEDS_CAST) // [r"invalid conversion from 'void*' to 'ch ar*'"]
34 #
35 # void* a = NULL;
36 # char* b = a;
37 #
38 # #endif
39 #
40 # If we needed disable TEST_NEEDS_SEMICOLON, then change the define to:
41 #
42 # DISABLE_TEST_NEEDS_SEMICOLON
43 # TEST_NEEDS_CAST
44 #
45 # The lines above are parsed by a regexp so avoid getting creative with the
46 # formatting or ifdef logic; it will likely just not work.
47 #
48 # Implementation notes:
49 # The .nc files are actually processed by a python script which executes the
50 # compiler and generates a .cc file that is empty on success, or will have a
51 # series of #error lines on failure, and a set of trivially passing gunit
52 # TEST() functions on success. This allows us to fail at the compile step when
53 # something goes wrong, and know during the unittest run that the test was at
54 # least processed when things go right.
55
56 {
57 'conditions': [
58 [ 'OS=="linux" and clang==0', {
59 'rules': [
60 {
61 'variables': {
62 'nocompile_driver': '<(DEPTH)/tools/nocompile_driver.py',
63 'nc_result_path': '<(INTERMEDIATE_DIR)/<(module_dir)/<(RULE_INPUT_RO OT)_nc.cc',
64 },
65 'rule_name': 'run_nocompile',
66 'extension': 'nc',
67 'inputs': [
68 '<(nocompile_driver)',
69 ],
70 'outputs': [
71 '<(nc_result_path)'
72 ],
73 'action': [
74 'python',
75 '<(nocompile_driver)',
76 '4', # number of compilers to invoke in parallel.
77 '<(RULE_INPUT_PATH)',
78 '-Wall -Werror -I<(DEPTH)',
79 '<(nc_result_path)',
80 ],
81 'message': 'Generating no compile results for <(RULE_INPUT_PATH)',
82 'process_outputs_as_sources': 1,
83 },
84 ],
85 }, {
86 'sources/': [['exclude', '\\.nc$']]
87 }], # 'OS=="linux" and clang=="0"'
88 ],
89 }
90
OLDNEW
« no previous file with comments | « base/bind_unittest.nc ('k') | tools/nocompile_driver.py » ('j') | tools/nocompile_driver.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698