tools/nocompile_driver.py
def ExtractTestConfigs(sourcefile_path, suite_name):
  """Parses the source file for test configurations.

  Each no-compile test in the file is separated by an ifdef macro.  We scan
  the source file with the NCTEST_CONFIG_RE to find all ifdefs that look like
  they demark one no-compile test and try to extract the test configuration
  from that.

  Args:
    sourcefile_path: The path to the source file.
    suite_name: The name of the test suite.

  Returns:
    A list of test configurations. Each test configuration is a dictionary of
    the form:

      { name: 'NCTEST_NAME'
        suite_name: 'SOURCE_FILE_NAME'
        expectations: [re.Pattern, re.Pattern] }

    The |suite_name| is used to generate a pretty gtest output on successful
    completion of the no compile test.

    The compiled regexps in |expectations| define the valid outputs of the
    compiler.  If any one of the listed patterns matches either the stderr or
    stdout from the compilation, and the compilation failed, then the test is
    considered to have succeeded.  If the list is empty, than we ignore the
    compiler output and just check for failed compilation. If |expectations|
    is actually None, then this specifies a compiler sanity check test, which
    should expect a SUCCESSFUL compilation.
  """
  sourcefile = open(sourcefile_path, 'r')

  # Start with at least the compiler sanity test.  You need to always have one
  # sanity test to show that compiler flags and configuration are not just
  # wrong.  Otherwise, having a misconfigured compiler, or an error in the
  # shared portions of the .nc file would cause all tests to erroneously pass.
  test_configs = []

  for line in sourcefile:
    match_result = NCTEST_CONFIG_RE.match(line)
    if not match_result:
      continue

    groups = match_result.groups()

    # Grab the name and remove the defined() predicate if there is one.
    name = groups[0]
    strip_result = STRIP_DEFINED_RE.match(name)
    if strip_result:
      name = strip_result.group(1)

    # Read expectations if there are any.
    test_configs.append({'name': name,
                         'suite_name': suite_name,
                         'expectations': ParseExpectation(groups[1])})
  sourcefile.close()
  return test_configs
Parses the source file for test configurations.

  Each no-compile test in the file is separated by an ifdef macro.  We scan
  the source file with the NCTEST_CONFIG_RE to find all ifdefs that look like
  they demark one no-compile test and try to extract the test configuration
  from that.

  Args:
    sourcefile_path: The path to the source file.
    suite_name: The name of the test suite.

  Returns:
    A list of test configurations. Each test configuration is a dictionary of
    the form:

      { name: 'NCTEST_NAME'
        suite_name: 'SOURCE_FILE_NAME'
        expectations: [re.Pattern, re.Pattern] }

    The |suite_name| is used to generate a pretty gtest output on successful
    completion of the no compile test.

    The compiled regexps in |expectations| define the valid outputs of the
    compiler.  If any one of the listed patterns matches either the stderr or
    stdout from the compilation, and the compilation failed, then the test is
    considered to have succeeded.  If the list is empty, than we ignore the
    compiler output and just check for failed compilation. If |expectations|
    is actually None, then this specifies a compiler sanity check test, which
    should expect a SUCCESSFUL compilation.
  
Parses the source file for test configurations.
Each no-compile test in the file is separated by an ifdef macro.  We scan
the source file with the NCTEST_CONFIG_RE to find all ifdefs that look like
they demark one no-compile test and try to extract the test configuration
from that.
Parses the source file for test configurations . Each no - compile test in the file is separated by an ifdef macro . We scan the source file with the NCTEST_CONFIG_RE to find all ifdefs that look like they demark one no - compile test and try to extract the test configuration from that .
def ExtractTestConfigs(sourcefile_path, suite_name):
  sourcefile = open(sourcefile_path, 'r')
  test_configs = []
  for line in sourcefile:
    match_result = NCTEST_CONFIG_RE.match(line)
    if not match_result:
      continue
    groups = match_result.groups()
    name = groups[0]
    strip_result = STRIP_DEFINED_RE.match(name)
    if strip_result:
      name = strip_result.group(1)
    test_configs.append({'name': name,
                         'suite_name': suite_name,
                         'expectations': ParseExpectation(groups[1])})
  sourcefile.close()
  return test_configs
def ExtractTestConfigs ( sourcefile_path , suite_name ) : sourcefile = open ( sourcefile_path , 'r' ) test_configs = [ ] for line in sourcefile : match_result = NCTEST_CONFIG_RE . match ( line ) if not match_result : continue groups = match_result . groups ( ) name = groups [ 0 ] strip_result = STRIP_DEFINED_RE . match ( name ) if strip_result : name = strip_result . group ( 1 ) test_configs . append ( { 'name' : name , 'suite_name' : suite_name , 'expectations' : ParseExpectation ( groups [ 1 ] ) } ) sourcefile . close ( ) return test_configs
Parses the source file for test configurations.
Parses the source file for test configurations .
"""Parses the source file for test configurations.

  Each no-compile test in the file is separated by an ifdef macro.  We scan
  the source file with the NCTEST_CONFIG_RE to find all ifdefs that look like
  they demark one no-compile test and try to extract the test configuration
  from that.

  Args:
    sourcefile_path: The path to the source file.
    suite_name: The name of the test suite.

  Returns:
    A list of test configurations. Each test configuration is a dictionary of
    the form:

      { name: 'NCTEST_NAME'
        suite_name: 'SOURCE_FILE_NAME'
        expectations: [re.Pattern, re.Pattern] }

    The |suite_name| is used to generate a pretty gtest output on successful
    completion of the no compile test.

    The compiled regexps in |expectations| define the valid outputs of the
    compiler.  If any one of the listed patterns matches either the stderr or
    stdout from the compilation, and the compilation failed, then the test is
    considered to have succeeded.  If the list is empty, than we ignore the
    compiler output and just check for failed compilation. If |expectations|
    is actually None, then this specifies a compiler sanity check test, which
    should expect a SUCCESSFUL compilation.
  """ # Start with at least the compiler sanity test.  You need to always have one # sanity test to show that compiler flags and configuration are not just # wrong.  Otherwise, having a misconfigured compiler, or an error in the # shared portions of the .nc file would cause all tests to erroneously pass. # Grab the name and remove the defined() predicate if there is one. # Read expectations if there are any.
A list of test configurations. Each test configuration is a dictionary of
the form.

{ name: 'NCTEST_NAME'
suite_name: 'SOURCE_FILE_NAME'
expectations: [re.Pattern, re.Pattern] }

The |suite_name| is used to generate a pretty gtest output on successful
completion of the no compile test.

The compiled regexps in |expectations| define the valid outputs of the
compiler.  If any one of the listed patterns matches either the stderr or
stdout from the compilation, and the compilation failed, then the test is
considered to have succeeded.  If the list is empty, than we ignore the
compiler output and just check for failed compilation. If |expectations|
is actually None, then this specifies a compiler sanity check test, which
should expect a SUCCESSFUL compilation.
A list of test configurations . Each test configuration is a dictionary of the form . { name : ' NCTEST_NAME ' suite_name : ' SOURCE_FILE_NAME ' expectations : [ re . Pattern re . Pattern ] } The |suite_name| is used to generate a pretty gtest output on successful completion of the no compile test . The compiled regexps in |expectations| define the valid outputs of the compiler . If any one of the listed patterns matches either the stderr or stdout from the compilation and the compilation failed then the test is considered to have succeeded . If the list is empty than we ignore the compiler output and just check for failed compilation . If |expectations| is actually None then this specifies a compiler sanity check test which should expect a SUCCESSFUL compilation .
sourcefile_path
The path to the source file.
The path to the source file .
suite_name
The name of the test suite.
The name of the test suite .