Permalink
Browse files

Dojo works properly in both run and test.

  • Loading branch information...
1 parent e063af1 commit 87f16f1da12880416f2cc1b9e44ebc68d655c77e @sritchie sritchie committed Nov 27, 2011
Showing with 12 additions and 16 deletions.
  1. +0 −4 src/koan_engine/checker.clj
  2. +6 −5 src/koan_engine/freshness.clj
  3. +5 −6 src/koan_engine/koans.clj
  4. +1 −1 src/koans/tuples.clj
@@ -48,10 +48,6 @@
pairs)]
`(do ~@tests)))
-;; This needs to occur in the project-koan-specific namespace, else
-;; load-string won't have the proper requirements.
-;;
-;; In the actual koan we prefix form with some use and requires.
(defn ensure-failing-without-answers [dojo-path]
(if (every?
(fn [koan]
@@ -4,7 +4,6 @@
[koan-engine.koans :only [among-paths?
namaste
next-koan-path
- ordered-koans
ordered-koan-paths
tests-pass?]])
(:import [java.util.concurrent ScheduledThreadPoolExecutor TimeUnit]))
@@ -13,21 +12,23 @@
(constantly
(clj-files-in (file koan-root))))
-(defn report-refresh [report]
+(defn report-refresh [dojo-path report]
(when-let [refreshed-files (seq (:reloaded report))]
(let [these-koans (filter
(among-paths? refreshed-files)
(ordered-koan-paths))]
- (when (every? tests-pass? these-koans)
+ (when (every? (partial tests-pass? dojo-path)
+ these-koans)
(if-let [next-koan-file (file (next-koan-path (last these-koans)))]
(report-refresh {:reloaded [next-koan-file]})
(namaste))))
(println))
:refreshed)
-(defn refresh! [{:keys [koan-root]}]
+(defn refresh!
+ [{:keys [koan-root dojo-resource]}]
(freshener (files-to-keep-fresh koan-root)
- report-refresh))
+ (partial report-refresh dojo-resource)))
(def scheduler (ScheduledThreadPoolExecutor. 1))
View
@@ -2,12 +2,11 @@
(:use [clojure.java.io :only [file resource]])
(:require [koan-engine.util :as u]))
-;; Add more koan namespaces here.
+;; TODO: Proper koan validation. Accept the path as an argument.
(defn ordered-koans []
- (if-let [conf-path (resource "job-conf.clj")]
+ (if-let [conf-path (resource "koans.clj")]
(try (let [conf (-> conf-path slurp read-string)]
- (u/safe-assert (map? conf)
- "job-conf.clj must produce a map of config parameters!")
+ (u/safe-assert (map? conf) "Koans aren't valid!")
conf)
(catch RuntimeException e
(throw (Exception. "Error reading job-conf.clj!\n\n") e)))
@@ -31,8 +30,8 @@
(first more)
(recur more)))))
-(defn tests-pass? [file-path]
- (u/with-dojo ["dojo.clj"]
+(defn tests-pass? [dojo-path file-path]
+ (u/with-dojo [dojo-path]
(try (load-file file-path)
true
(catch Exception e
View
@@ -3,7 +3,7 @@
(meditations
"We shall contemplate truth by testing reality, via equality."
(= __ [["truth."]])
-
+
"Queries produce results..."
(?= __ (<- [?x]
(one-tuple ?x)))

0 comments on commit 87f16f1

Please sign in to comment.