-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Deepak Rajamohan
committed
Sep 11, 2021
1 parent
577543b
commit 528dcde
Showing
7 changed files
with
95 additions
and
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const testFunctionsMapV5 = { | ||
"addon": { "objectName": "Addon" }, | ||
"addon_data": { "objectName": "AddonData" } | ||
}; | ||
|
||
const testFunctionsMapV3 = { | ||
"asyncprogressqueueworker": { "objectName": "AsyncProgressQueueWorker" }, | ||
"asyncprogressworker": { "objectName": "AsyncProgressWorker" }, | ||
}; | ||
|
||
const testFunctionsMap = { | ||
"arraybuffer": { "objectName": "ArrayBuffer" }, | ||
"asynccontext": { "objectName": "AsyncContext" }, | ||
"asyncworker-persistent": { "objectName": "PersistentAsyncWorker" }, | ||
"asyncworker": { "objectName": "AsyncWorker" }, | ||
"bigint": { "objectName": "BigInt" }, | ||
"buffer": { "objectName": "Buffer" }, | ||
"callbackscope": { "objectName": "CallbackScope" }, | ||
"date": { "objectName": "Date" }, | ||
"error": { "objectName": "Error" }, | ||
"external": { "objectName": "External" }, | ||
"function": { "objectName": "Function" }, | ||
"functionreference": { "objectName": "FunctionReference" }, | ||
"handlescope": { "objectName": "HandleScope" }, | ||
"memory_management": { "objectName": "MemoryManagement" }, | ||
"movable_callbacks": { "objectName": "MovableCallbacks" }, | ||
"name": { "objectName": "Name" }, | ||
"objectreference": { "objectName": "ObjectReference" }, | ||
"objectwrap-removewrap": { "objectName": "ObjectWrapRemoveWrap" }, | ||
"objectwrap": { "objectName": "ObjectWrap" }, | ||
"objectwrap_constructor_exception": { "objectName": "ObjectWrapConstructorException" }, | ||
"objectwrap_multiple_inheritance": { "objectName": "ObjectWrapMultipleInheritance" }, | ||
"promise": { "objectName": "Promise" }, | ||
"reference": { "objectName": "Reference" }, | ||
"run_script": { "objectName": "RunScript" }, | ||
"symbol": { "objectName": "Symbol" }, | ||
"thunking_manual": { "objectName": "ThunkingManual" }, | ||
"typedarray": { "objectName": "TypedArray" }, | ||
"version_management": { "objectName": "VersionManagement" } | ||
}; |
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 |
---|---|---|
@@ -1,10 +1,6 @@ | ||
#include "napi.h" | ||
#include "hello.h" | ||
using namespace Napi; | ||
Object InitFunction(Env env); | ||
Object Init(Env env, Object exports) { | ||
exports.Set("function", InitFunction(env)); | ||
exports.Set(Napi::String::New(env, "HelloWorld"), Napi::Function::New(env, HelloWorld)); | ||
return exports; | ||
} | ||
NODE_API_MODULE(addon, Init); |
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 |
---|---|---|
@@ -1,47 +1,29 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const addon = require('./build/Release/binding.node'); | ||
const assert = require("assert"); | ||
const { spawn } = require("child_process"); | ||
|
||
process.argv.forEach(function (val, index, array) { | ||
console.log(index + ': ' + val); | ||
}); | ||
const executeTests = async function () { | ||
const childProcess = spawn("node", ["test"], {cwd: path.join(__dirname, '../'), env: { ...process.env, REL_BUILD_PATH: path.join(__dirname, './build') }}); | ||
|
||
const ls = spawn("node", ["test"], {cwd: path.join(__dirname, '../'), env: { ...process.env, REL_BUILD_PATH: path.join(__dirname, './build') }}); | ||
childProcess.stdout.on("data", data => { | ||
console.log(`${data}`); | ||
}); | ||
|
||
ls.stdout.on("data", data => { | ||
console.log(`stdout: ${data}`); | ||
}); | ||
childProcess.stderr.on("data", data => { | ||
console.log(`error: ${data}`); | ||
}); | ||
|
||
ls.stderr.on("data", data => { | ||
console.log(`stderr: ${data}`); | ||
}); | ||
return new Promise((resolve, reject) => { | ||
childProcess.on('error', (error) => { | ||
console.log(`error: ${error.message}`); | ||
reject(error); | ||
}); | ||
|
||
ls.on('error', (error) => { | ||
console.log(`error: ${error.message}`); | ||
}); | ||
childProcess.on("close", code => { | ||
console.log(`child process exited with code ${code}`); | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
|
||
ls.on("close", code => { | ||
console.log(`child process exited with code ${code}`); | ||
}); | ||
|
||
/** | ||
* | ||
* Hello world test | ||
* | ||
*/ | ||
const HelloWorld = addon.HelloWorld; | ||
|
||
assert(HelloWorld, "The expected function is undefined"); | ||
|
||
function testBasic() | ||
{ | ||
const result = HelloWorld("hello"); | ||
assert.strictEqual(result, "world", "Unexpected value returned"); | ||
} | ||
|
||
assert.doesNotThrow(testBasic, undefined, "testBasic threw an expection"); | ||
|
||
console.log("Tests passed- everything looks OK!"); | ||
|
||
executeTests(); |