-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- allow subset of tests to be run more easily
- Loading branch information
Showing
15 changed files
with
616 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules | ||
/build | ||
/generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
# Enable running tests with specific filter conditions: | ||
|
||
### Example: | ||
|
||
- compile ad run only tests on objectwrap.cc and objectwrap.js | ||
``` | ||
npm run unit --filter=objectwrap | ||
``` | ||
|
||
|
||
# Wildcards are also possible: | ||
|
||
### Example: | ||
|
||
- compile and run all tests files ending with reference -> function_reference.cc object_reference.cc reference.cc | ||
``` | ||
npm run unit --filter=*reference | ||
``` | ||
|
||
# Multiple filter conditions are also allowed | ||
|
||
### Example: | ||
|
||
- compile and run all tests under folders threadsafe_function and typed_threadsafe_function and also the objectwrap.cc file | ||
``` | ||
npm run unit --filter='*function objectwrap' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
/** | ||
* @param bindingConfigurations | ||
* This method acts as a template to generate the content of binding.cc file | ||
*/ | ||
module.exports.generateFileContent = function (bindingConfigurations) { | ||
const content = []; | ||
const inits = []; | ||
const exports = []; | ||
|
||
for (const config of bindingConfigurations) { | ||
inits.push(`Object Init${config.objectName}(Env env);`); | ||
exports.push(`exports.Set("${config.propertyName}", Init${config.objectName}(env));`); | ||
} | ||
|
||
content.push('#include "napi.h"'); | ||
content.push('using namespace Napi;'); | ||
|
||
inits.forEach(init => content.push(init)); | ||
|
||
content.push('Object Init(Env env, Object exports) {'); | ||
|
||
exports.forEach(exp => content.push(exp)); | ||
|
||
content.push('return exports;'); | ||
content.push('}'); | ||
content.push('NODE_API_MODULE(addon, Init);'); | ||
|
||
return Promise.resolve(content.join('\r\n')); | ||
}; | ||
|
||
module.exports.writeToBindingFile = function writeToBindingFile (content) { | ||
const generatedFilePath = path.join(__dirname, 'generated', 'binding.cc'); | ||
fs.writeFileSync(generatedFilePath, ''); | ||
fs.writeFileSync(generatedFilePath, content, { flag: 'a' }); | ||
console.log('generated binding file ', generatedFilePath, new Date()); | ||
}; |
Oops, something went wrong.