mirror of
https://github.com/dart-lang/sdk
synced 2024-09-04 16:03:44 +00:00
Replace more Bazel with Blaze, some simplifications.
Change-Id: I096860e17ce56c2f602718f11706f24989c1f65b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255141 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
c66faf9f3a
commit
4eb511da43
|
@ -157,7 +157,7 @@ abstract class AnalysisServer {
|
|||
ProcessRunner? processRunner,
|
||||
this.notificationManager, {
|
||||
this.requestStatistics,
|
||||
bool enableBazelWatcher = false,
|
||||
bool enableBlazeWatcher = false,
|
||||
}) : resourceProvider = OverlayResourceProvider(baseResourceProvider),
|
||||
pubApi = PubApi(instrumentationService, httpClient,
|
||||
Platform.environment['PUB_HOSTED_URL']) {
|
||||
|
@ -228,7 +228,7 @@ abstract class AnalysisServer {
|
|||
analysisPerformanceLogger,
|
||||
analysisDriverScheduler,
|
||||
instrumentationService,
|
||||
enableBazelWatcher: enableBazelWatcher,
|
||||
enableBlazeWatcher: enableBlazeWatcher,
|
||||
);
|
||||
searchEngine = SearchEngineImpl(driverMap.values);
|
||||
}
|
||||
|
|
|
@ -35,14 +35,14 @@ import 'package:path/path.dart' as path;
|
|||
import 'package:watcher/watcher.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
/// Enables watching of files generated by Bazel.
|
||||
/// Enables watching of files generated by Blaze.
|
||||
///
|
||||
/// TODO(michalt): This is a temporary flag that we use to disable this
|
||||
/// functionality due its performance issues. We plan to benchmark and optimize
|
||||
/// it and re-enable it everywhere.
|
||||
/// Not private to enable testing.
|
||||
/// NB: If you set this to `false` remember to disable the
|
||||
/// `test/integration/serve/bazel_changes_test.dart`.
|
||||
/// `test/integration/serve/blaze_changes_test.dart`.
|
||||
var experimentalEnableBlazeWatching = true;
|
||||
|
||||
/// Class that maintains a mapping from included/excluded paths to a set of
|
||||
|
@ -193,20 +193,20 @@ class ContextManagerImpl implements ContextManager {
|
|||
/// Subscriptions to watch included resources for changes.
|
||||
final List<StreamSubscription<WatchEvent>> watcherSubscriptions = [];
|
||||
|
||||
/// For each folder, stores the subscription to the Bazel workspace so that we
|
||||
/// For each folder, stores the subscription to the Blaze workspace so that we
|
||||
/// can establish watches for the generated files.
|
||||
final blazeSearchSubscriptions =
|
||||
<Folder, StreamSubscription<BlazeSearchInfo>>{};
|
||||
|
||||
/// The watcher service running in a separate isolate to watch for changes
|
||||
/// to files generated by Bazel.
|
||||
/// to files generated by Blaze.
|
||||
///
|
||||
/// Might be `null` if watching Bazel files is not enabled.
|
||||
/// Might be `null` if watching Blaze files is not enabled.
|
||||
BlazeFileWatcherService? blazeWatcherService;
|
||||
|
||||
/// The subscription to changes in the files watched by [blazeWatcherService].
|
||||
///
|
||||
/// Might be `null` if watching Bazel files is not enabled.
|
||||
/// Might be `null` if watching Blaze files is not enabled.
|
||||
StreamSubscription<List<WatchEvent>>? blazeWatcherSubscription;
|
||||
|
||||
/// For each [Folder] store which files are being watched. This allows us to
|
||||
|
@ -233,9 +233,9 @@ class ContextManagerImpl implements ContextManager {
|
|||
this._performanceLog,
|
||||
this._scheduler,
|
||||
this._instrumentationService,
|
||||
{required bool enableBazelWatcher})
|
||||
{required bool enableBlazeWatcher})
|
||||
: pathContext = resourceProvider.pathContext {
|
||||
if (enableBazelWatcher) {
|
||||
if (enableBlazeWatcher) {
|
||||
blazeWatcherService = BlazeFileWatcherService(_instrumentationService);
|
||||
blazeWatcherSubscription = blazeWatcherService!.events
|
||||
.listen((events) => _handleBlazeWatchEvents(events));
|
||||
|
@ -630,7 +630,6 @@ class ContextManagerImpl implements ContextManager {
|
|||
for (var path in watched.paths) {
|
||||
blazeWatcherService!.stopWatching(watched.workspace, path);
|
||||
}
|
||||
_stopWatchingBlazeBinPaths(watched);
|
||||
}
|
||||
blazeSearchSubscriptions.remove(rootFolder)?.cancel();
|
||||
driverMap.remove(rootFolder);
|
||||
|
@ -650,16 +649,11 @@ class ContextManagerImpl implements ContextManager {
|
|||
}
|
||||
}
|
||||
|
||||
List<String> _getPossibleBlazeBinPaths(_BlazeWatchedFiles watched) => [
|
||||
pathContext.join(watched.workspace, 'bazel-bin'),
|
||||
pathContext.join(watched.workspace, 'blaze-bin'),
|
||||
];
|
||||
|
||||
/// Establishes watch(es) for the Bazel generated files provided in
|
||||
/// Establishes watch(es) for the Blaze generated files provided in
|
||||
/// [notification].
|
||||
///
|
||||
/// Whenever the files change, we trigger re-analysis. This allows us to react
|
||||
/// to creation/modification of files that were generated by Bazel.
|
||||
/// to creation/modification of files that were generated by Blaze.
|
||||
void _handleBlazeSearchInfo(
|
||||
Folder folder, String workspace, BlazeSearchInfo info) {
|
||||
final blazeWatcherService = this.blazeWatcherService;
|
||||
|
@ -673,19 +667,8 @@ class ContextManagerImpl implements ContextManager {
|
|||
if (added) blazeWatcherService.startWatching(workspace, info);
|
||||
}
|
||||
|
||||
/// Notifies the drivers that a generated Bazel file has changed.
|
||||
/// Notifies the drivers that a generated Blaze file has changed.
|
||||
void _handleBlazeWatchEvents(List<WatchEvent> events) {
|
||||
// First check if we have any changes to the bazel-*/blaze-* paths. If
|
||||
// we do, we'll simply recreate all contexts to make sure that we follow the
|
||||
// correct paths.
|
||||
var bazelSymlinkPaths = blazeWatchedPathsPerFolder.values
|
||||
.expand((watched) => _getPossibleBlazeBinPaths(watched))
|
||||
.toSet();
|
||||
if (events.any((event) => bazelSymlinkPaths.contains(event.path))) {
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
// If a file was created or removed, the URI resolution is likely wrong.
|
||||
// Do as for `package_config.json` changes - recreate all contexts.
|
||||
if (events
|
||||
|
@ -807,34 +790,12 @@ class ContextManagerImpl implements ContextManager {
|
|||
existingExcludedSet.containsAll(excludedPaths);
|
||||
}
|
||||
|
||||
/// Starts watching for the `bazel-bin` and `blaze-bin` symlinks.
|
||||
///
|
||||
/// This is important since these symlinks might not be present when the
|
||||
/// server starts up, in which case `BazelWorkspace` assumes by default the
|
||||
/// Bazel ones. So we want to detect if the symlinks get created to reset
|
||||
/// everything and repeat the search for the folders.
|
||||
void _startWatchingBlazeBinPaths(_BlazeWatchedFiles watched) {
|
||||
var watcherService = blazeWatcherService;
|
||||
if (watcherService == null) return;
|
||||
var paths = _getPossibleBlazeBinPaths(watched);
|
||||
watcherService.startWatching(
|
||||
watched.workspace, BlazeSearchInfo(paths[0], paths));
|
||||
}
|
||||
|
||||
/// Stops watching for the `bazel-bin` and `blaze-bin` symlinks.
|
||||
void _stopWatchingBlazeBinPaths(_BlazeWatchedFiles watched) {
|
||||
var watcherService = blazeWatcherService;
|
||||
if (watcherService == null) return;
|
||||
var paths = _getPossibleBlazeBinPaths(watched);
|
||||
watcherService.stopWatching(watched.workspace, paths[0]);
|
||||
}
|
||||
|
||||
/// Listens to files generated by Bazel that were found or searched for.
|
||||
/// Listens to files generated by Blaze that were found or searched for.
|
||||
///
|
||||
/// This is handled specially because the files are outside the package
|
||||
/// folder, but we still want to watch for changes to them.
|
||||
///
|
||||
/// Does nothing if the [driver] is not in a Bazel workspace.
|
||||
/// Does nothing if the [analysisDriver] is not in a Blaze workspace.
|
||||
void _watchBlazeFilesIfNeeded(Folder folder, AnalysisDriver analysisDriver) {
|
||||
if (!experimentalEnableBlazeWatching) return;
|
||||
var watcherService = blazeWatcherService;
|
||||
|
@ -849,7 +810,6 @@ class ContextManagerImpl implements ContextManager {
|
|||
|
||||
var watched = _BlazeWatchedFiles(workspace.root);
|
||||
blazeWatchedPathsPerFolder[folder] = watched;
|
||||
_startWatchingBlazeBinPaths(watched);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -381,7 +381,7 @@ class LegacyAnalysisServer extends AnalysisServer {
|
|||
DiagnosticServer? diagnosticServer,
|
||||
this.detachableFileSystemManager,
|
||||
// Disable to avoid using this in unit tests.
|
||||
bool enableBazelWatcher = false,
|
||||
bool enableBlazeWatcher = false,
|
||||
}) : super(
|
||||
options,
|
||||
sdkManager,
|
||||
|
@ -394,7 +394,7 @@ class LegacyAnalysisServer extends AnalysisServer {
|
|||
processRunner,
|
||||
NotificationManager(channel, baseResourceProvider.pathContext),
|
||||
requestStatistics: requestStatistics,
|
||||
enableBazelWatcher: enableBazelWatcher,
|
||||
enableBlazeWatcher: enableBlazeWatcher,
|
||||
) {
|
||||
var contextManagerCallbacks =
|
||||
ServerContextManagerCallbacks(this, resourceProvider);
|
||||
|
|
|
@ -140,7 +140,7 @@ class LspAnalysisServer extends AnalysisServer {
|
|||
DiagnosticServer? diagnosticServer,
|
||||
this.detachableFileSystemManager,
|
||||
// Disable to avoid using this in unit tests.
|
||||
bool enableBazelWatcher = false,
|
||||
bool enableBlazeWatcher = false,
|
||||
}) : super(
|
||||
options,
|
||||
sdkManager,
|
||||
|
@ -152,7 +152,7 @@ class LspAnalysisServer extends AnalysisServer {
|
|||
httpClient,
|
||||
processRunner,
|
||||
LspNotificationManager(channel, baseResourceProvider.pathContext),
|
||||
enableBazelWatcher: enableBazelWatcher,
|
||||
enableBlazeWatcher: enableBlazeWatcher,
|
||||
) {
|
||||
notificationManager.server = this;
|
||||
messageHandler = UninitializedStateMessageHandler(this);
|
||||
|
|
|
@ -89,7 +89,7 @@ class LspSocketServer implements AbstractSocketServer {
|
|||
instrumentationService,
|
||||
diagnosticServer: diagnosticServer,
|
||||
detachableFileSystemManager: detachableFileSystemManager,
|
||||
enableBazelWatcher: true,
|
||||
enableBlazeWatcher: true,
|
||||
);
|
||||
detachableFileSystemManager?.setAnalysisServer(server);
|
||||
}
|
||||
|
|
|
@ -85,9 +85,9 @@ String _getPath(ResourceProvider provider, Element? e,
|
|||
}
|
||||
|
||||
var path = source.fullName;
|
||||
var bazelWorkspace = BlazeWorkspace.find(provider, path);
|
||||
if (bazelWorkspace != null) {
|
||||
return provider.pathContext.relative(path, from: bazelWorkspace.root);
|
||||
var blazeWorkspace = BlazeWorkspace.find(provider, path);
|
||||
if (blazeWorkspace != null) {
|
||||
return provider.pathContext.relative(path, from: blazeWorkspace.root);
|
||||
}
|
||||
var gnWorkspace = GnWorkspace.find(provider, path);
|
||||
if (gnWorkspace != null) {
|
||||
|
|
|
@ -93,7 +93,7 @@ class SocketServer implements AbstractSocketServer {
|
|||
requestStatistics: requestStatistics,
|
||||
diagnosticServer: diagnosticServer,
|
||||
detachableFileSystemManager: detachableFileSystemManager,
|
||||
enableBazelWatcher: true,
|
||||
enableBlazeWatcher: true,
|
||||
);
|
||||
detachableFileSystemManager?.setAnalysisServer(server);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ void main() {
|
|||
class AnalysisHoverBlazeTest extends BlazeWorkspaceAnalysisServerTest {
|
||||
Future<void> test_blaze_notOwnedUri() async {
|
||||
newFile(
|
||||
'$workspaceRootPath/bazel-genfiles/dart/my/lib/test.dart',
|
||||
'$workspaceRootPath/blaze-genfiles/dart/my/lib/test.dart',
|
||||
'// generated',
|
||||
);
|
||||
|
||||
|
|
|
@ -62,15 +62,13 @@ class BlazeChangesTest extends AbstractAnalysisServerIntegrationTest {
|
|||
sourceDirectory = Directory(inWorkspace('third_party/dart/project'));
|
||||
sourceDirectory.createSync(recursive: true);
|
||||
|
||||
blazeRoot = inTmpDir('bazel_or_blaze_root');
|
||||
blazeRoot = inTmpDir('blaze_root');
|
||||
Directory(blazeRoot).createSync(recursive: true);
|
||||
|
||||
blazeOutPath =
|
||||
'$blazeRoot/execroot/bazel_or_blaze_workspace/bazel_or_blaze-out';
|
||||
blazeBinPath =
|
||||
'$blazeRoot/execroot/bazel_or_blaze_workspace/bazel_or_blaze-out/bin';
|
||||
blazeOutPath = '$blazeRoot/execroot/blaze_workspace/blaze-out';
|
||||
blazeBinPath = '$blazeRoot/execroot/blaze_workspace/blaze-out/bin';
|
||||
blazeGenfilesPath =
|
||||
'$blazeRoot/execroot/bazel_or_blaze_workspace/bazel_or_blaze-out/genfiles';
|
||||
'$blazeRoot/execroot/blaze_workspace/blaze-out/genfiles';
|
||||
|
||||
Directory(inTmpDir(blazeOutPath)).createSync(recursive: true);
|
||||
Directory(inTmpDir(blazeBinPath)).createSync(recursive: true);
|
||||
|
|
|
@ -46,7 +46,7 @@ class InitializationTest extends AbstractLspAnalysisServerTest {
|
|||
|
||||
Future<void> test_blazeWorkspace() async {
|
||||
var workspacePath = '/home/user/ws';
|
||||
// Make it a Bazel workspace.
|
||||
// Make it a Blaze workspace.
|
||||
newFile('$workspacePath/${file_paths.blazeWorkspaceMarker}', '');
|
||||
|
||||
var packagePath = '$workspacePath/team/project1';
|
||||
|
@ -816,7 +816,7 @@ class InitializationTest extends AbstractLspAnalysisServerTest {
|
|||
final file1 = convertPath('/home/nonProject/file1.dart');
|
||||
newFile(file1, '');
|
||||
|
||||
// Make /home a bazel workspace.
|
||||
// Make /home a Blaze workspace.
|
||||
newFile('/home/${file_paths.blazeWorkspaceMarker}', '');
|
||||
|
||||
await initialize(allowEmptyRootUri: true);
|
||||
|
|
|
@ -78,7 +78,7 @@ import 'package:test/222/new_name.dart';
|
|||
|
||||
@failingTest
|
||||
Future<void> test_file_imported_with_package_uri_lib_change() async {
|
||||
// The current testing stack does not support creating such bazel roots
|
||||
// The current testing stack does not support creating such Blaze roots
|
||||
var file = newFile('/home/test0/test1/test2/lib/111/name.dart', '');
|
||||
addTestSource(r'''
|
||||
import 'package:test0.test1.test2/111/name.dart';
|
||||
|
@ -101,7 +101,7 @@ import 'package:test0.test1.test3/111/name.dart';
|
|||
|
||||
@failingTest
|
||||
Future<void> test_file_imported_with_package_uri_lib_change_down() async {
|
||||
// The current testing stack does not support creating such bazel roots
|
||||
// The current testing stack does not support creating such Blaze roots
|
||||
var file = newFile('/home/test0/test1/test2/lib/111/name.dart', '');
|
||||
addTestSource(r'''
|
||||
import 'package:test0.test1.test2/111/name.dart';
|
||||
|
@ -124,7 +124,7 @@ import 'package:test0.test1.test2.test3/111/name.dart';
|
|||
|
||||
@failingTest
|
||||
Future<void> test_file_imported_with_package_uri_lib_change_up() async {
|
||||
// The current testing stack does not support creating such bazel roots
|
||||
// The current testing stack does not support creating such Blaze roots
|
||||
var file = newFile('/home/test0/test1/test2/lib/111/name.dart', '');
|
||||
addTestSource(r'''
|
||||
import 'package:test0.test1.test2/111/name.dart';
|
||||
|
|
|
@ -493,11 +493,11 @@ class PluginManagerTest with ResourceProviderMixin, _ContextRoot {
|
|||
|
||||
void test_pathsFor_withPubspec_inBlazeWorkspace() {
|
||||
//
|
||||
// Build a Bazel workspace containing four packages, including the plugin.
|
||||
// Build a Blaze workspace containing four packages, including the plugin.
|
||||
//
|
||||
newFile('/workspaceRoot/${file_paths.blazeWorkspaceMarker}', '');
|
||||
newFolder('/workspaceRoot/bazel-bin');
|
||||
newFolder('/workspaceRoot/bazel-genfiles');
|
||||
newFolder('/workspaceRoot/blaze-bin');
|
||||
newFolder('/workspaceRoot/blaze-genfiles');
|
||||
|
||||
String newPackage(String packageName, [List<String>? dependencies]) {
|
||||
var packageRoot =
|
||||
|
|
|
@ -38,7 +38,7 @@ void _cacheFiles(Map<String, String> cachedFiles) {
|
|||
}
|
||||
|
||||
/// Helper for copying files from "tests/mock_packages" to memory file system
|
||||
/// for Bazel.
|
||||
/// for Blaze.
|
||||
class BlazeMockPackages {
|
||||
static final BlazeMockPackages instance = BlazeMockPackages._();
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ class NotLibraryButPartResult
|
|||
/// The type of [InvalidResult] returned when the given file path does not
|
||||
/// represent the corresponding URI.
|
||||
///
|
||||
/// This usually happens in Bazel workspaces, when a URI is resolved to
|
||||
/// This usually happens in Blaze workspaces, when a URI is resolved to
|
||||
/// a generated file, but there is also a writable file to which this URI
|
||||
/// would be resolved, if there were no generated file.
|
||||
///
|
||||
|
|
|
@ -1352,7 +1352,7 @@ class FileSystemState {
|
|||
/// Return `true` if there is a URI that can be resolved to the [path].
|
||||
///
|
||||
/// When a file exists, but for the URI that corresponds to the file is
|
||||
/// resolved to another file, e.g. a generated one in Bazel, Gn, etc, we
|
||||
/// resolved to another file, e.g. a generated one in Blaze, Gn, etc, we
|
||||
/// cannot analyze the original file.
|
||||
bool hasUri(String path) {
|
||||
bool? flag = _hasUriForPath[path];
|
||||
|
|
|
@ -164,7 +164,7 @@ class DeclarationsContext {
|
|||
///
|
||||
/// We include libraries from this list only when actual context dependencies
|
||||
/// are not known. Dependencies are always know for Pub packages, but are
|
||||
/// currently never known for Bazel packages.
|
||||
/// currently never known for Blaze packages.
|
||||
final List<String> _knownPathList = [];
|
||||
|
||||
DeclarationsContext(this._tracker, this._analysisContext);
|
||||
|
@ -190,7 +190,7 @@ class DeclarationsContext {
|
|||
/// of packages listed as `dependencies`, and files in the `test` directory
|
||||
/// can in addition access libraries of packages listed as `dev_dependencies`.
|
||||
///
|
||||
/// With `Bazel` sets of accessible libraries are specified explicitly by
|
||||
/// With `Blaze` sets of accessible libraries are specified explicitly by
|
||||
/// the client using [setDependencies].
|
||||
Libraries getLibraries(String path) {
|
||||
var sdkLibraries = <Library>[];
|
||||
|
@ -237,7 +237,7 @@ class DeclarationsContext {
|
|||
contextPathList = _contextPathList;
|
||||
}
|
||||
} else {
|
||||
// In bazel workspaces, consider declarations from the entire context
|
||||
// In Blaze workspaces, consider declarations from the entire context
|
||||
contextPathList = _contextPathList;
|
||||
}
|
||||
|
||||
|
@ -261,7 +261,7 @@ class DeclarationsContext {
|
|||
///
|
||||
/// For `Pub` packages this method is invoked automatically, because their
|
||||
/// dependencies, described in `pubspec.yaml` files, and can be automatically
|
||||
/// included. This method is useful for `Bazel` contexts, where dependencies
|
||||
/// included. This method is useful for `Blaze` contexts, where dependencies
|
||||
/// are specified externally, in form of `BUILD` files.
|
||||
///
|
||||
/// New dependencies will replace any previously set dependencies for this
|
||||
|
@ -651,7 +651,7 @@ class DeclarationsTracker {
|
|||
|
||||
/// Pull known files into [DeclarationsContext]s.
|
||||
///
|
||||
/// This is a temporary support for Bazel repositories, because IDEA
|
||||
/// This is a temporary support for Blaze repositories, because IDEA
|
||||
/// does not yet give us dependencies for them.
|
||||
@visibleForTesting
|
||||
void pullKnownFiles() {
|
||||
|
@ -1235,7 +1235,7 @@ class _File {
|
|||
pathKey = '${pathKeyBuilder.toHex()}.declarations_content';
|
||||
}
|
||||
|
||||
// With Bazel multiple workspaces might be copies of the same workspace,
|
||||
// With Blaze multiple workspaces might be copies of the same workspace,
|
||||
// and have files with the same content, but with different paths.
|
||||
// So, we use the content hash to reuse their declarations without parsing.
|
||||
String? content;
|
||||
|
@ -2113,7 +2113,7 @@ class _LibraryWalker extends graph.DependencyWalker<_LibraryNode> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Information about a package: `Pub` or `Bazel`.
|
||||
/// Information about a package: `Pub` or `Blaze`.
|
||||
class _Package {
|
||||
final Folder root;
|
||||
final Folder lib;
|
||||
|
|
|
@ -14,11 +14,10 @@ import 'package:analyzer/src/util/file_paths.dart' as file_paths;
|
|||
import 'package:analyzer/src/util/uri.dart';
|
||||
import 'package:analyzer/src/workspace/blaze_watcher.dart';
|
||||
import 'package:analyzer/src/workspace/workspace.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:pub_semver/pub_semver.dart';
|
||||
|
||||
/// Instances of the class `BazelFileUriResolver` resolve `file` URI's by first
|
||||
/// Instances of the class `BlazeFileUriResolver` resolve `file` URI's by first
|
||||
/// resolving file uri's in the expected way, and then by looking in the
|
||||
/// corresponding generated directories.
|
||||
class BlazeFileUriResolver extends ResourceUriResolver {
|
||||
|
@ -176,20 +175,16 @@ class BlazePackageUriResolver extends UriResolver {
|
|||
}
|
||||
}
|
||||
|
||||
/// Information about a Bazel workspace.
|
||||
/// Information about a Blaze workspace.
|
||||
class BlazeWorkspace extends Workspace
|
||||
implements WorkspaceWithDefaultAnalysisOptions {
|
||||
static const String _READONLY = 'READONLY';
|
||||
|
||||
/// The name of the file that identifies a set of Bazel Targets.
|
||||
/// The name of the file that identifies a set of Blaze Targets.
|
||||
///
|
||||
/// For Dart package purposes, a BUILD file identifies a package.
|
||||
static const String _buildFileName = 'BUILD';
|
||||
|
||||
/// Default prefix for "-genfiles" and "-bin" that will be assumed if no build
|
||||
/// output symlinks are found.
|
||||
static const defaultSymlinkPrefix = 'bazel';
|
||||
|
||||
final ResourceProvider provider;
|
||||
|
||||
/// The absolute workspace root path.
|
||||
|
@ -199,20 +194,17 @@ class BlazeWorkspace extends Workspace
|
|||
@override
|
||||
final String root;
|
||||
|
||||
/// Either `blaze` or `bazel`.
|
||||
final String symlinkPrefix;
|
||||
|
||||
/// The absolute path to the optional read only workspace root, in the
|
||||
/// `READONLY` folder if a git-based workspace, or `null`.
|
||||
final String? readonly;
|
||||
|
||||
/// The absolute paths to all `bazel-bin` folders.
|
||||
/// The absolute paths to all `blaze-bin` folders.
|
||||
///
|
||||
/// In practice, there is usually one "bin" path, and sometimes there are two,
|
||||
/// on distributed build systems. It is very rare to have more than two.
|
||||
final List<String> binPaths;
|
||||
|
||||
/// The absolute path to the `bazel-genfiles` folder.
|
||||
/// The absolute path to the `blaze-genfiles` folder.
|
||||
final String genfiles;
|
||||
|
||||
/// Sometimes `BUILD` files are not preserved, and `xyz.packages` files
|
||||
|
@ -232,7 +224,6 @@ class BlazeWorkspace extends Workspace
|
|||
BlazeWorkspace._(
|
||||
this.provider,
|
||||
this.root,
|
||||
this.symlinkPrefix,
|
||||
this.readonly,
|
||||
this.binPaths,
|
||||
this.genfiles, {
|
||||
|
@ -269,7 +260,7 @@ class BlazeWorkspace extends Workspace
|
|||
}
|
||||
|
||||
/// Return the file with the given [absolutePath], looking first into
|
||||
/// directories for generated files: `bazel-bin` and `bazel-genfiles`, and
|
||||
/// directories for generated files: `blaze-bin` and `blaze-genfiles`, and
|
||||
/// then into the workspace root. The file in the workspace root is returned
|
||||
/// even if it does not exist. Return `null` if the given [absolutePath] is
|
||||
/// not in the workspace [root].
|
||||
|
@ -284,10 +275,8 @@ class BlazeWorkspace extends Workspace
|
|||
// symlinks and not the [binPaths] or [genfiles] to make sure we use the
|
||||
// files corresponding to the most recent build configuration and get
|
||||
// consistent view of all the generated files.
|
||||
var generatedCandidates = [
|
||||
'$symlinkPrefix-genfiles',
|
||||
'$symlinkPrefix-bin'
|
||||
].map((prefix) => context.join(root, context.join(prefix, relative)));
|
||||
var generatedCandidates = ['blaze-genfiles', 'blaze-bin']
|
||||
.map((prefix) => context.join(root, context.join(prefix, relative)));
|
||||
for (var path in generatedCandidates) {
|
||||
File file = provider.getFile(path);
|
||||
if (file.exists) {
|
||||
|
@ -334,7 +323,7 @@ class BlazeWorkspace extends Workspace
|
|||
return null;
|
||||
}
|
||||
|
||||
// Handle files which are given with their location in "bazel-bin", etc.
|
||||
// Handle files which are given with their location in "blaze-bin", etc.
|
||||
// This does not typically happen during usual analysis, but it still could,
|
||||
// and it can come up in tests.
|
||||
for (var binPath in [genfiles, ...binPaths]) {
|
||||
|
@ -388,7 +377,7 @@ class BlazeWorkspace extends Workspace
|
|||
/// package's root. A ".packages" file found in [folder]'s sister path
|
||||
/// under a "bin" path among [binPaths] denotes a Dart package.
|
||||
///
|
||||
/// For example, if the [root] of this BazelWorkspace is
|
||||
/// For example, if the [root] of this BlazeWorkspace is
|
||||
/// "/build/work/abc123/workspace" with two "bin" folders,
|
||||
/// "/build/work/abc123/workspace/blaze-out/host/bin/" and
|
||||
/// "/build/work/abc123/workspace/blaze-out/k8-opt/bin/", and [folder]
|
||||
|
@ -446,18 +435,18 @@ class BlazeWorkspace extends Workspace
|
|||
return null;
|
||||
}
|
||||
|
||||
/// Find the Bazel workspace that contains the given [filePath].
|
||||
/// Find the Blaze workspace that contains the given [filePath].
|
||||
///
|
||||
/// This method walks up the file system from [filePath], looking for various
|
||||
/// "marker" files which indicate a Bazel workspace.
|
||||
/// "marker" files which indicate a Blaze workspace.
|
||||
///
|
||||
/// At each folder _f_ with parent _p_, starting with [filePath]:
|
||||
///
|
||||
/// * If _f_ has a sibling folder named "READONLY", and that folder has a
|
||||
/// child folder with the same name as _f_, then a [BlazeWorkspace] rooted at
|
||||
/// _f_ is returned.
|
||||
/// * If _f_ has a child folder named "blaze-out" or "bazel-out", then a
|
||||
/// [BlazeWorkspace] rooted at _f_ is returned.
|
||||
/// * If _f_ has a child folder named "blaze-out", then a [BlazeWorkspace]
|
||||
/// rooted at _f_ is returned.
|
||||
/// * If _f_ has a child file named [file_paths.blazeWorkspaceMarker], then
|
||||
/// a [BlazeWorkspace] rooted at _f_ is returned.
|
||||
static BlazeWorkspace? find(
|
||||
|
@ -478,29 +467,21 @@ class BlazeWorkspace extends Workspace
|
|||
context.join(readonlyFolder.path, folder.shortName);
|
||||
if (provider.getFolder(readonlyRoot).exists) {
|
||||
var binPaths = _findBinFolderPaths(folder);
|
||||
String symlinkPrefix =
|
||||
_findSymlinkPrefix(provider, root, binPaths: binPaths);
|
||||
binPaths = binPaths..add(context.join(root, '$symlinkPrefix-bin'));
|
||||
return BlazeWorkspace._(provider, root, symlinkPrefix, readonlyRoot,
|
||||
binPaths, context.join(root, '$symlinkPrefix-genfiles'),
|
||||
binPaths = binPaths..add(context.join(root, 'blaze-bin'));
|
||||
return BlazeWorkspace._(provider, root, readonlyRoot, binPaths,
|
||||
context.join(root, 'blaze-genfiles'),
|
||||
lookForBuildFileSubstitutes: lookForBuildFileSubstitutes);
|
||||
}
|
||||
}
|
||||
|
||||
if (_firstExistingFolder(parent, ['blaze-out', 'bazel-out']) != null) {
|
||||
// Found the "out" folder; must be a bazel workspace.
|
||||
final blazeOutFolder = parent.getChildAssumingFolder('blaze-out');
|
||||
if (blazeOutFolder.exists) {
|
||||
// Found the "out" folder; must be a Blaze workspace.
|
||||
String root = parent.path;
|
||||
var binPaths = _findBinFolderPaths(parent);
|
||||
String symlinkPrefix =
|
||||
_findSymlinkPrefix(provider, root, binPaths: binPaths);
|
||||
binPaths = binPaths..add(context.join(root, '$symlinkPrefix-bin'));
|
||||
return BlazeWorkspace._(
|
||||
provider,
|
||||
root,
|
||||
symlinkPrefix,
|
||||
null /* readonly */,
|
||||
binPaths,
|
||||
context.join(root, '$symlinkPrefix-genfiles'),
|
||||
binPaths = binPaths..add(context.join(root, 'blaze-bin'));
|
||||
return BlazeWorkspace._(provider, root, null /* readonly */, binPaths,
|
||||
context.join(root, 'blaze-genfiles'),
|
||||
lookForBuildFileSubstitutes: lookForBuildFileSubstitutes);
|
||||
}
|
||||
|
||||
|
@ -508,16 +489,9 @@ class BlazeWorkspace extends Workspace
|
|||
if (folder.getChildAssumingFile(file_paths.blazeWorkspaceMarker).exists) {
|
||||
String root = folder.path;
|
||||
var binPaths = _findBinFolderPaths(folder);
|
||||
String symlinkPrefix =
|
||||
_findSymlinkPrefix(provider, root, binPaths: binPaths);
|
||||
binPaths = binPaths..add(context.join(root, '$symlinkPrefix-bin'));
|
||||
return BlazeWorkspace._(
|
||||
provider,
|
||||
root,
|
||||
symlinkPrefix,
|
||||
null /* readonly */,
|
||||
binPaths,
|
||||
context.join(root, '$symlinkPrefix-genfiles'),
|
||||
binPaths = binPaths..add(context.join(root, 'blaze-bin'));
|
||||
return BlazeWorkspace._(provider, root, null /* readonly */, binPaths,
|
||||
context.join(root, 'blaze-genfiles'),
|
||||
lookForBuildFileSubstitutes: lookForBuildFileSubstitutes);
|
||||
}
|
||||
}
|
||||
|
@ -528,17 +502,16 @@ class BlazeWorkspace extends Workspace
|
|||
/// Find the "bin" folder path, by searching for it.
|
||||
///
|
||||
/// Depending on the environment we're working in (source code tree, build
|
||||
/// environment subtree of sources, local workspace, blaze, bazel), the "bin"
|
||||
/// folder may be available at a symlink found at `$root/blaze-bin/` or
|
||||
/// `$root/bazel-bin/`. If that symlink is not available, then we must search
|
||||
/// the immediate folders found in `$root/blaze-out/` and `$root/bazel-out/`
|
||||
/// for folders named "bin".
|
||||
/// environment subtree of sources, local workspace, blaze), the "bin"
|
||||
/// folder may be available at a symlink found at `$root/blaze-bin/`. If that
|
||||
/// symlink is not available, then we must search the immediate folders found
|
||||
/// in `$root/blaze-out/` for folders named "bin".
|
||||
///
|
||||
/// If no "bin" folder is found in any of those locations, empty list is
|
||||
/// returned.
|
||||
static List<String> _findBinFolderPaths(Folder root) {
|
||||
var out = _firstExistingFolder(root, ['blaze-out', 'bazel-out']);
|
||||
if (out == null) {
|
||||
final out = root.getChildAssumingFolder('blaze-out');
|
||||
if (!out.exists) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -554,36 +527,6 @@ class BlazeWorkspace extends Workspace
|
|||
return binPaths;
|
||||
}
|
||||
|
||||
/// Return the symlink prefix, _X_, for folders `X-bin` or `X-genfiles`.
|
||||
///
|
||||
/// If the workspace's "bin" folders were already found, the symlink prefix is
|
||||
/// determined from one of the [binPaths]. Otherwise it is determined by
|
||||
/// probing the internal `blaze-genfiles` and `bazel-genfiles`. Make a default
|
||||
/// assumption according to [defaultSymlinkPrefix] if neither of the folders
|
||||
/// exists.
|
||||
static String _findSymlinkPrefix(ResourceProvider provider, String root,
|
||||
{List<String>? binPaths}) {
|
||||
path.Context context = provider.pathContext;
|
||||
if (binPaths != null && binPaths.isNotEmpty) {
|
||||
return context.basename(binPaths.first).startsWith('bazel')
|
||||
? 'bazel'
|
||||
: 'blaze';
|
||||
}
|
||||
if (provider.getFolder(context.join(root, 'blaze-genfiles')).exists) {
|
||||
return 'blaze';
|
||||
}
|
||||
if (provider.getFolder(context.join(root, 'bazel-genfiles')).exists) {
|
||||
return 'bazel';
|
||||
}
|
||||
// Couldn't find it. Make a default assumption.
|
||||
return defaultSymlinkPrefix;
|
||||
}
|
||||
|
||||
/// Return the first folder within [root], chosen from [names], which exists.
|
||||
static Folder? _firstExistingFolder(Folder root, List<String> names) => names
|
||||
.map((name) => root.getChildAssumingFolder(name))
|
||||
.firstWhereOrNull((folder) => folder.exists);
|
||||
|
||||
/// Return the default language version of the workspace.
|
||||
///
|
||||
/// Return `null` if cannot be read, for example because the file does not
|
||||
|
@ -614,11 +557,11 @@ class BlazeWorkspace extends Workspace
|
|||
}
|
||||
}
|
||||
|
||||
/// Information about a package defined in a BazelWorkspace.
|
||||
/// Information about a package defined in a [BlazeWorkspace].
|
||||
///
|
||||
/// Separate from [Packages] or package maps, this class is designed to simply
|
||||
/// understand whether arbitrary file paths represent libraries declared within
|
||||
/// a given package in a BazelWorkspace.
|
||||
/// a given package in a [BlazeWorkspace].
|
||||
class BlazeWorkspacePackage extends WorkspacePackage {
|
||||
/// A prefix for any URI of a path in this package.
|
||||
final String _uriPrefix;
|
||||
|
|
|
@ -486,11 +486,8 @@ class _BlazeInvocationWatcher implements PollTrigger {
|
|||
|
||||
Future<String?> _getCommandLogPath() async {
|
||||
String? resolvedLink;
|
||||
var bazelOut = _inWorkspace('bazel-out');
|
||||
var blazeOut = _inWorkspace('blaze-out');
|
||||
if (await io.Link(bazelOut).exists()) {
|
||||
resolvedLink = await io.Link(bazelOut).target();
|
||||
} else if (await io.Link(blazeOut).exists()) {
|
||||
if (await io.Link(blazeOut).exists()) {
|
||||
resolvedLink = await io.Link(blazeOut).target();
|
||||
}
|
||||
if (resolvedLink == null) return null;
|
||||
|
|
|
@ -66,7 +66,7 @@ embedded_libs:
|
|||
sdkSummaryFile.writeAsBytesSync(sdkSummaryBytes);
|
||||
|
||||
// Pub workspace does not support SDK summaries.
|
||||
// So, we use Bazel workspace.
|
||||
// So, we use Blaze workspace.
|
||||
const workspacePath = '/workspace';
|
||||
newFile('$workspacePath/${file_paths.blazeWorkspaceMarker}', '');
|
||||
final myPackageRoot = getFolder('$workspacePath/dart/my');
|
||||
|
@ -113,7 +113,7 @@ embedded_libs:
|
|||
sdkSummaryFile.writeAsBytesSync(sdkSummaryBytes);
|
||||
|
||||
// Pub workspace does not support SDK summaries.
|
||||
// So, we use Bazel workspace.
|
||||
// So, we use Blaze workspace.
|
||||
const workspacePath = '/workspace';
|
||||
newFile('$workspacePath/${file_paths.blazeWorkspaceMarker}', '');
|
||||
final myPackageRoot = getFolder('$workspacePath/dart/my');
|
||||
|
|
|
@ -171,8 +171,8 @@ environment:
|
|||
void test_sourceFactory_blazeWorkspace() {
|
||||
var projectPath = convertPath('/workspace/my/module');
|
||||
newFile('/workspace/${file_paths.blazeWorkspaceMarker}', '');
|
||||
newFolder('/workspace/bazel-bin');
|
||||
newFolder('/workspace/bazel-genfiles');
|
||||
newFolder('/workspace/blaze-bin');
|
||||
newFolder('/workspace/blaze-genfiles');
|
||||
|
||||
var analysisContext = _createSingleAnalysisContext(projectPath);
|
||||
expect(analysisContext.contextRoot.workspace, isA<BlazeWorkspace>());
|
||||
|
|
|
@ -1135,7 +1135,7 @@ analyzer:
|
|||
var workspacePath = '/home/workspace';
|
||||
var workspaceFolder = getFolder(workspacePath);
|
||||
newFile('$workspacePath/${file_paths.blazeWorkspaceMarker}', '');
|
||||
var bazelOptionsFile = newFile(
|
||||
var blazeOptionsFile = newFile(
|
||||
'$workspacePath/dart/analysis_options/lib/default.yaml',
|
||||
'',
|
||||
);
|
||||
|
@ -1150,7 +1150,7 @@ analyzer:
|
|||
var root = findRoot(roots, workspaceFolder);
|
||||
expect(root.includedPaths, unorderedEquals([rootFolder.path]));
|
||||
expect(root.excludedPaths, isEmpty);
|
||||
expect(root.optionsFile, bazelOptionsFile);
|
||||
expect(root.optionsFile, blazeOptionsFile);
|
||||
expect(root.packagesFile, isNull);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class FileSystemState_BlazeWorkspaceTest extends BlazeWorkspaceResolutionTest {
|
|||
void test_getFileForUri_hasGenerated_askGeneratedFirst() async {
|
||||
var relPath = 'dart/my/test/a.dart';
|
||||
var writablePath = convertPath('$workspaceRootPath/$relPath');
|
||||
var generatedPath = convertPath('$workspaceRootPath/bazel-bin/$relPath');
|
||||
var generatedPath = convertPath('$workspaceRootPath/blaze-bin/$relPath');
|
||||
|
||||
// This generated file should be used instead of the writable.
|
||||
newFile(generatedPath, '');
|
||||
|
@ -69,7 +69,7 @@ class FileSystemState_BlazeWorkspaceTest extends BlazeWorkspaceResolutionTest {
|
|||
void test_getFileForUri_hasGenerated_askWritableFirst() async {
|
||||
var relPath = 'dart/my/test/a.dart';
|
||||
var writablePath = convertPath('$workspaceRootPath/$relPath');
|
||||
var generatedPath = convertPath('$workspaceRootPath/bazel-bin/$relPath');
|
||||
var generatedPath = convertPath('$workspaceRootPath/blaze-bin/$relPath');
|
||||
|
||||
// This generated file should be used instead of the writable.
|
||||
newFile(generatedPath, '');
|
||||
|
|
|
@ -23,7 +23,7 @@ class AnalysisSessionImpl_BlazeWorkspaceTest
|
|||
extends BlazeWorkspaceResolutionTest {
|
||||
void test_getErrors_notFileOfUri() async {
|
||||
var relPath = 'dart/my/lib/a.dart';
|
||||
newFile('$workspaceRootPath/bazel-bin/$relPath', '');
|
||||
newFile('$workspaceRootPath/blaze-bin/$relPath', '');
|
||||
|
||||
final file = getFile('$workspaceRootPath/$relPath');
|
||||
var session = contextFor(file).currentSession;
|
||||
|
@ -46,7 +46,7 @@ class AnalysisSessionImpl_BlazeWorkspaceTest
|
|||
|
||||
void test_getParsedLibrary_notFileOfUri() async {
|
||||
var relPath = 'dart/my/lib/a.dart';
|
||||
newFile('$workspaceRootPath/bazel-bin/$relPath', '');
|
||||
newFile('$workspaceRootPath/blaze-bin/$relPath', '');
|
||||
|
||||
final file = getFile('$workspaceRootPath/$relPath');
|
||||
var session = contextFor(file).currentSession;
|
||||
|
@ -56,7 +56,7 @@ class AnalysisSessionImpl_BlazeWorkspaceTest
|
|||
|
||||
void test_getResolvedLibrary_notFileOfUri() async {
|
||||
var relPath = 'dart/my/lib/a.dart';
|
||||
newFile('$workspaceRootPath/bazel-bin/$relPath', '');
|
||||
newFile('$workspaceRootPath/blaze-bin/$relPath', '');
|
||||
|
||||
final file = getFile('$workspaceRootPath/$relPath');
|
||||
var session = contextFor(file).currentSession;
|
||||
|
@ -66,7 +66,7 @@ class AnalysisSessionImpl_BlazeWorkspaceTest
|
|||
|
||||
void test_getResolvedUnit_notFileOfUri() async {
|
||||
var relPath = 'dart/my/lib/a.dart';
|
||||
newFile('$workspaceRootPath/bazel-bin/$relPath', '');
|
||||
newFile('$workspaceRootPath/blaze-bin/$relPath', '');
|
||||
|
||||
final file = getFile('$workspaceRootPath/$relPath');
|
||||
var session = contextFor(file).currentSession;
|
||||
|
@ -100,7 +100,7 @@ class AnalysisSessionImpl_BlazeWorkspaceTest
|
|||
|
||||
void test_getUnitElement_notPathOfUri() async {
|
||||
var relPath = 'dart/my/lib/a.dart';
|
||||
newFile('$workspaceRootPath/bazel-bin/$relPath', '');
|
||||
newFile('$workspaceRootPath/blaze-bin/$relPath', '');
|
||||
|
||||
final file = getFile('$workspaceRootPath/$relPath');
|
||||
var session = contextFor(file).currentSession;
|
||||
|
|
|
@ -21,10 +21,10 @@ main() {
|
|||
class InvalidExportOfInternalElement_BlazePackageTest
|
||||
extends BlazeWorkspaceResolutionTest
|
||||
with InvalidExportOfInternalElementTest {
|
||||
String get testPackageBlazeBinPath => '$workspaceRootPath/bazel-bin/dart/my';
|
||||
String get testPackageBlazeBinPath => '$workspaceRootPath/blaze-bin/dart/my';
|
||||
|
||||
String get testPackageGenfilesPath =>
|
||||
'$workspaceRootPath/bazel-genfiles/dart/my';
|
||||
'$workspaceRootPath/blaze-genfiles/dart/my';
|
||||
|
||||
@override
|
||||
String get testPackageLibPath => myPackageLibPath;
|
||||
|
@ -37,7 +37,7 @@ class InvalidExportOfInternalElement_BlazePackageTest
|
|||
getFolder(metaPath),
|
||||
);
|
||||
newFile('$testPackageBlazeBinPath/my.packages', '');
|
||||
newFolder('$workspaceRootPath/bazel-out');
|
||||
newFolder('$workspaceRootPath/blaze-out');
|
||||
}
|
||||
|
||||
void test_exporterIsInBlazeBinLib() async {
|
||||
|
|
|
@ -31,11 +31,11 @@ class BlazeFileUriResolverTest with ResourceProviderMixin {
|
|||
void test_resolveAbsolute_blazeBin_exists() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-bin/my/test/a.dart',
|
||||
'/workspace/blaze-bin/my/test/a.dart',
|
||||
]);
|
||||
_assertResolve(
|
||||
toUriStr('/workspace/bazel-bin/my/test/a.dart'),
|
||||
getFile('/workspace/bazel-bin/my/test/a.dart'),
|
||||
toUriStr('/workspace/blaze-bin/my/test/a.dart'),
|
||||
getFile('/workspace/blaze-bin/my/test/a.dart'),
|
||||
restoredUriStr: toUriStr('/workspace/my/test/a.dart'),
|
||||
);
|
||||
}
|
||||
|
@ -86,22 +86,22 @@ class BlazeFileUriResolverTest with ResourceProviderMixin {
|
|||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/my/test/a.dart',
|
||||
'/workspace/bazel-bin/my/test/a.dart',
|
||||
'/workspace/blaze-bin/my/test/a.dart',
|
||||
]);
|
||||
_assertResolve(
|
||||
toUriStr('/workspace/my/test/a.dart'),
|
||||
getFile('/workspace/bazel-bin/my/test/a.dart'),
|
||||
getFile('/workspace/blaze-bin/my/test/a.dart'),
|
||||
);
|
||||
}
|
||||
|
||||
void test_resolveAbsolute_writableUri_blazeBin_noWritable() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-bin/my/test/a.dart',
|
||||
'/workspace/blaze-bin/my/test/a.dart',
|
||||
]);
|
||||
_assertResolve(
|
||||
toUriStr('/workspace/my/test/a.dart'),
|
||||
getFile('/workspace/bazel-bin/my/test/a.dart'),
|
||||
getFile('/workspace/blaze-bin/my/test/a.dart'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -109,22 +109,22 @@ class BlazeFileUriResolverTest with ResourceProviderMixin {
|
|||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/my/test/a.dart',
|
||||
'/workspace/bazel-genfiles/my/test/a.dart',
|
||||
'/workspace/blaze-genfiles/my/test/a.dart',
|
||||
]);
|
||||
_assertResolve(
|
||||
toUriStr('/workspace/my/test/a.dart'),
|
||||
getFile('/workspace/bazel-genfiles/my/test/a.dart'),
|
||||
getFile('/workspace/blaze-genfiles/my/test/a.dart'),
|
||||
);
|
||||
}
|
||||
|
||||
void test_resolveAbsolute_writableUri_blazeGenfiles_noWritable() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/my/test/a.dart',
|
||||
'/workspace/blaze-genfiles/my/test/a.dart',
|
||||
]);
|
||||
_assertResolve(
|
||||
toUriStr('/workspace/my/test/a.dart'),
|
||||
getFile('/workspace/bazel-genfiles/my/test/a.dart'),
|
||||
getFile('/workspace/blaze-genfiles/my/test/a.dart'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -192,23 +192,23 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_resolveAbsolute_bin() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/my/foo/lib/foo1.dart',
|
||||
'/workspace/bazel-bin/my/foo/lib/foo1.dart'
|
||||
'/workspace/blaze-bin/my/foo/lib/foo1.dart'
|
||||
]);
|
||||
_assertResolve(
|
||||
'package:my.foo/foo1.dart', '/workspace/bazel-bin/my/foo/lib/foo1.dart',
|
||||
'package:my.foo/foo1.dart', '/workspace/blaze-bin/my/foo/lib/foo1.dart',
|
||||
exists: true);
|
||||
}
|
||||
|
||||
void test_resolveAbsolute_bin_notInWorkspace() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/bazel-bin/my/foo/lib/foo1.dart'
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/blaze-bin/my/foo/lib/foo1.dart'
|
||||
]);
|
||||
_assertResolve(
|
||||
'package:my.foo/foo1.dart', '/workspace/bazel-bin/my/foo/lib/foo1.dart',
|
||||
'package:my.foo/foo1.dart', '/workspace/blaze-bin/my/foo/lib/foo1.dart',
|
||||
exists: true);
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/my/foo/test',
|
||||
]);
|
||||
_assertResolve(toUriStr('/workspace/bazel-bin/my/test/a .dart'),
|
||||
_assertResolve(toUriStr('/workspace/blaze-bin/my/test/a .dart'),
|
||||
'/workspace/my/test/a .dart',
|
||||
exists: false, restore: false);
|
||||
}
|
||||
|
@ -225,21 +225,21 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_resolveAbsolute_file_bin_to_genfiles() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/my/foo/test/foo1.dart',
|
||||
'/workspace/bazel-bin/'
|
||||
'/workspace/blaze-genfiles/my/foo/test/foo1.dart',
|
||||
'/workspace/blaze-bin/'
|
||||
]);
|
||||
_assertResolve(toUriStr('/workspace/bazel-bin/my/foo/test/foo1.dart'),
|
||||
'/workspace/bazel-genfiles/my/foo/test/foo1.dart',
|
||||
_assertResolve(toUriStr('/workspace/blaze-bin/my/foo/test/foo1.dart'),
|
||||
'/workspace/blaze-genfiles/my/foo/test/foo1.dart',
|
||||
restore: false);
|
||||
}
|
||||
|
||||
void test_resolveAbsolute_file_genfiles_to_workspace() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/my/foo/test/foo1.dart'
|
||||
]);
|
||||
_assertResolve(toUriStr('/workspace/bazel-genfiles/my/foo/test/foo1.dart'),
|
||||
_assertResolve(toUriStr('/workspace/blaze-genfiles/my/foo/test/foo1.dart'),
|
||||
'/workspace/my/foo/test/foo1.dart',
|
||||
restore: false);
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_resolveAbsolute_file_not_in_workspace() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/other/my/foo/test/foo1.dart'
|
||||
]);
|
||||
_assertNoResolve(toUriStr('/other/my/foo/test/foo1.dart'));
|
||||
|
@ -267,40 +267,40 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_resolveAbsolute_file_workspace_to_genfiles() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/my/foo/test/foo1.dart'
|
||||
'/workspace/blaze-genfiles/my/foo/test/foo1.dart'
|
||||
]);
|
||||
_assertResolve(toUriStr('/workspace/my/foo/test/foo1.dart'),
|
||||
'/workspace/bazel-genfiles/my/foo/test/foo1.dart',
|
||||
'/workspace/blaze-genfiles/my/foo/test/foo1.dart',
|
||||
restore: false);
|
||||
}
|
||||
|
||||
void test_resolveAbsolute_genfiles() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/my/foo/lib/foo1.dart',
|
||||
'/workspace/bazel-genfiles/my/foo/lib/foo1.dart'
|
||||
'/workspace/blaze-genfiles/my/foo/lib/foo1.dart'
|
||||
]);
|
||||
_assertResolve('package:my.foo/foo1.dart',
|
||||
'/workspace/bazel-genfiles/my/foo/lib/foo1.dart',
|
||||
'/workspace/blaze-genfiles/my/foo/lib/foo1.dart',
|
||||
exists: true);
|
||||
}
|
||||
|
||||
void test_resolveAbsolute_genfiles_notInWorkspace() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/bazel-genfiles/my/foo/lib/foo1.dart'
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/blaze-genfiles/my/foo/lib/foo1.dart'
|
||||
]);
|
||||
_assertResolve('package:my.foo/foo1.dart',
|
||||
'/workspace/bazel-genfiles/my/foo/lib/foo1.dart',
|
||||
'/workspace/blaze-genfiles/my/foo/lib/foo1.dart',
|
||||
exists: true);
|
||||
}
|
||||
|
||||
void test_resolveAbsolute_null_doubleDot() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
]);
|
||||
var uri = Uri.parse('package:foo..bar/baz.dart');
|
||||
var source = resolver.resolveAbsolute(uri);
|
||||
|
@ -310,7 +310,7 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_resolveAbsolute_null_doubleSlash() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
]);
|
||||
var uri = Uri.parse('package:foo//bar/baz.dart');
|
||||
var source = resolver.resolveAbsolute(uri);
|
||||
|
@ -329,7 +329,7 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_resolveAbsolute_null_noSlash() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
]);
|
||||
var source = resolver.resolveAbsolute(Uri.parse('package:foo'));
|
||||
expect(source, isNull);
|
||||
|
@ -338,7 +338,7 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_resolveAbsolute_null_notPackage() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
]);
|
||||
var source = resolver.resolveAbsolute(Uri.parse('dart:async'));
|
||||
expect(source, isNull);
|
||||
|
@ -347,7 +347,7 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_resolveAbsolute_null_startsWithSlash() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/my/foo/lib/bar.dart',
|
||||
]);
|
||||
var source = resolver.resolveAbsolute(Uri.parse('package:/foo/bar.dart'));
|
||||
|
@ -358,24 +358,24 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
_addResources([
|
||||
'/Users/user/test/READONLY/prime/',
|
||||
'/Users/user/test/READONLY/prime/my/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/bazel-genfiles/',
|
||||
'/Users/user/test/prime/blaze-genfiles/',
|
||||
'/Users/user/test/prime/my/module/',
|
||||
'/Users/user/test/prime/bazel-bin/my/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/blaze-bin/my/foo/lib/foo1.dart',
|
||||
], workspacePath: '/Users/user/test/prime/my/module');
|
||||
_assertResolve('package:my.foo/foo1.dart',
|
||||
'/Users/user/test/prime/bazel-bin/my/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/blaze-bin/my/foo/lib/foo1.dart',
|
||||
exists: true);
|
||||
}
|
||||
|
||||
void test_resolveAbsolute_readonly_bin_notInWorkspace() {
|
||||
_addResources([
|
||||
'/Users/user/test/READONLY/prime/',
|
||||
'/Users/user/test/prime/bazel-genfiles/',
|
||||
'/Users/user/test/prime/blaze-genfiles/',
|
||||
'/Users/user/test/prime/my/module/',
|
||||
'/Users/user/test/prime/bazel-bin/my/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/blaze-bin/my/foo/lib/foo1.dart',
|
||||
], workspacePath: '/Users/user/test/prime/my/module');
|
||||
_assertResolve('package:my.foo/foo1.dart',
|
||||
'/Users/user/test/prime/bazel-bin/my/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/blaze-bin/my/foo/lib/foo1.dart',
|
||||
exists: true);
|
||||
}
|
||||
|
||||
|
@ -383,24 +383,24 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
_addResources([
|
||||
'/Users/user/test/READONLY/prime/',
|
||||
'/Users/user/test/READONLY/prime/my/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/bazel-genfiles/',
|
||||
'/Users/user/test/prime/blaze-genfiles/',
|
||||
'/Users/user/test/prime/my/module/',
|
||||
'/Users/user/test/prime/bazel-genfiles/my/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/blaze-genfiles/my/foo/lib/foo1.dart',
|
||||
], workspacePath: '/Users/user/test/prime/my/module');
|
||||
_assertResolve('package:my.foo/foo1.dart',
|
||||
'/Users/user/test/prime/bazel-genfiles/my/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/blaze-genfiles/my/foo/lib/foo1.dart',
|
||||
exists: true);
|
||||
}
|
||||
|
||||
void test_resolveAbsolute_readonly_genfiles_notInWorkspace() {
|
||||
_addResources([
|
||||
'/Users/user/test/READONLY/prime/',
|
||||
'/Users/user/test/prime/bazel-genfiles/',
|
||||
'/Users/user/test/prime/blaze-genfiles/',
|
||||
'/Users/user/test/prime/my/module/',
|
||||
'/Users/user/test/prime/bazel-genfiles/my/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/blaze-genfiles/my/foo/lib/foo1.dart',
|
||||
], workspacePath: '/Users/user/test/prime/my/module');
|
||||
_assertResolve('package:my.foo/foo1.dart',
|
||||
'/Users/user/test/prime/bazel-genfiles/my/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/blaze-genfiles/my/foo/lib/foo1.dart',
|
||||
exists: true);
|
||||
}
|
||||
|
||||
|
@ -408,12 +408,12 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
_addResources([
|
||||
'/Users/user/test/READONLY/prime/',
|
||||
'/Users/user/test/READONLY/prime/third_party/dart/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/bazel-genfiles/',
|
||||
'/Users/user/test/prime/blaze-genfiles/',
|
||||
'/Users/user/test/prime/my/module/',
|
||||
'/Users/user/test/prime/bazel-bin/third_party/dart/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/blaze-bin/third_party/dart/foo/lib/foo1.dart',
|
||||
], workspacePath: '/Users/user/test/prime/my/module');
|
||||
_assertResolve('package:foo/foo1.dart',
|
||||
'/Users/user/test/prime/bazel-bin/third_party/dart/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/blaze-bin/third_party/dart/foo/lib/foo1.dart',
|
||||
exists: true);
|
||||
}
|
||||
|
||||
|
@ -421,12 +421,12 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
_addResources([
|
||||
'/Users/user/test/READONLY/prime/',
|
||||
'/Users/user/test/READONLY/prime/third_party/dart/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/bazel-genfiles/',
|
||||
'/Users/user/test/prime/blaze-genfiles/',
|
||||
'/Users/user/test/prime/my/module/',
|
||||
'/Users/user/test/prime/bazel-genfiles/third_party/dart/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/blaze-genfiles/third_party/dart/foo/lib/foo1.dart',
|
||||
], workspacePath: '/Users/user/test/prime/my/module');
|
||||
_assertResolve('package:foo/foo1.dart',
|
||||
'/Users/user/test/prime/bazel-genfiles/third_party/dart/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/blaze-genfiles/third_party/dart/foo/lib/foo1.dart',
|
||||
exists: true);
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,7 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
_addResources([
|
||||
'/Users/user/test/READONLY/prime/',
|
||||
'/Users/user/test/READONLY/prime/third_party/dart/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/bazel-genfiles/',
|
||||
'/Users/user/test/prime/blaze-genfiles/',
|
||||
'/Users/user/test/prime/my/module/',
|
||||
], workspacePath: '/Users/user/test/prime/my/module');
|
||||
_assertResolve('package:foo/foo2.dart',
|
||||
|
@ -446,7 +446,7 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
_addResources([
|
||||
'/Users/user/test/READONLY/prime/',
|
||||
'/Users/user/test/READONLY/prime/third_party/dart/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/bazel-genfiles/',
|
||||
'/Users/user/test/prime/blaze-genfiles/',
|
||||
'/Users/user/test/prime/my/module/',
|
||||
], workspacePath: '/Users/user/test/prime/my/module');
|
||||
_assertResolve('package:foo/foo1.dart',
|
||||
|
@ -457,7 +457,7 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_resolveAbsolute_readonly_workspace_doesNotExist() {
|
||||
_addResources([
|
||||
'/Users/user/test/READONLY/prime/',
|
||||
'/Users/user/test/prime/bazel-genfiles/',
|
||||
'/Users/user/test/prime/blaze-genfiles/',
|
||||
'/Users/user/test/prime/my/module/',
|
||||
], workspacePath: '/Users/user/test/prime/my/module');
|
||||
_assertResolve('package:my.foo/foo1.dart',
|
||||
|
@ -469,7 +469,7 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
_addResources([
|
||||
'/Users/user/test/READONLY/prime/',
|
||||
'/Users/user/test/READONLY/prime/my/foo/lib/foo1.dart',
|
||||
'/Users/user/test/prime/bazel-genfiles/',
|
||||
'/Users/user/test/prime/blaze-genfiles/',
|
||||
'/Users/user/test/prime/my/module/',
|
||||
], workspacePath: '/Users/user/test/prime/my/module');
|
||||
_assertResolve('package:my.foo/foo1.dart',
|
||||
|
@ -480,30 +480,30 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_resolveAbsolute_thirdParty_bin() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/third_party/dart/foo/lib/foo1.dart',
|
||||
'/workspace/bazel-bin/third_party/dart/foo/lib/foo1.dart',
|
||||
'/workspace/blaze-bin/third_party/dart/foo/lib/foo1.dart',
|
||||
]);
|
||||
_assertResolve('package:foo/foo1.dart',
|
||||
'/workspace/bazel-bin/third_party/dart/foo/lib/foo1.dart',
|
||||
'/workspace/blaze-bin/third_party/dart/foo/lib/foo1.dart',
|
||||
exists: true);
|
||||
}
|
||||
|
||||
void test_resolveAbsolute_thirdParty_bin_notInWorkspace() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/bazel-bin/third_party/dart/foo/lib/foo1.dart',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/blaze-bin/third_party/dart/foo/lib/foo1.dart',
|
||||
]);
|
||||
_assertResolve('package:foo/foo1.dart',
|
||||
'/workspace/bazel-bin/third_party/dart/foo/lib/foo1.dart',
|
||||
'/workspace/blaze-bin/third_party/dart/foo/lib/foo1.dart',
|
||||
exists: true);
|
||||
}
|
||||
|
||||
void test_resolveAbsolute_thirdParty_doesNotExist() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/third_party/dart/foo/lib/foo1.dart',
|
||||
]);
|
||||
_assertResolve('package:foo/foo2.dart',
|
||||
|
@ -514,7 +514,7 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_resolveAbsolute_thirdParty_exists() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/third_party/dart/foo/lib/foo1.dart',
|
||||
]);
|
||||
_assertResolve('package:foo/foo1.dart',
|
||||
|
@ -525,30 +525,30 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_resolveAbsolute_thirdParty_genfiles() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/third_party/dart/foo/lib/foo1.dart',
|
||||
'/workspace/bazel-genfiles/third_party/dart/foo/lib/foo1.dart',
|
||||
'/workspace/blaze-genfiles/third_party/dart/foo/lib/foo1.dart',
|
||||
]);
|
||||
_assertResolve('package:foo/foo1.dart',
|
||||
'/workspace/bazel-genfiles/third_party/dart/foo/lib/foo1.dart',
|
||||
'/workspace/blaze-genfiles/third_party/dart/foo/lib/foo1.dart',
|
||||
exists: true);
|
||||
}
|
||||
|
||||
void test_resolveAbsolute_thirdParty_genfiles_notInWorkspace() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/bazel-genfiles/third_party/dart/foo/lib/foo1.dart',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/blaze-genfiles/third_party/dart/foo/lib/foo1.dart',
|
||||
]);
|
||||
_assertResolve('package:foo/foo1.dart',
|
||||
'/workspace/bazel-genfiles/third_party/dart/foo/lib/foo1.dart',
|
||||
'/workspace/blaze-genfiles/third_party/dart/foo/lib/foo1.dart',
|
||||
exists: true);
|
||||
}
|
||||
|
||||
void test_resolveAbsolute_workspace_doesNotExist() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
]);
|
||||
_assertResolve('package:my.foo/doesNotExist.dart',
|
||||
'/workspace/my/foo/lib/doesNotExist.dart',
|
||||
|
@ -558,7 +558,7 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_resolveAbsolute_workspace_exists() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/my/foo/lib/foo1.dart',
|
||||
]);
|
||||
_assertResolve(
|
||||
|
@ -569,7 +569,7 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_resolveAbsolute_workspace_exists_hasSpace() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/my/foo/lib/foo .dart',
|
||||
]);
|
||||
_assertResolve(
|
||||
|
@ -580,7 +580,7 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_restoreAbsolute_noPackageName_workspace() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/lib/foo1.dart',
|
||||
'/workspace/foo/lib/foo2.dart',
|
||||
]);
|
||||
|
@ -591,31 +591,31 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_restoreAbsolute_noPathInLib_bin() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/bazel-bin/my/foo/lib/foo1.dart',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/blaze-bin/my/foo/lib/foo1.dart',
|
||||
]);
|
||||
_assertRestore('/workspace/bazel-bin', null);
|
||||
_assertRestore('/workspace/bazel-bin/my', null);
|
||||
_assertRestore('/workspace/bazel-bin/my/foo', null);
|
||||
_assertRestore('/workspace/bazel-bin/my/foo/lib', null);
|
||||
_assertRestore('/workspace/blaze-bin', null);
|
||||
_assertRestore('/workspace/blaze-bin/my', null);
|
||||
_assertRestore('/workspace/blaze-bin/my/foo', null);
|
||||
_assertRestore('/workspace/blaze-bin/my/foo/lib', null);
|
||||
}
|
||||
|
||||
void test_restoreAbsolute_noPathInLib_genfiles() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/bazel-genfiles/my/foo/lib/foo1.dart',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/blaze-genfiles/my/foo/lib/foo1.dart',
|
||||
]);
|
||||
_assertRestore('/workspace/bazel-genfiles', null);
|
||||
_assertRestore('/workspace/bazel-genfiles/my', null);
|
||||
_assertRestore('/workspace/bazel-genfiles/my/foo', null);
|
||||
_assertRestore('/workspace/bazel-genfiles/my/foo/lib', null);
|
||||
_assertRestore('/workspace/blaze-genfiles', null);
|
||||
_assertRestore('/workspace/blaze-genfiles/my', null);
|
||||
_assertRestore('/workspace/blaze-genfiles/my/foo', null);
|
||||
_assertRestore('/workspace/blaze-genfiles/my/foo/lib', null);
|
||||
}
|
||||
|
||||
void test_restoreAbsolute_noPathInLib_workspace() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/my/foo/lib/foo1.dart',
|
||||
]);
|
||||
_assertRestore('/workspace', null);
|
||||
|
@ -627,7 +627,7 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
|
|||
void test_restoreAbsolute_thirdPartyNotDart_workspace() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
'/workspace/third_party/something/lib/foo.dart',
|
||||
]);
|
||||
_assertRestore('/workspace/third_party/something/lib/foo.dart',
|
||||
|
@ -796,7 +796,7 @@ class BlazeWorkspacePackageTest with ResourceProviderMixin {
|
|||
void test_findPackageFor_missingMarkerFiles() {
|
||||
_addResources([
|
||||
'/ws/${file_paths.blazeWorkspaceMarker}',
|
||||
'/ws/bazel-genfiles',
|
||||
'/ws/blaze-genfiles',
|
||||
]);
|
||||
workspace = BlazeWorkspace.find(
|
||||
resourceProvider,
|
||||
|
@ -912,7 +912,7 @@ class BlazeWorkspacePackageTest with ResourceProviderMixin {
|
|||
void _setUpPackage() {
|
||||
_addResources([
|
||||
'/ws/${file_paths.blazeWorkspaceMarker}',
|
||||
'/ws/bazel-genfiles/',
|
||||
'/ws/blaze-genfiles/',
|
||||
'/ws/some/code/BUILD',
|
||||
'/ws/some/code/lib/code.dart',
|
||||
]);
|
||||
|
@ -939,7 +939,7 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
|
|||
void test_blazeNotifications() async {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-bin/my/module/test1.dart',
|
||||
'/workspace/blaze-bin/my/module/test1.dart',
|
||||
]);
|
||||
var workspace = BlazeWorkspace.find(
|
||||
resourceProvider, convertPath('/workspace/my/module'))!;
|
||||
|
@ -953,8 +953,8 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
|
|||
expect(
|
||||
info.candidatePaths,
|
||||
containsAll([
|
||||
convertPath('/workspace/bazel-bin/my/module/test1.dart'),
|
||||
convertPath('/workspace/bazel-genfiles/my/module/test1.dart'),
|
||||
convertPath('/workspace/blaze-bin/my/module/test1.dart'),
|
||||
convertPath('/workspace/blaze-genfiles/my/module/test1.dart'),
|
||||
]));
|
||||
|
||||
var file2 =
|
||||
|
@ -965,8 +965,8 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
|
|||
expect(
|
||||
info.candidatePaths,
|
||||
containsAll([
|
||||
convertPath('/workspace/bazel-bin/my/module/test2.dart'),
|
||||
convertPath('/workspace/bazel-genfiles/my/module/test2.dart'),
|
||||
convertPath('/workspace/blaze-bin/my/module/test2.dart'),
|
||||
convertPath('/workspace/blaze-genfiles/my/module/test2.dart'),
|
||||
]));
|
||||
}
|
||||
|
||||
|
@ -1034,32 +1034,32 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
|
|||
_addResources([
|
||||
'/Users/user/test/READONLY/prime/',
|
||||
'/Users/user/test/prime/',
|
||||
'/Users/user/test/prime/bazel-genfiles/',
|
||||
'/Users/user/test/prime/blaze-genfiles/',
|
||||
]);
|
||||
var workspace = BlazeWorkspace.find(
|
||||
resourceProvider, convertPath('/Users/user/test/prime/my/module'))!;
|
||||
expect(workspace.root, convertPath('/Users/user/test/prime'));
|
||||
expect(workspace.readonly, convertPath('/Users/user/test/READONLY/prime'));
|
||||
expect(workspace.binPaths.single,
|
||||
convertPath('/Users/user/test/prime/bazel-bin'));
|
||||
convertPath('/Users/user/test/prime/blaze-bin'));
|
||||
expect(workspace.genfiles,
|
||||
convertPath('/Users/user/test/prime/bazel-genfiles'));
|
||||
convertPath('/Users/user/test/prime/blaze-genfiles'));
|
||||
}
|
||||
|
||||
void test_find_hasReadonlyFolder_bad_actuallyHasWorkspaceFile() {
|
||||
_addResources([
|
||||
'/Users/user/test/READONLY/',
|
||||
'/Users/user/test/prime/${file_paths.blazeWorkspaceMarker}',
|
||||
'/Users/user/test/prime/bazel-genfiles/',
|
||||
'/Users/user/test/prime/blaze-genfiles/',
|
||||
]);
|
||||
var workspace = BlazeWorkspace.find(
|
||||
resourceProvider, convertPath('/Users/user/test/prime/my/module'))!;
|
||||
expect(workspace.root, convertPath('/Users/user/test/prime'));
|
||||
expect(workspace.readonly, isNull);
|
||||
expect(workspace.binPaths.single,
|
||||
convertPath('/Users/user/test/prime/bazel-bin'));
|
||||
convertPath('/Users/user/test/prime/blaze-bin'));
|
||||
expect(workspace.genfiles,
|
||||
convertPath('/Users/user/test/prime/bazel-genfiles'));
|
||||
convertPath('/Users/user/test/prime/blaze-genfiles'));
|
||||
}
|
||||
|
||||
void test_find_hasReadonlyFolder_blaze() {
|
||||
|
@ -1081,40 +1081,40 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
|
|||
void test_find_hasWorkspaceFile() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
]);
|
||||
var workspace = BlazeWorkspace.find(
|
||||
resourceProvider, convertPath('/workspace/my/module'))!;
|
||||
expect(workspace.root, convertPath('/workspace'));
|
||||
expect(workspace.readonly, isNull);
|
||||
expect(workspace.binPaths.single, convertPath('/workspace/bazel-bin'));
|
||||
expect(workspace.genfiles, convertPath('/workspace/bazel-genfiles'));
|
||||
expect(workspace.binPaths.single, convertPath('/workspace/blaze-bin'));
|
||||
expect(workspace.genfiles, convertPath('/workspace/blaze-genfiles'));
|
||||
}
|
||||
|
||||
void test_find_hasWorkspaceFile_forModuleInWorkspace() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
]);
|
||||
var workspace = BlazeWorkspace.find(
|
||||
resourceProvider, convertPath('/workspace/my/module'))!;
|
||||
expect(workspace.root, convertPath('/workspace'));
|
||||
expect(workspace.readonly, isNull);
|
||||
expect(workspace.binPaths.single, convertPath('/workspace/bazel-bin'));
|
||||
expect(workspace.genfiles, convertPath('/workspace/bazel-genfiles'));
|
||||
expect(workspace.binPaths.single, convertPath('/workspace/blaze-bin'));
|
||||
expect(workspace.genfiles, convertPath('/workspace/blaze-genfiles'));
|
||||
}
|
||||
|
||||
void test_find_hasWorkspaceFile_forWorkspace() {
|
||||
_addResources([
|
||||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
'/workspace/bazel-genfiles/',
|
||||
'/workspace/blaze-genfiles/',
|
||||
]);
|
||||
var workspace =
|
||||
BlazeWorkspace.find(resourceProvider, convertPath('/workspace'))!;
|
||||
expect(workspace.root, convertPath('/workspace'));
|
||||
expect(workspace.readonly, isNull);
|
||||
expect(workspace.binPaths.single, convertPath('/workspace/bazel-bin'));
|
||||
expect(workspace.genfiles, convertPath('/workspace/bazel-genfiles'));
|
||||
expect(workspace.binPaths.single, convertPath('/workspace/blaze-bin'));
|
||||
expect(workspace.genfiles, convertPath('/workspace/blaze-genfiles'));
|
||||
}
|
||||
|
||||
void test_find_hasWorkspaceFile_forWorkspace_blaze() {
|
||||
|
@ -1142,14 +1142,13 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
|
|||
}
|
||||
|
||||
void test_find_null_symlinkPrefix() {
|
||||
String prefix = BlazeWorkspace.defaultSymlinkPrefix;
|
||||
newFile('/workspace/${file_paths.blazeWorkspaceMarker}', '');
|
||||
var workspace = BlazeWorkspace.find(
|
||||
resourceProvider, convertPath('/workspace/my/module'))!;
|
||||
expect(workspace.root, convertPath('/workspace'));
|
||||
expect(workspace.readonly, isNull);
|
||||
expect(workspace.binPaths.single, convertPath('/workspace/$prefix-bin'));
|
||||
expect(workspace.genfiles, convertPath('/workspace/$prefix-genfiles'));
|
||||
expect(workspace.binPaths.single, convertPath('/workspace/blaze-bin'));
|
||||
expect(workspace.genfiles, convertPath('/workspace/blaze-genfiles'));
|
||||
}
|
||||
|
||||
void test_findFile_hasReadonlyFolder() {
|
||||
|
@ -1159,8 +1158,8 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
|
|||
'/Users/user/test/prime/my/module/test1.dart',
|
||||
'/Users/user/test/prime/my/module/test2.dart',
|
||||
'/Users/user/test/prime/my/module/test3.dart',
|
||||
'/Users/user/test/prime/bazel-bin/my/module/test2.dart',
|
||||
'/Users/user/test/prime/bazel-genfiles/my/module/test3.dart',
|
||||
'/Users/user/test/prime/blaze-bin/my/module/test2.dart',
|
||||
'/Users/user/test/prime/blaze-genfiles/my/module/test3.dart',
|
||||
'/Users/user/test/READONLY/prime/other/module/test4.dart',
|
||||
]);
|
||||
workspace = BlazeWorkspace.find(
|
||||
|
@ -1168,9 +1167,9 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
|
|||
_expectFindFile('/Users/user/test/prime/my/module/test1.dart',
|
||||
equals: '/Users/user/test/prime/my/module/test1.dart');
|
||||
_expectFindFile('/Users/user/test/prime/my/module/test2.dart',
|
||||
equals: '/Users/user/test/prime/bazel-bin/my/module/test2.dart');
|
||||
equals: '/Users/user/test/prime/blaze-bin/my/module/test2.dart');
|
||||
_expectFindFile('/Users/user/test/prime/my/module/test3.dart',
|
||||
equals: '/Users/user/test/prime/bazel-genfiles/my/module/test3.dart');
|
||||
equals: '/Users/user/test/prime/blaze-genfiles/my/module/test3.dart');
|
||||
_expectFindFile('/Users/user/test/prime/other/module/test4.dart',
|
||||
equals: '/Users/user/test/READONLY/prime/other/module/test4.dart');
|
||||
}
|
||||
|
@ -1179,7 +1178,7 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
|
|||
_addResources([
|
||||
'/Users/user/test/READONLY/prime/',
|
||||
'/Users/user/test/prime/',
|
||||
'/Users/user/test/prime/bazel-genfiles/',
|
||||
'/Users/user/test/prime/blaze-genfiles/',
|
||||
'/Users/user/test/prime/my/module/test.dart',
|
||||
'/Users/user/test/READONLY/prime/my/module/test.dart',
|
||||
]);
|
||||
|
@ -1195,17 +1194,17 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
|
|||
'/workspace/my/module/test1.dart',
|
||||
'/workspace/my/module/test2.dart',
|
||||
'/workspace/my/module/test3.dart',
|
||||
'/workspace/bazel-bin/my/module/test2.dart',
|
||||
'/workspace/bazel-genfiles/my/module/test3.dart',
|
||||
'/workspace/blaze-bin/my/module/test2.dart',
|
||||
'/workspace/blaze-genfiles/my/module/test3.dart',
|
||||
]);
|
||||
workspace = BlazeWorkspace.find(
|
||||
resourceProvider, convertPath('/workspace/my/module'))!;
|
||||
_expectFindFile('/workspace/my/module/test1.dart',
|
||||
equals: '/workspace/my/module/test1.dart');
|
||||
_expectFindFile('/workspace/my/module/test2.dart',
|
||||
equals: '/workspace/bazel-bin/my/module/test2.dart');
|
||||
equals: '/workspace/blaze-bin/my/module/test2.dart');
|
||||
_expectFindFile('/workspace/my/module/test3.dart',
|
||||
equals: '/workspace/bazel-genfiles/my/module/test3.dart');
|
||||
equals: '/workspace/blaze-genfiles/my/module/test3.dart');
|
||||
}
|
||||
|
||||
/// Create new files and directories from [paths].
|
||||
|
|
|
@ -29,8 +29,8 @@ class BlazeWatcherTest with ResourceProviderMixin {
|
|||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
]);
|
||||
var candidates = [
|
||||
convertPath('/workspace/bazel-bin/my/module/test1.dart'),
|
||||
convertPath('/workspace/bazel-genfiles/my/module/test1.dart'),
|
||||
convertPath('/workspace/blaze-bin/my/module/test1.dart'),
|
||||
convertPath('/workspace/blaze-genfiles/my/module/test1.dart'),
|
||||
];
|
||||
var watcher = BlazeFilePoller(resourceProvider, candidates);
|
||||
|
||||
|
@ -74,12 +74,12 @@ class BlazeWatcherTest with ResourceProviderMixin {
|
|||
'/workspace/${file_paths.blazeWorkspaceMarker}',
|
||||
]);
|
||||
var candidates1 = [
|
||||
convertPath('/workspace/bazel-bin/my/module/test1.dart'),
|
||||
convertPath('/workspace/bazel-genfiles/my/module/test1.dart'),
|
||||
convertPath('/workspace/blaze-bin/my/module/test1.dart'),
|
||||
convertPath('/workspace/blaze-genfiles/my/module/test1.dart'),
|
||||
];
|
||||
var candidates2 = [
|
||||
convertPath('/workspace/bazel-bin/my/module/test2.dart'),
|
||||
convertPath('/workspace/bazel-genfiles/my/module/test2.dart'),
|
||||
convertPath('/workspace/blaze-bin/my/module/test2.dart'),
|
||||
convertPath('/workspace/blaze-genfiles/my/module/test2.dart'),
|
||||
];
|
||||
var trigger = _MockPollTrigger();
|
||||
var recPort = ReceivePort();
|
||||
|
@ -151,12 +151,12 @@ class BlazeWatcherTest with ResourceProviderMixin {
|
|||
'/workspace2/${file_paths.blazeWorkspaceMarker}',
|
||||
]);
|
||||
var candidates1 = [
|
||||
convertPath('/workspace1/bazel-bin/my/module/test1.dart'),
|
||||
convertPath('/workspace1/bazel-genfiles/my/module/test1.dart'),
|
||||
convertPath('/workspace1/blaze-bin/my/module/test1.dart'),
|
||||
convertPath('/workspace1/blaze-genfiles/my/module/test1.dart'),
|
||||
];
|
||||
var candidates2 = [
|
||||
convertPath('/workspace2/bazel-bin/my/module/test2.dart'),
|
||||
convertPath('/workspace2/bazel-genfiles/my/module/test2.dart'),
|
||||
convertPath('/workspace2/blaze-bin/my/module/test2.dart'),
|
||||
convertPath('/workspace2/blaze-genfiles/my/module/test2.dart'),
|
||||
];
|
||||
_MockPollTrigger? trigger1;
|
||||
_MockPollTrigger? trigger2;
|
||||
|
@ -246,7 +246,7 @@ class BlazeWatcherTest with ResourceProviderMixin {
|
|||
void deleteFolder(path) => _deleteResources(['$path/']);
|
||||
|
||||
var candidates = [
|
||||
convertPath('/workspace/bazel-out'),
|
||||
convertPath('/workspace/blaze-out'),
|
||||
convertPath('/workspace/blaze-out'),
|
||||
];
|
||||
var watcher = BlazeFilePoller(resourceProvider, candidates);
|
||||
|
|
|
@ -135,7 +135,7 @@ class ExitCodesTest extends BaseTest {
|
|||
await withTempDirAsync((String tempDirPath) async {
|
||||
var dartSdkPath = path.absolute(getSdkPath());
|
||||
await recursiveCopy(
|
||||
Directory(path.join(testDirectory, 'data', 'bazel')), tempDirPath);
|
||||
Directory(path.join(testDirectory, 'data', 'blaze')), tempDirPath);
|
||||
var origWorkingDir = Directory.current;
|
||||
try {
|
||||
Directory.current = path.join(tempDirPath, 'proj');
|
||||
|
|
Loading…
Reference in a new issue