Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor modernizations: CI, Clojure version, test organization #182

Merged
merged 5 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Tests

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build-clj:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: "Setup Java 17"
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Clojure
uses: DeLaGuardo/[email protected]
with:
lein: 2.10.0
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: "m2-${{ hashFiles('project.clj') }}"
- name: Run tests
run: lein test
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:description "lightweight literate programming for clojure -- inspired by [docco](http://jashkenas.github.com/docco/)"
;; :main marginalia.main
:dependencies
[[org.clojure/clojure "1.7.0"]
[[org.clojure/clojure "1.11.1"]
[org.clojure/clojurescript "1.7.228"]
[org.clojure/tools.namespace "0.2.10"]
[org.clojure/tools.cli "0.3.3"]
Expand Down
7 changes: 7 additions & 0 deletions test/marginalia/core_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(ns marginalia.core-test
(:require
[clojure.test :refer :all]
[marginalia.core :as core]))

(deftest parse-project-file-simple
(is (= "project-name" (:name (marginalia.core/parse-project-file "test/marginalia/resources/multi-def-project.clj.txt")))))
14 changes: 14 additions & 0 deletions test/marginalia/multidoc_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(ns marginalia.multidoc-test
(:require
[clojure.test :refer :all]
[marginalia.core :as core]
[marginalia.test.helpers :refer :all]))

(deftest multi-page-test
(with-project "multi_page"
(fn [source-dir output-dir metadata]
(core/multidoc! output-dir
(find-clojure-file-paths source-dir)
metadata))

(is (= 3 number-of-generated-pages))))
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(ns marginalia.test.parse
(ns marginalia.parse-test
"This module does stuff"
(:use clojure.test)
(:require [marginalia.parser :as p]))
(:require
[clojure.test :refer :all]
[marginalia.parser :as p]))

(deftest test-inline-literals
(is (= (count (marginalia.parser/parse "(ns test)")) 1))
Expand Down
6 changes: 0 additions & 6 deletions test/marginalia/test/core.clj

This file was deleted.

12 changes: 7 additions & 5 deletions test/marginalia/test/helpers.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
(ns marginalia.test.helpers
(:use clojure.test)
(:use [clojure.java.io :only (file delete-file)])
(:require marginalia.core))
(:require
[clojure.java.io :refer [file delete-file]]
[clojure.test :refer :all]
[marginalia.core :as core]
[marginalia.html :as html]))


;; copied from http://clojuredocs.org/clojure_contrib/clojure.contrib.io/delete-file-recursively
Expand All @@ -17,7 +19,7 @@
(delete-file f silently)))

(defn find-clojure-file-paths [source-dir]
(marginalia.core/find-processable-file-paths source-dir #(re-find #"\.clj$" %)))
(core/find-processable-file-paths source-dir #(re-find #"clj$" %)))

(defn files-in [dir]
(seq (.listFiles (file dir))))
Expand Down Expand Up @@ -50,7 +52,7 @@
`(do
(delete-file-recursively ~test-project-target true)
(.mkdirs (file ~test-project-target))
(binding [marginalia.html/*resources* ""]
(binding [html/*resources* ""]
(~doc-generator ~test-project-src ~test-project-target ~test-metadata))
(let [~'number-of-generated-pages (count (files-in ~test-project-target))]
;; We need to `deftest` in order for test runners (e.g. `lein test`) to pick up failures
Expand Down
12 changes: 0 additions & 12 deletions test/marginalia/test/multidoc.clj

This file was deleted.

12 changes: 0 additions & 12 deletions test/marginalia/test/uberdoc.clj

This file was deleted.

15 changes: 15 additions & 0 deletions test/marginalia/uberdoc_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(ns marginalia.uberdoc-test
(:require
[clojure.java.io :as io]
[clojure.test :refer :all]
[marginalia.core :as core]
[marginalia.test.helpers :refer :all]))

(deftest single-page-test
(with-project "single_page"
(fn [source-dir output-dir metadata]
(marginalia.core/uberdoc! (io/file output-dir "index.html")
(find-clojure-file-paths source-dir)
metadata))

(is (= 1 number-of-generated-pages))))
Loading