Skip to content

Commit

Permalink
unsuccessful attempt to run karma in continous mode
Browse files Browse the repository at this point in the history
in watch mode, karmas's web server does not wait for cljs compiler
to finish writing generated files, corrupts its own cache and starts serving corrupted files.
  • Loading branch information
darwin committed Sep 22, 2015
1 parent a094b37 commit 8e7ccec
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 54 deletions.
8 changes: 8 additions & 0 deletions cljs/src/meld/meld/core_tests.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(ns meld.core-tests
(:require-macros [plastic.logging :refer [log info warn error group group-end]]
[cljs.test :refer [deftest is testing]])
(:require [meld.core :as core]))

(deftest meld-core-sample
(testing "testing meld"
(is (= 1 9))))
3 changes: 2 additions & 1 deletion cljs/src/test/plastic/suites/all_tests.cljs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
(ns plastic.suites.all-tests
[:require [plastic.test.sample]])
[:require [plastic.test.sample]
[plastic.suites.meld-tests]])
2 changes: 2 additions & 0 deletions cljs/src/test/plastic/suites/meld_tests.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(ns plastic.suites.meld-tests
[:require [meld.core-tests]])
2 changes: 1 addition & 1 deletion cljs/src/test/plastic/test/sample.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
(testing "testing level 1"
(testing "testing level 2"
(testing "testing level 3"
(is (= 1 1))))))
(is (= 1 3))))))
52 changes: 0 additions & 52 deletions karma.dev.conf.js

This file was deleted.

50 changes: 50 additions & 0 deletions script/auto-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
set -e

# http://stackoverflow.com/a/32566506/84283
kill_childs() {
local pid="${1}"
local self="${2:-false}"

if children="$(pgrep -P "$pid")"; then
for child in $children; do
kill_childs "$child" true
done
fi

if [ "$self" == true ]; then
kill -s SIGTERM "$pid" || (sleep 10 && kill -9 "$pid" &)
fi
}

# http://superuser.com/a/917073/8244
wait_file() {
local file="$1"; shift
local wait_seconds="${1:-10}"; shift # 10 seconds as default timeout

until test $((wait_seconds--)) -eq 0 -o -f "$file" ; do sleep 1; done

((++wait_seconds))
}

echo "THIS SCRIPT DOES NOT WORK RELIABLY"
echo "karmas's web server does not wait for cljs compiler to finish writing of files, corrupts its own cache and starts serving corrupted files."


trap 'echo "killing child processes: $(jobs -p)..." && kill_childs $(jobs -p)' EXIT

# ensure we start in cljs project root
cd "$(dirname "${BASH_SOURCE[0]}")"; cd ../cljs

lein clean
lein cljsbuild auto test &

compiler_output="resources/test/.build/test/plastic.js"

wait_file $compiler_output 120 || {
echo "compiler output file missing after waiting for $? seconds: '$$compiler_output'"
echo "check for errors/misconfiguration of: lein cljsbuild auto test"
exit 1
}

../node_modules/karma/bin/karma start ../karma/dev.conf.js

0 comments on commit 8e7ccec

Please sign in to comment.