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
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
|
|
|
import 'src/context.dart';
|
|
|
|
|
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(() {
|
2017-03-14 17:28:56 +00:00
|
|
|
fs = new MemoryFileSystem();
|
|
|
|
fs.directory(_kFlutterRoot).createSync(recursive: true);
|
|
|
|
Cache.flutterRoot = _kFlutterRoot;
|
2017-01-09 16:37:00 +00:00
|
|
|
tempDir = fs.systemTempDirectory.createTempSync('analysis_test');
|
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,
|
2016-09-08 02:41:59 +00:00
|
|
|
});
|
2016-03-06 20:26:29 +00:00
|
|
|
});
|
|
|
|
}
|