From b13d8f243da15ded051e87e663c4f2c2fcc5804c Mon Sep 17 00:00:00 2001 From: "sky@chromium.org" Date: Fri, 24 Oct 2014 18:16:13 +0000 Subject: Moves warning about invalid targets into 'invalid_targets' in result Previously if an invalid_target was supplied analyze would report it via 'warning'. I'm moving that warning to 'invalid_targets' and providing the list of invalid targets there. BUG=426892 TEST=covered by tests R=scottmg@chromium.org Review URL: https://codereview.chromium.org/671233004 git-svn-id: http://gyp.googlecode.com/svn/trunk@1994 78cadc50-ecff-11dd-a971-7dbc132099af --- pylib/gyp/generator/analyzer.py | 16 ++++++++++------ test/analyzer/gyptest-analyzer.py | 23 ++++++++++++----------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/pylib/gyp/generator/analyzer.py b/pylib/gyp/generator/analyzer.py index 9c2ef9f7..2784350d 100644 --- a/pylib/gyp/generator/analyzer.py +++ b/pylib/gyp/generator/analyzer.py @@ -11,7 +11,6 @@ targets: list of targets to search for. The target names are unqualified. The following is output: error: only supplied if there is an error. -warning: only supplied if there is a warning. targets: the set of targets passed in via targets that either directly or indirectly depend upon the set of paths supplied in files. build_targets: minimal set of targets that directly depend on the changed @@ -21,6 +20,7 @@ status: outputs one of three values: none of the supplied files were found, one of the include files changed so that it should be assumed everything changed (in this case targets and build_targets are not output) or at least one file was found. +invalid_targets: list of supplied targets thare were not found. If the generator flag analyzer_output_path is specified, output is written there. Otherwise output is written to stdout. @@ -444,6 +444,11 @@ def _WriteOutput(params, **values): print 'Supplied targets that depend on changed files:' for target in values['targets']: print '\t', target + if 'invalid_targets' in values: + values['invalid_targets'].sort() + print 'The following targets were not found:' + for target in values['invalid_targets']: + print '\t', target if 'build_targets' in values: values['build_targets'].sort() print 'Targets that require a build:' @@ -531,12 +536,11 @@ def GenerateOutput(target_list, target_dicts, data, params): data, target_list, target_dicts, toplevel_dir, frozenset(config.files), params['build_files']) - warning = None unqualified_mapping = _GetUnqualifiedToTargetMapping(all_targets, config.targets) + invalid_targets = None if len(unqualified_mapping) != len(config.targets): - not_found = _NamesNotIn(config.targets, unqualified_mapping) - warning = 'Unable to find all targets: ' + str(not_found) + invalid_targets = _NamesNotIn(config.targets, unqualified_mapping) if matching_targets: search_targets = _LookupTargets(config.targets, unqualified_mapping) @@ -557,8 +561,8 @@ def GenerateOutput(target_list, target_dicts, data, params): 'status': found_dependency_string if matching_targets else no_dependency_string, 'build_targets': build_targets} - if warning: - result_dict['warning'] = warning + if invalid_targets: + result_dict['invalid_targets'] = invalid_targets _WriteOutput(params, **result_dict) except Exception as e: diff --git a/test/analyzer/gyptest-analyzer.py b/test/analyzer/gyptest-analyzer.py index 378996a2..537d1c80 100644 --- a/test/analyzer/gyptest-analyzer.py +++ b/test/analyzer/gyptest-analyzer.py @@ -76,8 +76,8 @@ def EnsureContains(targets=set(), matched=False, build_targets=set()): print 'unexpected error', result.get('error') test.fail_test() - if result.get('warning', None): - print 'unexpected warning', result.get('warning') + if result.get('invalid_targets', None): + print 'unexpected invalid_targets', result.get('invalid_targets') test.fail_test() actual_targets = set(result['targets']) @@ -105,8 +105,8 @@ def EnsureMatchedAll(targets): print 'unexpected error', result.get('error') test.fail_test() - if result.get('warning', None): - print 'unexpected warning', result.get('warning') + if result.get('invalid_targets', None): + print 'unexpected invalid_targets', result.get('invalid_targets') test.fail_test() if result['status'] != found_all: @@ -135,12 +135,13 @@ def EnsureStdoutContains(expected_error_string): test.fail_test() -def EnsureWarning(expected_warning_string): - """Verifies output contains the warning string.""" +def EnsureInvalidTargets(expected_invalid_targets): + """Verifies output contains invalid_targets.""" result = _ReadOutputFileContents() - if result.get('warning', '').find(expected_warning_string) == -1: - print 'actual warning:', result.get('warning', ''), \ - '\nexpected warning:', expected_warning_string + actual_invalid_targets = set(result['invalid_targets']) + if actual_invalid_targets != expected_invalid_targets: + print 'actual invalid_targets:', actual_invalid_targets, \ + '\nexpected :', expected_invalid_targets test.fail_test() # Verifies config_path must be specified. @@ -152,10 +153,10 @@ test.run_gyp('test.gyp', '-Gconfig_path=bogus_file', '-Ganalyzer_output_path=analyzer_output') EnsureError('Unable to open file bogus_file') -# Verify get warning when bad target is specified. +# Verify 'invalid_targets' is present when bad target is specified. _CreateConfigFile(['exe2.c'], ['bad_target']) run_analyzer() -EnsureWarning('Unable to find all targets') +EnsureInvalidTargets({'bad_target'}) # Verifies config_path must point to a valid json file. _CreateBogusConfigFile() -- cgit v1.2.3