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

Side by Side Diff: pkg/analysis_server/test/integration/analysis/get_errors_nonStandard_sdk.dart

Issue 2276033003: Correctly use sdk passed on command-line (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 3 months 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
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
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.
4
5 library test.integration.analysis.get.errors;
6
7 import 'dart:async';
8 import 'dart:io';
9
10 import 'package:analysis_server/plugin/protocol/protocol.dart';
11 import 'package:analyzer/file_system/physical_file_system.dart';
12 import 'package:analyzer/src/dart/sdk/sdk.dart';
13 import 'package:analyzer/src/generated/sdk.dart';
14 import 'package:path/path.dart' as path;
15 import 'package:test_reflective_loader/test_reflective_loader.dart';
16 import 'package:unittest/unittest.dart';
17
18 import '../../mock_sdk.dart';
19 import '../../utils.dart';
20 import '../integration_tests.dart';
21
22 main() {
23 initializeTestEnvironment();
24 defineReflectiveTests(AnalysisDomainGetErrorsTest);
25 }
26
27 /**
28 * Base class for testing the "analysis.getErrors" request.
scheglov 2016/08/24 18:37:20 The comment seems out of sync with the tests.
Brian Wilkerson 2016/08/24 19:38:12 Done, thanks.
29 */
30 @reflectiveTest
31 class AnalysisDomainGetErrorsTest
32 extends AbstractAnalysisServerIntegrationTest {
33 AnalysisDomainGetErrorsTest();
34
35 String createNonStandardSdk() {
36 MockSdkLibrary fakeLibrary =
37 new MockSdkLibrary('dart:fake', '/lib/fake/fake.dart', '');
38 String sdkPath = path.join(sourceDirectory.path, 'sdk');
39 StringBuffer librariesContent = new StringBuffer();
40 librariesContent.writeln(
41 'final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {');
42 MockSdk.LIBRARIES.toList()
43 ..add(fakeLibrary)
44 ..forEach((SdkLibrary library) {
45 List<String> components = path.posix.split(library.path);
46 components[0] = sdkPath;
47 String libraryPath = path.joinAll(components);
48 new Directory(path.dirname(libraryPath)).createSync(recursive: true);
49 new File(libraryPath)
50 .writeAsStringSync((library as MockSdkLibrary).content);
51
52 String relativePath = path.joinAll(components.sublist(2));
53 librariesContent.write('"');
54 librariesContent
55 .write(library.shortName.substring(5)); // Remove the 'dart:' prefix
56 librariesContent.write('": const LibraryInfo("');
57 librariesContent.write(relativePath);
58 librariesContent.writeln('"),');
59 });
60 librariesContent.writeln('};');
61
62 String librariesPath = path.joinAll([
63 sdkPath,
64 'lib',
65 '_internal',
66 'sdk_library_metadata',
67 'lib',
68 'libraries.dart'
69 ]);
70 new Directory(path.dirname(librariesPath)).createSync(recursive: true);
71 new File(librariesPath).writeAsStringSync(librariesContent.toString());
72
73 return sdkPath;
74 }
75
76 @override
77 Future startServer({int servicesPort, bool checked: true}) {
78 String sdkPath = createNonStandardSdk();
79 return server.start(
80 servicesPort: servicesPort, checked: checked, sdkPath: sdkPath);
81 }
82
83 Future test_getErrors() async {
84 String pathname = sourcePath('test.dart');
85 String text = r'''
86 import 'dart:core';
87 import 'dart:fake';
88 ''';
89 writeFile(pathname, text);
90 standardAnalysisSetup();
91 await analysisFinished;
92 List<AnalysisError> errors = currentAnalysisErrors[pathname];
93 expect(errors, hasLength(1));
94 expect(errors[0].code, 'unused_import');
95 }
96 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/server/driver.dart ('k') | pkg/analysis_server/test/integration/analysis/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698