diff --git a/.gitignore b/.gitignore index 6778ac723..afac9533a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ /vendor/*.sln /generate/idefs.json +/generate/missing-tests.json /binding.gyp *.log diff --git a/generate/missing-tests-ignore.json b/generate/missing-tests-ignore.json new file mode 100644 index 000000000..eac03aba8 --- /dev/null +++ b/generate/missing-tests-ignore.json @@ -0,0 +1,34 @@ +{ + "blob": { + "functions": [ + "createFrombuffer", + "isBinary", + "lookup", + "rawcontent", + "rawsize" + ] + }, + "clone": { + "functions": [ + "initOptions" + ] + }, + "commit": { + "functions": [ + "parentCount", + "parentId", + "treeId" + ] + }, + "diff": { + "functions": [ + "getDelta", + "numDeltas" + ] + }, + "object": { + "functions": [ + "type" + ] + } +} diff --git a/generate/missing-tests.js b/generate/missing-tests.js new file mode 100644 index 000000000..339f1a217 --- /dev/null +++ b/generate/missing-tests.js @@ -0,0 +1,64 @@ +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"); +const missingFileIgnores = require("./missing-tests-ignore"); + +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 = []; + var fieldIgnores = (missingFileIgnores[idef.filename] || {}).fields; + var functionIgnores = (missingFileIgnores[idef.filename] || {}).functions; + + fieldIgnores = fieldIgnores || []; + functionIgnores = functionIgnores || []; + file = file || ""; + + idef.fields.forEach(function(field) { + if (file.indexOf(field.jsFunctionName) < 0 + && fieldIgnores.indexOf(field.jsFunctionName < 0)) { + fieldsResult.push(field.jsFunctionName); + } + }); + + result.fields = fieldsResult; + + idef.functions.forEach(function(fn) { + if (file.indexOf(fn.jsFunctionName) < 0 + && functionIgnores.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)); +}, function(fail) { + console.log(fail); +}); diff --git a/generate/setup.js b/generate/setup.js index 99304d836..50a82ccd7 100644 --- a/generate/setup.js +++ b/generate/setup.js @@ -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 = {}; diff --git a/package.json b/package.json index 395d8ca87..34abef0d8 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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",