os_utils_test.dart 1.13 KB
Newer Older
1 2 3 4
// Copyright 2015 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.

5
import 'package:flutter_tools/src/base/file_system.dart';
6
import 'package:flutter_tools/src/base/os.dart';
7
import 'package:flutter_tools/src/base/platform.dart';
8

9
import '../src/common.dart';
10
import '../src/context.dart';
11

12
void main() {
13
  group('OperatingSystemUtils', () {
14
    Directory tempDir;
15 16

    setUp(() {
17
      tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_os_utils_test.');
18 19 20
    });

    tearDown(() {
21
      tryToDelete(tempDir);
22 23
    });

24
    testUsingContext('makeExecutable', () async {
25
      final File file = fs.file(fs.path.join(tempDir.path, 'foo.script'));
26
      file.writeAsStringSync('hello world');
27
      os.makeExecutable(file);
28 29

      // Skip this test on windows.
30
      if (!platform.isWindows) {
31
        final String mode = file.statSync().modeString();
32 33 34
        // rwxr--r--
        expect(mode.substring(0, 3), endsWith('x'));
      }
35
    }, overrides: <Type, Generator> {
36
      OperatingSystemUtils: () => OperatingSystemUtils(),
37 38 39
    });
  });
}