nocompile.gypi 3.2 KB

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