]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/node-gyp/test/test-addon.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / node-gyp / test / test-addon.js
diff --git a/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/node-gyp/test/test-addon.js b/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/node-gyp/test/test-addon.js
new file mode 100644 (file)
index 0000000..c2a71f4
--- /dev/null
@@ -0,0 +1,28 @@
+'use strict'
+
+var test = require('tape')
+var execFile = require('child_process').execFile
+var path = require('path')
+var addonPath = path.resolve(__dirname, 'node_modules', 'hello_world')
+var nodeGyp = path.resolve(__dirname, '..', 'bin', 'node-gyp.js')
+
+test('build simple addon', function (t) {
+  t.plan(3)
+
+  // Set the loglevel otherwise the output disappears when run via 'npm test'
+  var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
+  var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
+    var logLines = stderr.toString().trim().split(/\r?\n/)
+    var lastLine = logLines[logLines.length-1]
+    t.strictEqual(err, null)
+    t.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
+    try {
+      var binding = require('hello_world')
+      t.strictEqual(binding.hello(), 'world')
+    } catch (error) {
+      t.error(error, 'load module')
+    }
+  })
+  proc.stdout.setEncoding('utf-8')
+  proc.stderr.setEncoding('utf-8')
+})