Skip to content

Commit

Permalink
Fix #33 -- Check for executable bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey Richardson authored and isaacs committed Jul 31, 2012
1 parent b82f519 commit c27e5ab
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/tap-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
4 changes: 4 additions & 0 deletions test/executed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

echo "1..1"
echo "ok 1 File with executable bit should be executed"
4 changes: 4 additions & 0 deletions test/not-executed.sh
Original file line number Diff line number Diff line change
@@ -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.