Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1261)

Unified Diff: pkg/analysis_server/test/domain_analysis_test.dart

Issue 1511833004: Validate that root paths are absolute and normalized. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/domain_analysis_test.dart
diff --git a/pkg/analysis_server/test/domain_analysis_test.dart b/pkg/analysis_server/test/domain_analysis_test.dart
index 2c6fc7b69a19d4d00881528e56b23674844955f5..b7f4b34f29144d17688d1ee19ff9bcc4a37f008d 100644
--- a/pkg/analysis_server/test/domain_analysis_test.dart
+++ b/pkg/analysis_server/test/domain_analysis_test.dart
@@ -119,6 +119,22 @@ main() {
expect(serverRef.getResolvedCompilationUnits(fileB), isEmpty);
});
});
+
+ test('not absolute', () async {
+ var response = testSetAnalysisRoots([], ['foo/bar']);
+ expect(
+ response,
+ isResponseFailure(
+ '0', RequestErrorCode.INVALID_FILE_PATH_FORMAT));
+ });
+
+ test('not normalized', () async {
+ var response = testSetAnalysisRoots([], ['/foo/../bar']);
+ expect(
+ response,
+ isResponseFailure(
+ '0', RequestErrorCode.INVALID_FILE_PATH_FORMAT));
+ });
});
group('included', () {
@@ -147,6 +163,22 @@ main() {
await server.onAnalysisComplete;
expect(serverRef.getResolvedCompilationUnits(fileB), hasLength(1));
});
+
+ test('not absolute', () async {
+ var response = testSetAnalysisRoots(['foo/bar'], []);
+ expect(
+ response,
+ isResponseFailure(
+ '0', RequestErrorCode.INVALID_FILE_PATH_FORMAT));
+ });
+
+ test('not normalized', () async {
+ var response = testSetAnalysisRoots(['/foo/../bar'], []);
+ expect(
+ response,
+ isResponseFailure(
+ '0', RequestErrorCode.INVALID_FILE_PATH_FORMAT));
+ });
});
});
@@ -167,8 +199,9 @@ main() {
resourceProvider.newFile('/p2/b.dart', 'library b;');
resourceProvider.newFile('/p2/c.dart', 'library c;');
- var setRootsRequest = new AnalysisSetAnalysisRootsParams(
- ['/p1', '/p2'], []).toRequest('0');
+ var setRootsRequest =
+ new AnalysisSetAnalysisRootsParams(['/p1', '/p2'], [])
+ .toRequest('0');
var setRootsResponse = handler.handleRequest(setRootsRequest);
expect(setRootsResponse, isResponseSuccess('0'));

Powered by Google App Engine
This is Rietveld 408576698