2016-03-06 20:26:29 +00:00
|
|
|
// Copyright 2016 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2017-03-14 17:28:56 +00:00
|
|
|
import 'package:file/file.dart';
|
|
|
|
import 'package:file/memory.dart';
|
2016-09-08 02:41:59 +00:00
|
|
|
import 'package:flutter_tools/src/cache.dart';
|
2016-10-04 12:20:24 +00:00
|
|
|
import 'package:flutter_tools/src/commands/analyze_base.dart';
|
2016-03-06 20:26:29 +00:00
|
|
|
|
2019-07-13 18:51:44 +00:00
|
|
|
import '../../src/common.dart';
|
|
|
|
import '../../src/context.dart';
|
2016-03-06 20:26:29 +00:00
|
|
|
|
2017-03-14 17:28:56 +00:00
|
|
|
const String _kFlutterRoot = '/data/flutter';
|
|
|
|
|
2016-03-10 01:43:14 +00:00
|
|
|
void main() {
|
2017-03-14 17:28:56 +00:00
|
|
|
FileSystem fs;
|
2016-03-06 20:26:29 +00:00
|
|
|
Directory tempDir;
|
|
|
|
|
|
|
|
setUp(() {
|
2018-09-12 06:29:29 +00:00
|
|
|
fs = MemoryFileSystem();
|
2017-03-14 17:28:56 +00:00
|
|
|
fs.directory(_kFlutterRoot).createSync(recursive: true);
|
|
|
|
Cache.flutterRoot = _kFlutterRoot;
|
2018-08-17 20:17:23 +00:00
|
|
|
tempDir = fs.systemTempDirectory.createTempSync('flutter_analysis_test.');
|
|
|
|
});
|
|
|
|
|
|
|
|
tearDown(() {
|
|
|
|
tryToDelete(tempDir);
|
2016-03-06 20:26:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
group('analyze', () {
|
2016-09-08 02:41:59 +00:00
|
|
|
testUsingContext('inRepo', () {
|
|
|
|
// Absolute paths
|
2016-10-04 12:20:24 +00:00
|
|
|
expect(inRepo(<String>[tempDir.path]), isFalse);
|
2017-02-14 01:45:50 +00:00
|
|
|
expect(inRepo(<String>[fs.path.join(tempDir.path, 'foo')]), isFalse);
|
2016-10-04 12:20:24 +00:00
|
|
|
expect(inRepo(<String>[Cache.flutterRoot]), isTrue);
|
2017-02-14 01:45:50 +00:00
|
|
|
expect(inRepo(<String>[fs.path.join(Cache.flutterRoot, 'foo')]), isTrue);
|
2017-03-14 17:28:56 +00:00
|
|
|
|
2016-09-08 02:41:59 +00:00
|
|
|
// Relative paths
|
2017-03-14 17:28:56 +00:00
|
|
|
fs.currentDirectory = Cache.flutterRoot;
|
|
|
|
expect(inRepo(<String>['.']), isTrue);
|
|
|
|
expect(inRepo(<String>['foo']), isTrue);
|
|
|
|
fs.currentDirectory = tempDir.path;
|
|
|
|
expect(inRepo(<String>['.']), isFalse);
|
|
|
|
expect(inRepo(<String>['foo']), isFalse);
|
|
|
|
|
2016-09-08 02:41:59 +00:00
|
|
|
// Ensure no exceptions
|
2016-10-04 12:20:24 +00:00
|
|
|
inRepo(null);
|
|
|
|
inRepo(<String>[]);
|
2017-03-14 17:28:56 +00:00
|
|
|
}, overrides: <Type, Generator>{
|
|
|
|
FileSystem: () => fs,
|
2019-10-23 05:05:00 +00:00
|
|
|
ProcessManager: () => FakeProcessManager.any(),
|
2016-09-08 02:41:59 +00:00
|
|
|
});
|
2016-03-06 20:26:29 +00:00
|
|
|
});
|
|
|
|
}
|