<commit_before>(ns clj-record.test.main
  (:require [clojure.contrib.sql :as sql]
            [clojure.contrib.test-is :as test-is]
            clj-record.config))


(defn drop-tables []
  (try
    (sql/drop-table :manufacturers)
    (sql/drop-table :products)
    (catch Exception e)))

(defn create-tables []
  (sql/create-table :manufacturers
    [:id "INT" "GENERATED ALWAYS AS IDENTITY CONSTRAINT manufacturer_pk PRIMARY KEY"]
    [:name "VARCHAR(32)" "NOT NULL"]
    [:founded "VARCHAR(4)"]
    [:grade :real])
  (sql/create-table :products
    [:id "INT" "GENERATED ALWAYS AS IDENTITY CONSTRAINT product_pk PRIMARY KEY"]
    [:name "VARCHAR(32)" "NOT NULL"]
    [:price "INT"]
    [:manufacturer_id "INT" "NOT NULL"]))

(sql/with-connection clj-record.config/db
  (sql/transaction
    (drop-tables)
    (create-tables)))

(println "Setup complete.")

(def files ["util-test" "core-test" "validation-test" "associations-test"])

(doseq [file files]
  (load file))

(def base-ns (re-find #"^\w*.*\." (str *ns*)))

(apply test-is/run-tests (map #(symbol (str base-ns %)) files))<commit_msg>Eliminate unneeded defs from loading and running tests.<commit_after>(ns clj-record.test.main
  (:require [clojure.contrib.sql :as sql]
            [clojure.contrib.test-is :as test-is]
            clj-record.config))


(defn drop-tables []
  (try
    (sql/drop-table :manufacturers)
    (sql/drop-table :products)
    (catch Exception e)))

(defn create-tables []
  (sql/create-table :manufacturers
    [:id "INT" "GENERATED ALWAYS AS IDENTITY CONSTRAINT manufacturer_pk PRIMARY KEY"]
    [:name "VARCHAR(32)" "NOT NULL"]
    [:founded "VARCHAR(4)"]
    [:grade :real])
  (sql/create-table :products
    [:id "INT" "GENERATED ALWAYS AS IDENTITY CONSTRAINT product_pk PRIMARY KEY"]
    [:name "VARCHAR(32)" "NOT NULL"]
    [:price "INT"]
    [:manufacturer_id "INT" "NOT NULL"]))

(sql/with-connection clj-record.config/db
  (sql/transaction
    (drop-tables)
    (create-tables)))

(println "Setup complete.")

(let [test-files ["util-test" "core-test" "validation-test" "associations-test"]
      base-ns (re-find #"^\w*.*\." (str *ns*))]
  (doseq [file test-files]
    (load file))
  (apply test-is/run-tests (map #(symbol (str base-ns %)) test-files)))
{'fraction_non_alphanumeric': 0.17155555555555554, 'fraction_numerical': 0.0044444444444444444, 'mean_word_length': 3.5200803212851404, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1426286', 'n_tokens_mistral': 839, 'n_tokens_neox': 789, 'n_words': 197}