Permalink
Browse files

Fix #33 -- Check for executable bit

  • Loading branch information...
1 parent b82f519 commit c27e5abad448fc905ab8701919a8f1054f7f9eb6 Corey Richardson committed with isaacs Jan 7, 2012
Showing with 21 additions and 1 deletion.
  1. +13 −1 lib/tap-runner.js
  2. +4 −0 test/executed.sh
  3. +4 −0 test/not-executed.sh
View
@@ -139,13 +139,25 @@ Runner.prototype.runFiles = function (files, dir, cb) {
}
var cmd = f, args = [], env = {}
-
if (path.extname(f) === ".js") {
cmd = "node"
args = [fileName]
} else if (path.extname(f) === ".coffee") {
cmd = "coffee"
args = [fileName]
+ } else {
+ // Check if file is executable
+ if ((st.mode & 0100) && process.getuid) {
+ if (process.getuid() != st.uid) {
+ return cb()
+ }
+ } else if ((st.mode & 0010) && process.getgid) {
+ if (process.getgid() != st.gid) {
+ return cb()
+ }
+ } else if ((st.mode & 0001) == 0) {
+ return cb()
+ }
}
if (st.isDirectory()) {
View
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo "1..1"
+echo "ok 1 File with executable bit should be executed"
View
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo "1..1"
+echo "not ok 1 File without executable bit should not be run"

0 comments on commit c27e5ab

Please sign in to comment.