From f881d1a1faf517525a600a8822486d7dd4c8671d Mon Sep 17 00:00:00 2001 From: Pete Blois Date: Fri, 4 Apr 2014 10:24:22 -0700 Subject: [PATCH] Fixing expression extractor & test Noticed that this test was not failing when it should have been, there were two issues- - The packages were not being specified for the test, so the expression extractor was skipping all Angular code. - The source crawler was not including exported libraries which causes it to incorrectly skip chunks of Angular code. End result is that the expression list being extracted was a fraction of what it should have been. --- lib/tools/source_crawler_impl.dart | 4 +++- scripts/test-expression-extractor.sh | 2 +- test/io/source_metadata_extractor_spec.dart | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/tools/source_crawler_impl.dart b/lib/tools/source_crawler_impl.dart index b32940c0d..654e25535 100644 --- a/lib/tools/source_crawler_impl.dart +++ b/lib/tools/source_crawler_impl.dart @@ -45,7 +45,9 @@ class SourceCrawlerImpl implements SourceCrawler { String currentFile, List visited, List toVisit) { cu.directives.forEach((Directive directive) { - if (directive is ImportDirective || directive is PartDirective) { + if (directive is ImportDirective || + directive is PartDirective || + directive is ExportDirective) { UriBasedDirective import = directive; String canonicalFile = canonicalizeImportPath( currentDir, currentFile, import.uri.stringValue); diff --git a/scripts/test-expression-extractor.sh b/scripts/test-expression-extractor.sh index 92a68ff1d..6fde0dafb 100755 --- a/scripts/test-expression-extractor.sh +++ b/scripts/test-expression-extractor.sh @@ -8,7 +8,7 @@ rm -rf xxx.dart OUT=$(mktemp XXX.dart) -dart bin/expression_extractor.dart example/web/todo.dart example /dev/null /dev/null $OUT +dart --package-root=example/packages bin/expression_extractor.dart example/web/todo.dart example /dev/null /dev/null $OUT if [[ -e $OUT ]]; then echo "Expression extractor created an output file" diff --git a/test/io/source_metadata_extractor_spec.dart b/test/io/source_metadata_extractor_spec.dart index 1bc511bea..c332e90e8 100644 --- a/test/io/source_metadata_extractor_spec.dart +++ b/test/io/source_metadata_extractor_spec.dart @@ -15,7 +15,7 @@ void main() { sourceMetadataExtractor .gatherDirectiveInfo('test/io/test_files/main.dart', sourceCrawler); - expect(directives, hasLength(2)); + expect(directives, hasLength(4)); DirectiveInfo info = directives.elementAt(1); expect(info.expressionAttrs, unorderedEquals(['expr', 'another-expression',