From f0beb63531993829f6b5e43250c9477b58c88d53 Mon Sep 17 00:00:00 2001
From: "francois.grand" <francois.grand@irstea.fr>
Date: Tue, 30 May 2017 10:16:06 +0200
Subject: [PATCH] =?UTF-8?q?ajout=20des=20outils=20de=20d=C3=A9buggage=20de?=
 =?UTF-8?q?s=20tests=20unitaires=20avec=20Chrome=20Inspector=20(debug=5Fte?=
 =?UTF-8?q?st)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .gitignore |  1 -
 Makefile   | 30 ++++++++++++++++++++++++++++++
 debug_test | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 84 insertions(+), 1 deletion(-)
 create mode 100644 Makefile
 create mode 100755 debug_test

diff --git a/.gitignore b/.gitignore
index e1d33528..948f3336 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,7 +33,6 @@
 npm-debug.log
 testem.log
 /typings
-Makefile
 
 # e2e
 /e2e/*.js
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..e94987b7
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,30 @@
+SRC_DIR := src
+BUILD_DIR := build
+NODE_BASE := $(HOME)/Documents/dev/node-v6.10.2-linux-x64
+NODE := $(NODE_BASE)/bin/node
+
+JASMINE_CLI := ./node_modules/jasmine-node/lib/jasmine-node/cli.js
+
+#$(error $(NODE))
+
+SOURCE_FILES := $(shell find $(SRC_DIR) -name *.ts)
+
+all : compile
+
+compile : build-dir $(SOURCE_FILES)
+	npm run build
+
+build-dir :
+	mkdir -p $(BUILD_DIR)
+
+buildspec :
+	npm run buildspec
+
+jasmine : buildspec
+	npm run jasmine
+
+karma :
+	npm run karma
+
+clean :
+	rm -rf $(BUILD_DIR)
diff --git a/debug_test b/debug_test
new file mode 100755
index 00000000..f575fbd7
--- /dev/null
+++ b/debug_test
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+do_kill()
+{
+  local pid=$1
+  if [[ -n $pid ]]; then
+    if [[ -n $(ps -ef|grep $pid|grep -v grep) ]]; then
+      echo "killing $pid..."
+      kill $jm_pid
+    else
+      echo "no process with pid $pid"
+    fi
+  fi
+}
+
+do_exit()
+{
+#   echo "exits"
+   do_kill $jm_pid
+}
+
+syntax()
+{
+  echo "syntaxe : $(basename $0) <fichier spec>"
+  exit 1
+}
+
+trap do_exit SIGINT
+trap do_exit EXIT
+
+if [[ $# != 1 ]]; then
+  syntax
+fi
+
+ni=$(ps -ef|grep node-inspector|grep -v grep)
+if [[ -z $ni ]]; then
+  echo "starting node-inspector..."
+  node-inspector &
+else
+  echo "node-inspector already running"
+fi
+echo
+
+echo "debugging $1..."
+node --debug-brk ./node_modules/jasmine-node/bin/jasmine-node $1 &
+jm_pid=$!
+echo
+
+#ps -ef|grep jasmine-node|grep -v grep
+#pid=$(ps -ef|grep jasmine-node|grep -v grep|awk '{print $2}')
+#echo $pid $jm_pid
+
+echo "starting Chrome...."
+chromium-browser http://127.0.0.1:8080/?port=5858
-- 
GitLab