Skip to content

Add test suite #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ FROM node

MAINTAINER Michael R. Bernstein

RUN useradd -u 9000 -r -s /bin/false app
RUN useradd -u 9000 -r -s /bin/false app

RUN npm install glob

WORKDIR /code
COPY . /usr/src/app
COPY engine.json /

USER app
VOLUME /code
Expand Down
11 changes: 11 additions & 0 deletions engine.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "fixme",
"description": "Discover lurking FIXMEs, BUGs, TODOs, etc. in your code",
"maintainer": {
"name": "Michael R. Bernstein",
"email": "[email protected]"
},
"test_paths": [
"/usr/src/app/test/integration/"
]
}
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ var excludeExtensions = [".jpg", ".jpeg", ".png", ".gif"];
var printIssue = function(fileName, lineNum, matchedString){
var issue = {
"type": "issue",
"check_name": "FIXME found",
"check_name": matchedString,
"description": matchedString + " found",
"categories": ["Bug Risk"],
"location":{
"path": fileName,
"lines": {
"begin": lineNum,
"end": lineNum
"end": lineNum
}
}
};
Expand All @@ -44,7 +44,7 @@ var findFixmes = function(file){
if (results !== ""){
// Parses grep output
var lines = results.split("\n");

lines.forEach(function(line, index, array){
// grep spits out an extra line that we can ignore
if(index < (array.length-1)){
Expand All @@ -57,7 +57,7 @@ var findFixmes = function(file){
var matchedString = cols[2];

if (matchedString !== undefined){
printIssue(fileName, lineNum, matchedString);
printIssue(fileName, parseInt(lineNum), matchedString);
}
}
})
Expand All @@ -82,7 +82,7 @@ var fileWalk = function(excludePaths){
analysisFiles.push(file);
}
});

return analysisFiles;
}

Expand Down
41 changes: 41 additions & 0 deletions test/integration/fixme.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#####################################################################
#####################################################################
## Integration tests for this engine must escape uses of the magic
## keywords, otherwise the engine will flag additional issues on the
## lines with the test markers themselves. We use backslash escaping
## to avoid this problem.
#####################################################################
#####################################################################

# [issue] check_name="F\IXME" description="F\IXME found" category="Bu\g Risk"
# FIXME: This is broken
x = x

############################

foo = $stdin.gets
# [issue] check_name="B\UG" description="B\UG found" category="Bu\g Risk"
# BUG: This should use double equals
if (foo = "foo")
puts "You said foo"
end

############################

foo = $stdin.gets
# [issue] check_name="X\XX" description="X\XX found" category="Bu\g Risk"
# XXX: This should use double equals
if (foo = "foo")
puts "You said foo"
end

############################

# [issue] check_name="T\ODO" description="T\ODO found" category="Bu\g Risk"
# TODO: Add more tests

############################

# [issue] check_name="H\ACK" description="H\ACK found" category="Bu\g Risk"
# HACK
instance_eval "CRAZY STUFF"