os_utils_test.dart 1.56 KB
Newer Older
1 2 3 4 5
// 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';
6
import 'package:flutter_tools/src/base/logger.dart';
7
import 'package:flutter_tools/src/base/os.dart';
8 9 10
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/signals.dart';
import 'package:process/process.dart';
11 12 13 14 15 16

import '../../src/common.dart';

void main() {
  group('OperatingSystemUtils', () {
    Directory tempDir;
17
    FileSystem fileSystem;
18 19

    setUp(() {
20 21
      fileSystem = LocalFileSystem.test(signals: Signals.test());
      tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_tools_os_utils_test.');
22 23 24 25 26 27
    });

    tearDown(() {
      tryToDelete(tempDir);
    });

28 29 30 31 32 33 34 35 36
    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'));
37
      file.writeAsStringSync('hello world');
38
      operatingSystemUtils.makeExecutable(file);
39 40

      // Skip this test on windows.
41
      if (!platform.isWindows) {
42 43 44 45 46 47 48
        final String mode = file.statSync().modeString();
        // rwxr--r--
        expect(mode.substring(0, 3), endsWith('x'));
      }
    });
  });
}