From 9a73d9d2155af4259a062cf82ef44039895c22ad Mon Sep 17 00:00:00 2001 From: blagoev Date: Sat, 6 May 2017 15:19:19 +0300 Subject: [PATCH] Improve VS Code debug Allow debugging of session-tests and improve VS Code debug tasks. New VS Code task to download and start server for debugging New VS Code tasks to build only changed files and full rebuild --- .vscode/launch.json | 42 ++++++++++++++++++++++++++++ .vscode/tasks.json | 32 ++++++++++++++++----- package.json | 6 ++-- scripts/download_and_start_server.sh | 6 ++++ 4 files changed, 77 insertions(+), 9 deletions(-) create mode 100755 scripts/download_and_start_server.sh diff --git a/.vscode/launch.json b/.vscode/launch.json index 347e625d..09612ab2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,24 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Debug LLDB", + "program": "node", + "cwd": "${workspaceRoot}/tests", + "args": ["--debug-brk=5858", "${workspaceRoot}/tests/node_modules/jasmine/bin/jasmine.js", "spec/unit_tests.js"], + "stopOnEntry": true + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug LLDB only", + "program": "node", + "cwd": "${workspaceRoot}/tests", + "args": ["${workspaceRoot}/tests/node_modules/jasmine/bin/jasmine.js", "spec/unit_tests.js"], + "stopOnEntry": false + }, { "type": "node", "request": "launch", @@ -24,6 +42,30 @@ "args": [ "spec/unit_tests.js" ] + }, + { + "type": "node", + "request": "launch", + "name": "Download & Start Server", + "cwd": "${workspaceRoot}/scripts" + + }, + { + "type": "node", + "request": "attach", + "name": "Attach to Port", + "address": "localhost", + "port": 5858 + } + ], + "compounds": [ + { + "name": "Rebuild + Start Server + Debug", + "configurations": ["Download & Start Server", "Debug Node Unit Tests (rebuild)"] + }, + { + "name": "Debug LLDB + NodeJS", + "configurations": ["Debug LLDB", "Attach to Port"] } ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index a8a937e6..adb49f34 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -2,15 +2,33 @@ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "0.1.0", - "command": "npm", - "isShellCommand": true, - "showOutput": "always", - "suppressTaskName": true, "tasks": [ { - "taskName": "rebuild-node-tests", - - "args": ["run", "prenode-tests"] + "taskName": "Rebuild Node Tests", + "command": "npm", + "isShellCommand": true, + "showOutput": "always", + "suppressTaskName": true, + "args": ["run", "rebuild-changes"], + "isBuildCommand": false + }, + { + "taskName": "Build Node Tests", + "command": "npm", + "isShellCommand": true, + "showOutput": "always", + "suppressTaskName": true, + "args": ["run", "build-changes"], + "isBuildCommand": true + }, + { + "taskName": "Download and Start Server", + "command": "${workspaceRoot}/scripts/download_and_start_server.sh", + "isShellCommand": true, + "showOutput": "always", + "echoCommand": true, + "isBackground": true, + "suppressTaskName": true } ] } \ No newline at end of file diff --git a/package.json b/package.json index 69634f05..67ab0484 100644 --- a/package.json +++ b/package.json @@ -48,10 +48,12 @@ "set-version": "scripts/set-version.sh", "get-core-version": "env-cmd ./dependencies.list node -p process.env.REALM_CORE_VERSION", "get-sync-version": "env-cmd ./dependencies.list node -p process.env.REALM_SYNC_VERSION", - "lint": "eslint", + "lint": "eslint", "test": "scripts/test.sh", "install": "node-pre-gyp install --fallback-to-build", - "prepublish": "node scripts/prepublish.js", + "build-changes": "node-pre-gyp build --fallback-to-build --debug --build-from-source", + "rebuild-changes": "node-pre-gyp install --fallback-to-build --debug --build-from-source && cd tests && npm install", + "prepublish": "echo prepublishing && node scripts/prepublish.js", "eslint": "npm install && npm run lint .", "license-check": "npm install && license-checker --exclude \"MIT,ISC,BSD,Apache-2.0,BSD-2-Clause,BSD-3-Clause,WTFPL,Unlicense,(MIT AND CC-BY-3.0)\" | node scripts/handle-license-check.js", "jsdoc:clean": "rimraf ./docs/output", diff --git a/scripts/download_and_start_server.sh b/scripts/download_and_start_server.sh new file mode 100755 index 00000000..40e3842c --- /dev/null +++ b/scripts/download_and_start_server.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -o pipefail +set -e +echo $(pwd) +sh scripts/download-object-server.sh && sh object-server-for-testing/start-object-server.command -f && echo \"Server PID: $!\" \ No newline at end of file