You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by al...@apache.org on 2020/04/14 08:20:52 UTC

[openwhisk-wskdebug] branch debug-envvar created (now 3a70753)

This is an automated email from the ASF dual-hosted git repository.

alexkli pushed a change to branch debug-envvar
in repository https://gitbox.apache.org/repos/asf/openwhisk-wskdebug.git.


      at 3a70753  [nodejs] pass through DEBUG, NODE_DEBUG environment variables #43

This branch includes the following new commits:

     new 3a70753  [nodejs] pass through DEBUG, NODE_DEBUG environment variables #43

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[openwhisk-wskdebug] 01/01: [nodejs] pass through DEBUG, NODE_DEBUG environment variables #43

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

alexkli pushed a commit to branch debug-envvar
in repository https://gitbox.apache.org/repos/asf/openwhisk-wskdebug.git

commit 3a70753ed049cac065c0354cf9a429a1d2f745bc
Author: Alexander Klimetschek <ak...@adobe.com>
AuthorDate: Tue Apr 14 01:19:57 2020 -0700

    [nodejs] pass through DEBUG, NODE_DEBUG environment variables #43
    
    set WSK_NODE_DEBUG to control NODE_DEBUG in the container, to avoid
    affecting it wskdebug itself
---
 src/kinds/nodejs/nodejs.js | 12 +++++++++++-
 test/nodejs.test.js        | 30 ++++++++++++++++++++++++++++--
 2 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/src/kinds/nodejs/nodejs.js b/src/kinds/nodejs/nodejs.js
index 08f0c9f..38d6396 100644
--- a/src/kinds/nodejs/nodejs.js
+++ b/src/kinds/nodejs/nodejs.js
@@ -36,13 +36,23 @@ module.exports = {
 
     // return extra docker arguments such as mounting the source path
     dockerArgs: function(invoker) {
+        let args = "";
         if (invoker.sourceDir) {
             if (!invoker.sourceFile) {
                 throw new Error("[source-path] or --build-path must point to the action javascript source file, it cannot be a folder.");
             }
 
-            return `-v "${invoker.sourceDir}:${CODE_MOUNT}"`;
+            args += ` -v "${invoker.sourceDir}:${CODE_MOUNT}"`;
         }
+
+        if (process.env.WSK_NODE_DEBUG) {
+            args += ` -e NODE_DEBUG='${process.env.WSK_NODE_DEBUG}'`;
+        }
+        if (process.env.DEBUG) {
+            args += ` -e DEBUG='${process.env.DEBUG}'`;
+        }
+
+        return args;
     },
 
     // return action for /init that mounts the sources specified by invoker.sourcePath
diff --git a/test/nodejs.test.js b/test/nodejs.test.js
index 9eb2f54..625e276 100644
--- a/test/nodejs.test.js
+++ b/test/nodejs.test.js
@@ -61,6 +61,9 @@ describe('nodejs', function() {
 
     afterEach(function() {
         test.afterEach();
+
+        delete process.env.DEBUG;
+        delete process.env.WSK_NODE_DEBUG;
     });
 
     it("should run an action without local sources", async function() {
@@ -548,14 +551,37 @@ describe('nodejs', function() {
         test.assertAllNocksInvoked();
     });
 
+    it("should pass through DEBUG and NODE_DEBUG env vars", async function() {
+        test.mockActionAndInvocation(
+            "myaction",
+            `function main(params) {
+                return {
+                    msg: 'CORRECT',
+                    debug: process.env.DEBUG,
+                    nodeDebug: process.env.NODE_DEBUG,
+                }
+            }`,
+            { },
+            {
+                msg: "CORRECT",
+                debug: "debug",
+                nodeDebug: "node_debug"
+            }
+        );
+
+        process.env.DEBUG = "debug";
+        process.env.WSK_NODE_DEBUG = "node_debug";
+        await wskdebug(`myaction -p ${test.port}`);
+
+        test.assertAllNocksInvoked();
+    });
+
     // TODO: test -l livereload connection
 
     // TODO: test agents - conditions (unit test agent code locally)
-    // TODO: test agent already installed (debugger.getAction())
 
     // TODO: test breakpoint debugging
     // TODO: test action options
     // TODO: test debugger options
-    // TODO: test non-concurrent openwhisk
 
 });