Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Added script to generate missing tests
This script will basically search for a file of the same name in the
test/tests directory and then string search in that file for field
and function names. Simple but effective for what we're doing.
  • Loading branch information
John Haley committed Nov 12, 2014
commit 2cb72ceaffa9ff9fd6e3758b3091b0c27407cd5e
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/vendor/*.sln

/generate/idefs.json
/generate/missing-tests.json
/binding.gyp

*.log
53 changes: 53 additions & 0 deletions generate/missing-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const path = require("path");
const idefs = require("./idefs");
const Promise = require("nodegit-promise");
const promisify = require("promisify-node");
const fse = promisify(require("fs-extra"));
const testFilesPath = path.resolve(__dirname, "../test/tests");

var output = {};

function findMissingTest(idef) {
var testFilePath = path.join(testFilesPath, idef.filename + ".js");
var result = {};

return fse.readFile(testFilePath, "utf8")
.then(function(file) {
var fieldsResult = [];
var functionsResult = [];

idef.fields.forEach(function(field) {
if (file.indexOf(field.jsFunctionName) < 0) {
fieldsResult.push(field.jsFunctionName);
}
});

result.fields = fieldsResult;

idef.functions.forEach(function(fn) {
if (file.indexOf(fn.jsFunctionName) < 0) {
functionsResult.push(fn.jsFunctionName);
}
});

result.functions = functionsResult;
},
function() {
result.testFileMissing = false;
result.testFilePath = testFilePath;
}).then(function() {
output[idef.filename] = result;
});
};

var promises = [];

idefs.forEach(function(idef) {
promises.push(findMissingTest(idef));
});

Promise.all(promises)
.then(function() {
fse.writeFileSync(path.join(__dirname, "missing-tests.json"),
JSON.stringify(output, null, 2));
});
1 change: 0 additions & 1 deletion generate/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ libgit2.types.forEach(function(type) {
// libgit2's docs aren't complete so we'll add in what they're missing here
Array.prototype.push.apply(libgit2.types, supplement.new.types);


var output = [];
var groupNames = [];
var dependencyLookup = {};
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"nan": "~1.3.0",
"node-gyp": "~1.0.2",
"node-pre-gyp": "~0.5.27",
"nodegit-promise": "~1.0.0",
"promise": "~6.0.0",
"promisify-node": "~0.1.2",
"q": "~1.0.1",
Expand All @@ -91,6 +92,7 @@
"cov": "istanbul cover node_modules/mocha/bin/_mocha -- test/runner test/tests --report=lcov",
"mocha": "mocha test/runner test/tests",
"test": "npm run lint && npm run cov",
"missing-tests": "node generate/missing-tests",
"publish": "node-pre-gyp package && node-pre-gyp publish",
"generate": "node generate/setup && node generate",
"install": "npm run generate && node install",
Expand Down