os_utils_test.dart 931 Bytes
Newer Older
1 2 3 4 5 6
// 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.

import 'dart:io';

7
import 'package:flutter_tools/src/base/os.dart';
8
import 'package:path/path.dart' as path;
9
import 'package:test/test.dart';
10

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

    setUp(() {
16
      temp = Directory.systemTemp.createTempSync('flutter_tools');
17 18 19 20 21 22 23
    });

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

    test('makeExecutable', () {
24
      File file = new File(path.join(temp.path, 'foo.script'));
25
      file.writeAsStringSync('hello world');
26
      os.makeExecutable(file);
27 28 29 30 31 32 33 34 35 36

      // Skip this test on windows.
      if (!Platform.isWindows) {
        String mode = file.statSync().modeString();
        // rwxr--r--
        expect(mode.substring(0, 3), endsWith('x'));
      }
    });
  });
}