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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/integration/analysis/get_errors_nonStandard_sdk.dart
diff --git a/pkg/analysis_server/test/integration/analysis/get_errors_nonStandard_sdk.dart b/pkg/analysis_server/test/integration/analysis/get_errors_nonStandard_sdk.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5fe22ba7b060b1b4c574ead7b9ac11e4020efac9
--- /dev/null
+++ b/pkg/analysis_server/test/integration/analysis/get_errors_nonStandard_sdk.dart
@@ -0,0 +1,96 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library test.integration.analysis.get.errors;
+
+import 'dart:async';
+import 'dart:io';
+
+import 'package:analysis_server/plugin/protocol/protocol.dart';
+import 'package:analyzer/file_system/physical_file_system.dart';
+import 'package:analyzer/src/dart/sdk/sdk.dart';
+import 'package:analyzer/src/generated/sdk.dart';
+import 'package:path/path.dart' as path;
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'package:unittest/unittest.dart';
+
+import '../../mock_sdk.dart';
+import '../../utils.dart';
+import '../integration_tests.dart';
+
+main() {
+ initializeTestEnvironment();
+ defineReflectiveTests(AnalysisDomainGetErrorsTest);
+}
+
+/**
+ * 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.
+ */
+@reflectiveTest
+class AnalysisDomainGetErrorsTest
+ extends AbstractAnalysisServerIntegrationTest {
+ AnalysisDomainGetErrorsTest();
+
+ String createNonStandardSdk() {
+ MockSdkLibrary fakeLibrary =
+ new MockSdkLibrary('dart:fake', '/lib/fake/fake.dart', '');
+ String sdkPath = path.join(sourceDirectory.path, 'sdk');
+ StringBuffer librariesContent = new StringBuffer();
+ librariesContent.writeln(
+ 'final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {');
+ MockSdk.LIBRARIES.toList()
+ ..add(fakeLibrary)
+ ..forEach((SdkLibrary library) {
+ List<String> components = path.posix.split(library.path);
+ components[0] = sdkPath;
+ String libraryPath = path.joinAll(components);
+ new Directory(path.dirname(libraryPath)).createSync(recursive: true);
+ new File(libraryPath)
+ .writeAsStringSync((library as MockSdkLibrary).content);
+
+ String relativePath = path.joinAll(components.sublist(2));
+ librariesContent.write('"');
+ librariesContent
+ .write(library.shortName.substring(5)); // Remove the 'dart:' prefix
+ librariesContent.write('": const LibraryInfo("');
+ librariesContent.write(relativePath);
+ librariesContent.writeln('"),');
+ });
+ librariesContent.writeln('};');
+
+ String librariesPath = path.joinAll([
+ sdkPath,
+ 'lib',
+ '_internal',
+ 'sdk_library_metadata',
+ 'lib',
+ 'libraries.dart'
+ ]);
+ new Directory(path.dirname(librariesPath)).createSync(recursive: true);
+ new File(librariesPath).writeAsStringSync(librariesContent.toString());
+
+ return sdkPath;
+ }
+
+ @override
+ Future startServer({int servicesPort, bool checked: true}) {
+ String sdkPath = createNonStandardSdk();
+ return server.start(
+ servicesPort: servicesPort, checked: checked, sdkPath: sdkPath);
+ }
+
+ Future test_getErrors() async {
+ String pathname = sourcePath('test.dart');
+ String text = r'''
+import 'dart:core';
+import 'dart:fake';
+''';
+ writeFile(pathname, text);
+ standardAnalysisSetup();
+ await analysisFinished;
+ List<AnalysisError> errors = currentAnalysisErrors[pathname];
+ expect(errors, hasLength(1));
+ expect(errors[0].code, 'unused_import');
+ }
+}
« 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