   (with-test-out
     (println ">>"(-> m :var meta :name))))
 
-(defmacro defregressiontest* [name permutated? file stats-var & body]
+(defmacro defregressiontest* [name permutated? file results-var & body]
   `(deftest ~name
      (with-bindings
        {#'dc/*persistence-schema-prefix* :featured_regression

        projectors (conj (config/projectors persistence) (config/timeline persistence))
        processor (processor/create {} "regression-set" persistence projectors)]
    (processor/replay processor 1000 nil)
    (:statistics (processor/shutdown processor))))

(defn clean-db []
  (j/execute! test-db ["DROP SCHEMA IF EXISTS \"featured_regression_regression-set\" CASCADE"])

        [meta features] (json-reader/features-from-stream stream)]
    [meta features]))

(defn- inserted-features [extracts dataset collection extract-type features]
  (doseq [f features]
    (let [max-row-id (if (empty? @extracts)
                       0
                       (reduce max (map first @extracts)))]
          (swap! extracts assoc (inc max-row-id) f))))


(defn- filter-collection [item-to-filter collection] 
  (some #(= % item-to-filter) collection))

(defn- deleted-versions [extracts dataset collection extract-type versions-to-delete]
  (let [rows-to-delete (map first (filter #(filter-collection (:_version (second %)) versions-to-delete) @extracts))]
    (doseq [row-id rows-to-delete]
      (swap! extracts dissoc row-id))))

;(defn- deleted-versions [extracts dataset collection extract-type versions-to-delete]
;  (println "do nothing"))


(defn process-feature-permutation [meta feature-permutation]
  (println "  " (map #(into [] (map :action %1)) feature-permutation))
  (let [extracts (atom {})]
    (with-bindings
      {#'e/*process-insert-extract* (partial inserted-features extracts)
       #'e/*process-delete-extract* (partial deleted-versions extracts)
       #'e/*initialized-collection?* (constantly true)}
      {:stats (apply merge-with (fn [a b] (if (seq? a) (conj a b) (+ a b)))
            (map (fn [features]
                (let [persistence (config/persistence)
                      projectors (conj (config/projectors persistence) (config/timeline persistence))
                      processor (processor/create meta "regression-set" persistence projectors)]
                  (dorun (processor/consume processor features))
                  (e/fill-extract "regression-set" nil)
                  (e/flush-changelog "regression-set")
                  (:statistics (processor/shutdown processor))))
              feature-permutation)) 
      :extracts extracts})))

(defn replay []
  (println "  Replaying")
