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

Side by Side Diff: pkg/analysis_server/test/analysis/set_priority_files_test.dart

Issue 1408163008: Fix for duplicate priority sources. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 test.analysis.set_priority_files; 5 library test.analysis.set_priority_files;
6 6
7 import 'package:analysis_server/plugin/protocol/protocol.dart'; 7 import 'package:analysis_server/plugin/protocol/protocol.dart';
8 import 'package:analysis_server/src/domain_analysis.dart'; 8 import 'package:analysis_server/src/domain_analysis.dart';
9 import 'package:analyzer/src/generated/engine.dart'
10 show InternalAnalysisContext;
11 import 'package:analyzer/src/generated/source.dart';
9 import 'package:test_reflective_loader/test_reflective_loader.dart'; 12 import 'package:test_reflective_loader/test_reflective_loader.dart';
10 import 'package:unittest/unittest.dart'; 13 import 'package:unittest/unittest.dart';
11 14
12 import '../analysis_abstract.dart'; 15 import '../analysis_abstract.dart';
13 import '../mocks.dart'; 16 import '../mocks.dart';
14 import '../utils.dart'; 17 import '../utils.dart';
15 18
16 main() { 19 main() {
17 initializeTestEnvironment(); 20 initializeTestEnvironment();
18 defineReflectiveTests(SetPriorityFilesTest); 21 defineReflectiveTests(SetPriorityFilesTest);
19 } 22 }
20 23
21 @reflectiveTest 24 @reflectiveTest
22 class SetPriorityFilesTest extends AbstractAnalysisTest { 25 class SetPriorityFilesTest extends AbstractAnalysisTest {
23 @override 26 @override
24 void setUp() { 27 void setUp() {
25 super.setUp(); 28 super.setUp();
26 server.handlers = [new AnalysisDomainHandler(server),]; 29 server.handlers = [new AnalysisDomainHandler(server),];
27 createProject(); 30 createProject();
28 } 31 }
29 32
30 test_fileDoesNotExist() async { 33 test_fileDoesNotExist() async {
31 String file = '$projectPath/doesNotExist.dart'; 34 String file = '$projectPath/doesNotExist.dart';
32 Response response = await _setPriorityFile(file); 35 Response response = await _setPriorityFile(file);
33 expect(response, isResponseSuccess('0')); 36 expect(response, isResponseSuccess('0'));
34 } 37 }
35 38
36 test_fileInAnalysisRoot() async { 39 test_fileInAnalysisRoot() async {
37 addTestFile(''); 40 addTestFile('');
41 // wait for analysis to ensure that file is know to the context
Brian Wilkerson 2015/10/30 00:08:48 "file is know" --> "the file is known"
42 await server.onAnalysisComplete;
43 // set priority files
38 Response response = await _setPriorityFile(testFile); 44 Response response = await _setPriorityFile(testFile);
39 expect(response, isResponseSuccess('0')); 45 expect(response, isResponseSuccess('0'));
46 // verify
47 InternalAnalysisContext context = server.getContainingContext(testFile);
48 List<Source> prioritySources = context.prioritySources;
49 expect(prioritySources, hasLength(1));
50 expect(prioritySources.first.fullName, testFile);
40 } 51 }
41 52
42 test_fileInSdk() async { 53 test_fileInSdk() async {
43 addTestFile(''); 54 addTestFile('');
44 await server.onAnalysisComplete; 55 await server.onAnalysisComplete;
45 Response response = await _setPriorityFile('/lib/convert/convert.dart'); 56 // set priority files
57 String filePath = '/lib/convert/convert.dart';
58 Response response = await _setPriorityFile(filePath);
46 expect(response, isResponseSuccess('0')); 59 expect(response, isResponseSuccess('0'));
60 // verify
61 InternalAnalysisContext sdkContext = server.defaultSdk.context;
62 List<Source> prioritySources = sdkContext.prioritySources;
63 expect(prioritySources, hasLength(1));
64 expect(prioritySources.first.fullName, filePath);
47 } 65 }
48 66
49 test_fileNotInAnalysisRoot() async { 67 test_fileNotInAnalysisRoot() async {
50 String path = '/other/file.dart'; 68 String path = '/other/file.dart';
51 addFile(path, ''); 69 addFile(path, '');
52 Response response = await _setPriorityFile(path); 70 Response response = await _setPriorityFile(path);
53 expect(response.error, isNotNull); 71 expect(response.error, isNotNull);
54 expect(response.error.code, RequestErrorCode.UNANALYZED_PRIORITY_FILES); 72 expect(response.error.code, RequestErrorCode.UNANALYZED_PRIORITY_FILES);
55 } 73 }
56 74
57 _setPriorityFile(String file) async { 75 _setPriorityFile(String file) async {
58 Request request = 76 Request request =
59 new AnalysisSetPriorityFilesParams(<String>[file]).toRequest('0'); 77 new AnalysisSetPriorityFilesParams(<String>[file]).toRequest('0');
60 return await serverChannel.sendRequest(request); 78 return await serverChannel.sendRequest(request);
61 } 79 }
62 } 80 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698