2020-02-15 00:10:47 +00:00
|
|
|
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
import 'package:flutter_tools/src/base/file_system.dart';
|
2020-06-29 22:06:58 +00:00
|
|
|
import 'package:flutter_tools/src/base/logger.dart';
|
2020-02-15 00:10:47 +00:00
|
|
|
import 'package:flutter_tools/src/base/os.dart';
|
2020-06-29 22:06:58 +00:00
|
|
|
import 'package:flutter_tools/src/base/platform.dart';
|
|
|
|
import 'package:flutter_tools/src/base/signals.dart';
|
2021-02-08 17:21:46 +00:00
|
|
|
import 'package:process/process.dart';
|
2020-02-15 00:10:47 +00:00
|
|
|
|
|
|
|
import '../../src/common.dart';
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
group('OperatingSystemUtils', () {
|
2021-04-08 21:55:19 +00:00
|
|
|
late Directory tempDir;
|
|
|
|
late FileSystem fileSystem;
|
2020-02-15 00:10:47 +00:00
|
|
|
|
|
|
|
setUp(() {
|
2020-06-29 22:06:58 +00:00
|
|
|
fileSystem = LocalFileSystem.test(signals: Signals.test());
|
|
|
|
tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_tools_os_utils_test.');
|
2020-02-15 00:10:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
tearDown(() {
|
|
|
|
tryToDelete(tempDir);
|
|
|
|
});
|
|
|
|
|
2020-06-29 22:06:58 +00:00
|
|
|
testWithoutContext('makeExecutable', () async {
|
|
|
|
const Platform platform = LocalPlatform();
|
|
|
|
final OperatingSystemUtils operatingSystemUtils = OperatingSystemUtils(
|
|
|
|
fileSystem: fileSystem,
|
|
|
|
logger: BufferLogger.test(),
|
|
|
|
platform: platform,
|
|
|
|
processManager: const LocalProcessManager(),
|
|
|
|
);
|
|
|
|
final File file = fileSystem.file(fileSystem.path.join(tempDir.path, 'foo.script'));
|
2020-02-15 00:10:47 +00:00
|
|
|
file.writeAsStringSync('hello world');
|
2020-06-29 22:06:58 +00:00
|
|
|
operatingSystemUtils.makeExecutable(file);
|
2020-02-15 00:10:47 +00:00
|
|
|
|
|
|
|
// Skip this test on windows.
|
2020-06-29 22:06:58 +00:00
|
|
|
if (!platform.isWindows) {
|
2020-02-15 00:10:47 +00:00
|
|
|
final String mode = file.statSync().modeString();
|
|
|
|
// rwxr--r--
|
|
|
|
expect(mode.substring(0, 3), endsWith('x'));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|