os_utils_test.dart 1.14 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:path/path.dart' as path;
9
import 'package:test/test.dart';
10

11 12
import 'src/context.dart';

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

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

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

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

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