michael@0: # Copyright (c) 2011 The Chromium Authors. All rights reserved. michael@0: # Use of this source code is governed by a BSD-style license that can be michael@0: # found in the LICENSE file. michael@0: michael@0: # This file is meant to be included into an target to create a unittest that michael@0: # invokes a set of no-compile tests. A no-compile test is a test that asserts michael@0: # a particular construct will not compile. michael@0: # michael@0: # Also see: michael@0: # http://dev.chromium.org/developers/testing/no-compile-tests michael@0: # michael@0: # To use this, create a gyp target with the following form: michael@0: # { michael@0: # 'target_name': 'my_module_nc_unittests', michael@0: # 'type': 'executable', michael@0: # 'sources': [ michael@0: # 'nc_testset_1.nc', michael@0: # 'nc_testset_2.nc', michael@0: # ], michael@0: # 'includes': ['path/to/this/gypi/file'], michael@0: # } michael@0: # michael@0: # The .nc files are C++ files that contain code we wish to assert will not michael@0: # compile. Each individual test case in the file should be put in its own michael@0: # #ifdef section. The expected output should be appended with a C++-style michael@0: # comment that has a python list of regular expressions. This will likely michael@0: # be greater than 80-characters. Giving a solid expected output test is michael@0: # important so that random compile failures do not cause the test to pass. michael@0: # michael@0: # Example .nc file: michael@0: # michael@0: # #if defined(TEST_NEEDS_SEMICOLON) // [r"expected ',' or ';' at end of input"] michael@0: # michael@0: # int a = 1 michael@0: # michael@0: # #elif defined(TEST_NEEDS_CAST) // [r"invalid conversion from 'void*' to 'char*'"] michael@0: # michael@0: # void* a = NULL; michael@0: # char* b = a; michael@0: # michael@0: # #endif michael@0: # michael@0: # If we needed disable TEST_NEEDS_SEMICOLON, then change the define to: michael@0: # michael@0: # DISABLE_TEST_NEEDS_SEMICOLON michael@0: # TEST_NEEDS_CAST michael@0: # michael@0: # The lines above are parsed by a regexp so avoid getting creative with the michael@0: # formatting or ifdef logic; it will likely just not work. michael@0: # michael@0: # Implementation notes: michael@0: # The .nc files are actually processed by a python script which executes the michael@0: # compiler and generates a .cc file that is empty on success, or will have a michael@0: # series of #error lines on failure, and a set of trivially passing gunit michael@0: # TEST() functions on success. This allows us to fail at the compile step when michael@0: # something goes wrong, and know during the unittest run that the test was at michael@0: # least processed when things go right. michael@0: michael@0: { michael@0: # TODO(awong): Disabled until http://crbug.com/105388 is resolved. michael@0: 'sources/': [['exclude', '\\.nc$']], michael@0: 'conditions': [ michael@0: [ 'OS=="linux" and clang==0', { michael@0: 'rules': [ michael@0: { michael@0: 'variables': { michael@0: 'nocompile_driver': '<(DEPTH)/tools/nocompile_driver.py', michael@0: 'nc_result_path': ('<(INTERMEDIATE_DIR)/<(module_dir)/' michael@0: '<(RULE_INPUT_ROOT)_nc.cc'), michael@0: }, michael@0: 'rule_name': 'run_nocompile', michael@0: 'extension': 'nc', michael@0: 'inputs': [ michael@0: '<(nocompile_driver)', michael@0: ], michael@0: 'outputs': [ michael@0: '<(nc_result_path)' michael@0: ], michael@0: 'action': [ michael@0: 'python', michael@0: '<(nocompile_driver)', michael@0: '4', # number of compilers to invoke in parallel. michael@0: '<(RULE_INPUT_PATH)', michael@0: '-Wall -Werror -Wfatal-errors -I<(DEPTH)', michael@0: '<(nc_result_path)', michael@0: ], michael@0: 'message': 'Generating no compile results for <(RULE_INPUT_PATH)', michael@0: 'process_outputs_as_sources': 1, michael@0: }, michael@0: ], michael@0: }, { michael@0: 'sources/': [['exclude', '\\.nc$']] michael@0: }], # 'OS=="linux" and clang=="0"' michael@0: ], michael@0: } michael@0: