os_utils_test.dart 1.12 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
import 'package:test/test.dart';
9

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

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

    setUp(() {
17
      temp = fs.systemTempDirectory.createTempSync('flutter_tools');
18 19 20 21 22 23
    });

    tearDown(() {
      temp.deleteSync(recursive: true);
    });

24
    testUsingContext('makeExecutable', () async {
25
      final File file = fs.file(fs.path.join(temp.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 36
    }, overrides: <Type, Generator> {
      OperatingSystemUtils: () => new OperatingSystemUtils(),
37 38 39
    });
  });
}