Skip to content

Commit 88408d5

Browse files
DanTupcommit-bot@chromium.org
authored andcommitted
Fix LSP refactor test on Windows
Removes the recently-added base class to tests (which brought more with it than we needed - and caused issues on Windows) and adds in the flutter/meta packages using helpers (inc extracting the meta package to a new helper). Re-enable skipped LSP refactor test Change-Id: I62f8b3e300a776cae4fbd6d15deafb5b8970eef0 Change-Id: I165b9acf75a3ec9a91feb1730be2949eb4d5e5cb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106741 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Danny Tuppeny <dantup@google.com>
1 parent 87460ad commit 88408d5

4 files changed

Lines changed: 149 additions & 110 deletions

File tree

pkg/analysis_server/test/abstract_context.dart

Lines changed: 3 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import 'package:analyzer/src/test_utilities/mock_sdk.dart';
2121
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
2222

2323
import 'src/utilities/flutter_util.dart';
24+
import 'src/utilities/meta_util.dart';
2425

2526
/**
2627
* Finds an [Element] with the given [name].
@@ -68,111 +69,8 @@ class AbstractContextTest with ResourceProviderMixin {
6869
}
6970

7071
void addMetaPackage() {
71-
addPackageFile('meta', 'meta.dart', r'''
72-
library meta;
73-
74-
const _AlwaysThrows alwaysThrows = const _AlwaysThrows();
75-
76-
@deprecated
77-
const _Checked checked = const _Checked();
78-
79-
const _Experimental experimental = const _Experimental();
80-
81-
const _Factory factory = const _Factory();
82-
83-
const Immutable immutable = const Immutable();
84-
85-
const _IsTest isTest = const _IsTest();
86-
87-
const _IsTestGroup isTestGroup = const _IsTestGroup();
88-
89-
const _Literal literal = const _Literal();
90-
91-
const _MustCallSuper mustCallSuper = const _MustCallSuper();
92-
93-
const _OptionalTypeArgs optionalTypeArgs = const _OptionalTypeArgs();
94-
95-
const _Protected protected = const _Protected();
96-
97-
const Required required = const Required();
98-
99-
const _Sealed sealed = const _Sealed();
100-
101-
@deprecated
102-
const _Virtual virtual = const _Virtual();
103-
104-
const _VisibleForOverriding visibleForOverriding =
105-
const _VisibleForOverriding();
106-
107-
const _VisibleForTesting visibleForTesting = const _VisibleForTesting();
108-
109-
class Immutable {
110-
final String reason;
111-
const Immutable([this.reason]);
112-
}
113-
114-
class Required {
115-
final String reason;
116-
const Required([this.reason]);
117-
}
118-
119-
class _AlwaysThrows {
120-
const _AlwaysThrows();
121-
}
122-
123-
class _Checked {
124-
const _Checked();
125-
}
126-
127-
class _Experimental {
128-
const _Experimental();
129-
}
130-
131-
class _Factory {
132-
const _Factory();
133-
}
134-
135-
class _IsTest {
136-
const _IsTest();
137-
}
138-
139-
class _IsTestGroup {
140-
const _IsTestGroup();
141-
}
142-
143-
class _Literal {
144-
const _Literal();
145-
}
146-
147-
class _MustCallSuper {
148-
const _MustCallSuper();
149-
}
150-
151-
class _OptionalTypeArgs {
152-
const _OptionalTypeArgs();
153-
}
154-
155-
class _Protected {
156-
const _Protected();
157-
}
158-
159-
class _Sealed {
160-
const _Sealed();
161-
}
162-
163-
@deprecated
164-
class _Virtual {
165-
const _Virtual();
166-
}
167-
168-
class _VisibleForOverriding {
169-
const _VisibleForOverriding();
170-
}
171-
172-
class _VisibleForTesting {
173-
const _VisibleForTesting();
174-
}
175-
''');
72+
Folder libFolder = configureMetaPackage(resourceProvider);
73+
addTestPackageDependency('meta', libFolder.parent.path);
17674
}
17775

17876
/// Add a new file with the given [pathInLib] to the package with the

pkg/analysis_server/test/lsp/code_actions_refactor_test.dart

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import 'package:analysis_server/src/lsp/constants.dart';
66
import 'package:test/test.dart';
77
import 'package:test_reflective_loader/test_reflective_loader.dart';
88

9+
import '../src/utilities/flutter_util.dart' as flutter;
10+
import '../src/utilities/meta_util.dart' as meta;
911
import 'code_actions_abstract.dart';
1012

1113
main() {
1214
defineReflectiveSuite(() {
1315
defineReflectiveTests(ExtractMethodRefactorCodeActionsTest);
14-
// TODO(dantup): Restore this once the tests are fixed for Windows.
15-
//defineReflectiveTests(ExtractWidgetRefactorCodeActionsTest);
16+
defineReflectiveTests(ExtractWidgetRefactorCodeActionsTest);
1617
});
1718
}
1819

@@ -68,8 +69,21 @@ main() {}
6869
@reflectiveTest
6970
class ExtractWidgetRefactorCodeActionsTest extends AbstractCodeActionsTest {
7071
final extractWidgetTitle = 'Extract Widget';
72+
73+
@override
74+
void setUp() {
75+
super.setUp();
76+
77+
final flutterLibFolder = flutter.configureFlutterPackage(resourceProvider);
78+
final metaLibFolder = meta.configureMetaPackage(resourceProvider);
79+
// Create .packages in the project.
80+
newFile(join(projectFolderPath, '.packages'), content: '''
81+
flutter:${flutterLibFolder.toUri()}
82+
meta:${metaLibFolder.toUri()}
83+
''');
84+
}
85+
7186
test_appliesCorrectEdits() async {
72-
addFlutterPackage();
7387
const content = '''
7488
import 'package:flutter/material.dart';
7589

pkg/analysis_server/test/lsp/server_abstract.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import 'package:meta/meta.dart';
2121
import 'package:path/path.dart' as path;
2222
import 'package:test/test.dart';
2323

24-
import '../abstract_context.dart';
2524
import '../mocks.dart';
2625

2726
const dartLanguageId = 'dart';
@@ -844,7 +843,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
844843
contents.replaceAll(rangeMarkerStart, '').replaceAll(rangeMarkerEnd, '');
845844
}
846845

847-
abstract class AbstractLspAnalysisServerTest extends AbstractContextTest
846+
abstract class AbstractLspAnalysisServerTest
848847
with
849848
ResourceProviderMixin,
850849
ClientCapabilitiesHelperMixin,
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
// Copyright (c) 2019, 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+
import 'package:analyzer/file_system/file_system.dart';
6+
import 'package:analyzer/file_system/memory_file_system.dart';
7+
8+
const String metaPkgLibPath = '/packages/meta/lib';
9+
10+
/**
11+
* Add a meta library and types to the given [provider] and return
12+
* the `lib` folder.
13+
*/
14+
Folder configureMetaPackage(MemoryResourceProvider provider) {
15+
File newFile(String path, String content) =>
16+
provider.newFile(provider.convertPath(path), content ?? '');
17+
18+
Folder newFolder(String path) =>
19+
provider.newFolder(provider.convertPath(path));
20+
21+
newFile('$metaPkgLibPath/meta.dart', r'''
22+
library meta;
23+
24+
const _AlwaysThrows alwaysThrows = const _AlwaysThrows();
25+
26+
@deprecated
27+
const _Checked checked = const _Checked();
28+
29+
const _Experimental experimental = const _Experimental();
30+
31+
const _Factory factory = const _Factory();
32+
33+
const Immutable immutable = const Immutable();
34+
35+
const _IsTest isTest = const _IsTest();
36+
37+
const _IsTestGroup isTestGroup = const _IsTestGroup();
38+
39+
const _Literal literal = const _Literal();
40+
41+
const _MustCallSuper mustCallSuper = const _MustCallSuper();
42+
43+
const _OptionalTypeArgs optionalTypeArgs = const _OptionalTypeArgs();
44+
45+
const _Protected protected = const _Protected();
46+
47+
const Required required = const Required();
48+
49+
const _Sealed sealed = const _Sealed();
50+
51+
@deprecated
52+
const _Virtual virtual = const _Virtual();
53+
54+
const _VisibleForOverriding visibleForOverriding =
55+
const _VisibleForOverriding();
56+
57+
const _VisibleForTesting visibleForTesting = const _VisibleForTesting();
58+
59+
class Immutable {
60+
final String reason;
61+
const Immutable([this.reason]);
62+
}
63+
64+
class Required {
65+
final String reason;
66+
const Required([this.reason]);
67+
}
68+
69+
class _AlwaysThrows {
70+
const _AlwaysThrows();
71+
}
72+
73+
class _Checked {
74+
const _Checked();
75+
}
76+
77+
class _Experimental {
78+
const _Experimental();
79+
}
80+
81+
class _Factory {
82+
const _Factory();
83+
}
84+
85+
class _IsTest {
86+
const _IsTest();
87+
}
88+
89+
class _IsTestGroup {
90+
const _IsTestGroup();
91+
}
92+
93+
class _Literal {
94+
const _Literal();
95+
}
96+
97+
class _MustCallSuper {
98+
const _MustCallSuper();
99+
}
100+
101+
class _OptionalTypeArgs {
102+
const _OptionalTypeArgs();
103+
}
104+
105+
class _Protected {
106+
const _Protected();
107+
}
108+
109+
class _Sealed {
110+
const _Sealed();
111+
}
112+
113+
@deprecated
114+
class _Virtual {
115+
const _Virtual();
116+
}
117+
118+
class _VisibleForOverriding {
119+
const _VisibleForOverriding();
120+
}
121+
122+
class _VisibleForTesting {
123+
const _VisibleForTesting();
124+
}
125+
''');
126+
127+
return newFolder(metaPkgLibPath);
128+
}

0 commit comments

Comments
 (0)