| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dev_compiler.test.dependency_graph_test; | 5 library dev_compiler.test.dependency_graph_test; |
| 6 | 6 |
| 7 import 'package:unittest/compact_vm_config.dart'; | 7 import 'package:unittest/compact_vm_config.dart'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 | 9 |
| 10 import 'package:dev_compiler/src/checker/dart_sdk.dart' | 10 import 'package:dev_compiler/src/checker/dart_sdk.dart' |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 | |-- a4.dart | 1121 | |-- a4.dart |
| 1122 | | |-- a10.dart | 1122 | | |-- a10.dart |
| 1123 | |-- a5.dart (part) | 1123 | |-- a5.dart (part) |
| 1124 | |-- a6.dart (part) | 1124 | |-- a6.dart (part) |
| 1125 |-- harmony_feature_check.js | 1125 |-- harmony_feature_check.js |
| 1126 |-- dart_runtime.js | 1126 |-- dart_runtime.js |
| 1127 |-- dart_core.js | 1127 |-- dart_core.js |
| 1128 '''); | 1128 '''); |
| 1129 }); | 1129 }); |
| 1130 }); | 1130 }); |
| 1131 |
| 1132 group('represented non-existing files', () { |
| 1133 test('recognize locally change between existing and not-existing', () { |
| 1134 var n = nodeOf('/foo.dart'); |
| 1135 expect(n.source, isNotNull); |
| 1136 expect(n.source.exists(), isFalse); |
| 1137 var source = testUriResolver.files[new Uri.file('/foo.dart')]; |
| 1138 expect(n.source, source); |
| 1139 source.contents.data = "hi"; |
| 1140 source.contents.modificationTime++; |
| 1141 expect(n.source.exists(), isTrue); |
| 1142 }); |
| 1143 |
| 1144 test('non-existing files are tracked in dependencies', () { |
| 1145 var node = nodeOf('/foo.dart'); |
| 1146 node.source.contents.data = "import 'bar.dart';"; |
| 1147 rebuild(node, graph, buildNoTransitiveChange); |
| 1148 expect(node.allDeps.contains(nodeOf('/bar.dart')), isTrue); |
| 1149 |
| 1150 var source = nodeOf('/bar.dart').source; |
| 1151 source.contents.data = "hi"; |
| 1152 source.contents.modificationTime++; |
| 1153 results = []; |
| 1154 rebuild(node, graph, buildWithTransitiveChange); |
| 1155 expect(results, ['bar.dart', 'foo.dart']); |
| 1156 }); |
| 1157 }); |
| 1158 |
| 1159 group('null for non-existing files', () { |
| 1160 setUp(() { |
| 1161 testUriResolver = |
| 1162 new TestUriResolver(testFiles, representNonExistingFiles: false); |
| 1163 context = new TypeResolver.fromMock(mockSdkSources, options, |
| 1164 otherResolvers: [testUriResolver]).context; |
| 1165 graph = new SourceGraph(context, new LogReporter(), options); |
| 1166 }); |
| 1167 |
| 1168 test('recognize locally change between existing and not-existing', () { |
| 1169 var n = nodeOf('/foo.dart'); |
| 1170 expect(n.source, isNull); |
| 1171 var source = new TestSource(new Uri.file('/foo.dart'), "hi"); |
| 1172 testUriResolver.files[source.uri] = source; |
| 1173 expect(n.source, isNull); |
| 1174 n.update(graph); |
| 1175 expect(n.source, source); |
| 1176 expect(n.source.exists(), isTrue); |
| 1177 expect(n.needsRebuild, isTrue); |
| 1178 }); |
| 1179 |
| 1180 test('non-existing files are tracked in dependencies', () { |
| 1181 var s1 = |
| 1182 new TestSource(new Uri.file('/foo.dart'), "import 'bar.dart';"); |
| 1183 testUriResolver.files[s1.uri] = s1; |
| 1184 var node = nodeOf('/foo.dart'); |
| 1185 rebuild(node, graph, buildNoTransitiveChange); |
| 1186 expect(node.allDeps.length, 1); |
| 1187 expect(node.allDeps.contains(nodeOf('/bar.dart')), isTrue); |
| 1188 expect(nodeOf('/bar.dart').source, isNull); |
| 1189 |
| 1190 var s2 = new TestSource(new Uri.file('/bar.dart'), "hi"); |
| 1191 testUriResolver.files[s2.uri] = s2; |
| 1192 results = []; |
| 1193 rebuild(node, graph, buildWithTransitiveChange); |
| 1194 expect(results, ['bar.dart', 'foo.dart']); |
| 1195 }); |
| 1196 }); |
| 1131 }); | 1197 }); |
| 1132 } | 1198 } |
| 1133 | 1199 |
| 1134 expectGraph(SourceNode node, String expectation) { | 1200 expectGraph(SourceNode node, String expectation) { |
| 1135 expect(printReachable(node), equalsIgnoringWhitespace(expectation)); | 1201 expect(printReachable(node), equalsIgnoringWhitespace(expectation)); |
| 1136 } | 1202 } |
| 1137 | 1203 |
| 1138 nameFor(SourceNode node) => path.basename(node.uri.path); | 1204 nameFor(SourceNode node) => path.basename(node.uri.path); |
| 1139 printReachable(SourceNode node) { | 1205 printReachable(SourceNode node) { |
| 1140 var seen = new Set(); | 1206 var seen = new Set(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1168 ..write(e.structureChanged ? '[structure-changed] ' : ' ') | 1234 ..write(e.structureChanged ? '[structure-changed] ' : ' ') |
| 1169 ..write('\n'); | 1235 ..write('\n'); |
| 1170 }); | 1236 }); |
| 1171 } | 1237 } |
| 1172 } | 1238 } |
| 1173 helper(node); | 1239 helper(node); |
| 1174 return sb.toString(); | 1240 return sb.toString(); |
| 1175 } | 1241 } |
| 1176 | 1242 |
| 1177 bool _same(Set a, Set b) => a.length == b.length && a.containsAll(b); | 1243 bool _same(Set a, Set b) => a.length == b.length && a.containsAll(b); |
| OLD | NEW |