Skip to content

Commit

Permalink
CLJS-3262: Add self-parity tests to GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mfikes committed Jul 4, 2020
1 parent a19f8e0 commit 6691bae
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 4 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,43 @@ jobs:
- name: Run tests
run: node builds/out-self/core-self-test.js

# Self-parity Tests
self-parity-test:
name: Self-parity Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: DeLaGuardo/[email protected]
with:
tools-deps: '1.10.1.536'

- name: Cache maven
uses: actions/cache@v2
env:
cache-name: cache-maven
with:
path: ~/.m2
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/deps.edn') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
- name: Cache gitlibs
uses: actions/cache@v2
env:
cache-name: cache-gitlibs
with:
path: ~/.gitlibs
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/deps.edn') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
- name: Build tests
run: clojure -A:selfparity.test.build

- name: Run tests
run: node builds/out-self-parity/main.js

# Compiler Tests
compiler-test:
name: Compiler Tests
Expand Down
6 changes: 5 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@
:runtime.test.build {:extra-paths ["src/test/cljs"]
:main-opts ["-m" "cljs.main" "-co" "resources/test.edn" "-c"]}
:selfhost.test.build {:extra-paths ["src/test/self"]
:main-opts ["-m" "cljs.main" "-co" "resources/self_host_test.edn" "-c"]}}}
:main-opts ["-m" "cljs.main" "-co" "resources/self_host_test.edn" "-c"]}
:selfparity.test.build {:extra-paths ["src/test/self"]
:main-opts ["-i" "src/test/self/self_parity/setup.clj"
"-e" "(self-parity.setup/-main)"
"-m" "cljs.main" "-co" "resources/self_parity_test.edn" "-c"]}}}
6 changes: 6 additions & 0 deletions resources/self_parity_test.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{:optimizations :none
:main self-parity.test
:output-to "builds/out-self-parity/main.js"
:output-dir "builds/out-self-parity"
:cache-analysis-format :edn
:target :nodejs}
3 changes: 1 addition & 2 deletions src/test/self/self_parity/auxiliary.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.

(ns ^{:doc "This auxiliary namespace is not actually loaded.
Its mere presence cause it to be compiled and thus causes
(ns ^{:doc "This auxiliary namespace only exists to cause
the libs listed here to be dumped into the compiler output
directory where they can be loaded on demand when running
the compiler tests in bootstrap mode."}
Expand Down
47 changes: 47 additions & 0 deletions src/test/self/self_parity/setup.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
;; Copyright (c) Rich Hickey. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.

(ns self-parity.setup
^{:doc "Sets up the filesystem, priming the output directory
with needed source files so that the self-hosted compiler
being executed within Node has various dependency sources
available (without the benefit of being able to load resources
from a classpath)."}
(:require
[clojure.java.io :as io]))

(def out-path (io/file "builds" "out-self-parity"))

(defn copy-source
[source-resource-name]
(let [target-file (io/file out-path source-resource-name)]
(io/make-parents target-file)
(io/copy (io/input-stream (io/resource source-resource-name)) target-file)))

(def test-check-source-resource-names
["clojure/test/check.cljc"
"clojure/test/check/random.clj"
"clojure/test/check/random.cljs"
"clojure/test/check/rose_tree.cljc"
"clojure/test/check/clojure_test.cljc"
"clojure/test/check/clojure_test/assertions.cljc"
"clojure/test/check/clojure_test/assertions/cljs.cljc"
"clojure/test/check/results.cljc"
"clojure/test/check/impl.cljc"
"clojure/test/check/properties.cljc"
"clojure/test/check/random/longs.cljs"
"clojure/test/check/random/doubles.cljs"
"clojure/test/check/random/longs/bit_count_impl.cljs"
"clojure/test/check/generators.cljc"])

(def source-resource-names
(into ["clojure/template.clj"]
test-check-source-resource-names))

(defn -main []
(run! copy-source source-resource-names))
3 changes: 2 additions & 1 deletion src/test/self/self_parity/test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
[cljs.js :as cljs]
[cljs.tools.reader :as reader]
[cljs.stacktrace :as st]
[goog.object :as gobj]))
[goog.object :as gobj]
[self-parity.auxiliary]))

(def out-dir "builds/out-self-parity")

Expand Down

0 comments on commit 6691bae

Please sign in to comment.