Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1788)

Unified Diff: packages/which/test/is_executable_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/which/test/has_permission_test.dart ('k') | packages/which/test/test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/which/test/is_executable_test.dart
diff --git a/packages/which/test/is_executable_test.dart b/packages/which/test/is_executable_test.dart
new file mode 100755
index 0000000000000000000000000000000000000000..788c41434865844769e3efe1f7c808fb79a13a5e
--- /dev/null
+++ b/packages/which/test/is_executable_test.dart
@@ -0,0 +1,74 @@
+
+library which.test.is_executable;
+
+import 'dart:io';
+
+import 'package:mockito/mockito.dart';
+import 'package:unittest/unittest.dart';
+import 'package:which/src/is_executable.dart';
+
+import 'util.dart';
+
+main() {
+ group('isExecutableStat', () {
+ test('false if not a file', () {
+
+ var stat = new MockFileStat();
+
+ // A directory.
+ when(stat.type).thenReturn(FileSystemEntityType.DIRECTORY);
+
+ var result = isExecutableStat(stat, false);
+
+ expect(result, isFalse);
+
+ verifyNever(stat.mode);
+ });
+
+ test('true for all files on windows', () {
+
+ var stat = new MockFileStat();
+
+ // A file.
+ when(stat.type).thenReturn(FileSystemEntityType.FILE);
+
+ var result = isExecutableStat(stat, true);
+
+ expect(result, isTrue);
+
+ verifyNever(stat.mode);
+ });
+
+ test('true if has world execute permission', () {
+ var result = isExecutableStat(_getMockFileStat('000000000001'), false);
+ expect(result, isTrue);
+ });
+
+ test('true if has group execute permission', () {
+ var result = isExecutableStat(_getMockFileStat('000000001000'), false);
+ expect(result, isTrue);
+ });
+
+ test('true if has owner execute permission', () {
+ var result = isExecutableStat(_getMockFileStat('000001000000'), false);
+ expect(result, isTrue);
+ });
+
+ test('false if has no execute permissions', () {
+ var result = isExecutableStat(_getMockFileStat('111110110110'), false);
+ expect(result, isFalse);
+ });
+ });
+}
+
+MockFileStat _getMockFileStat(String mode) {
+ var stat = new MockFileStat();
+
+ // A file.
+ when(stat.type).thenReturn(FileSystemEntityType.FILE);
+
+ // Last bit is world execute.
+ when(stat.mode).thenReturn(int.parse(mode, radix: 2));
+
+ return stat;
+}
« no previous file with comments | « packages/which/test/has_permission_test.dart ('k') | packages/which/test/test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698