-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from brandoncorrea/master
Passes Speclj using Advanced ClojureScript Optimizations
- Loading branch information
Showing
33 changed files
with
758 additions
and
628 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,61 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="iso-8859-1" content="text/html" http-equiv="Content-Type"/> | ||
<title>Speclj Specs</title> | ||
<!--<script src="../js/es5-shim.js" type="text/javascript"></script>--> | ||
<script src="../target/cljs/goog/base.js" type="text/javascript"></script> | ||
<script src="../target/specs.js" type="text/javascript"></script> | ||
<script type="text/javascript"> | ||
String.prototype.endsWith = function (suffix) { | ||
return this.indexOf(suffix, this.length - suffix.length) !== -1; | ||
}; | ||
<meta charset="iso-8859-1" content="text/html" http-equiv="Content-Type"/> | ||
<title>Speclj Specs</title> | ||
<!--<script src="../js/es5-shim.js" type="text/javascript"></script>--> | ||
<script src="../target/cljs/goog/base.js" type="text/javascript"></script> | ||
<script src="../target/specs.js" type="text/javascript"></script> | ||
<script type="text/javascript"> | ||
String.prototype.endsWith = function (suffix) { | ||
return this.indexOf(suffix, this.length - suffix.length) !== -1 | ||
} | ||
|
||
// Load all the specs | ||
for(var k in goog.debugLoader_.dependencies_) { | ||
var dep = goog.debugLoader_.dependencies_[k]; | ||
for (var i = 0; i < dep.provides.length; i++) { | ||
var ns = dep.provides[i]; | ||
// console.log(ns); | ||
if (ns.endsWith("_spec")) { | ||
goog.require(ns) | ||
} | ||
} | ||
} | ||
// Load all the specs | ||
for (let k in goog.debugLoader_.dependencies_) { | ||
let dep = goog.debugLoader_.dependencies_[k] | ||
dep.provides | ||
.filter(ns => ns.endsWith("_spec")) | ||
.forEach(goog.require) | ||
} | ||
|
||
runSpecsConfigured = function (color, reporter) { | ||
speclj.run.standard.armed = true; | ||
return speclj.run.standard.run_specs( | ||
cljs.core.keyword("color"), color | ||
, cljs.core.keyword("reporters"), [reporter] | ||
); | ||
}; | ||
runSpecsConfigured = function (color, reporter) { | ||
speclj.run.standard.arm() | ||
return speclj.run.standard.run_specs( | ||
"color", color, | ||
"reporters", [reporter] | ||
) | ||
} | ||
|
||
runSpecs = function () { | ||
return runSpecsConfigured(false, "documentation"); | ||
} | ||
runSpecs = function () { | ||
return runSpecsConfigured(false, "documentation") | ||
} | ||
|
||
runSpecsFiltered = function (affectedSpecs) { | ||
if(affectedSpecs != null) { | ||
console.log("Only running affected specs:"); | ||
var descriptionAtom = speclj.config.active_runner().descriptions; | ||
cljs.core.swap_BANG_(descriptionAtom, function (descriptions) { | ||
return cljs.core.filter(function (description) { | ||
return description.ns in affectedSpecs; | ||
}, descriptions); | ||
}); | ||
cljs.core.doall(cljs.core.map(function (description) { | ||
console.log(" ", description.ns); | ||
}, cljs.core.deref(descriptionAtom))); | ||
} | ||
return runSpecsConfigured(true, "documentation"); | ||
} | ||
</script> | ||
runSpecsFiltered = function (affectedSpecs) { | ||
if (affectedSpecs != null) { | ||
console.log("Only running affected specs:") | ||
var runner = speclj.config.active_runner() | ||
speclj.running.filter_descriptions(runner, affectedSpecs) | ||
speclj.running.get_descriptions(runner) | ||
.forEach((description) => | ||
console.log(" ", description.ns)) | ||
} | ||
return runSpecsConfigured(true, "documentation") | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<h3 style="margin: 1em">Speclj CLJS Specs</h3> | ||
|
||
<p style="margin: 1em; width: 400px;"> | ||
Typically these specs are run using a headless browser driven by a script. | ||
But you can run them here if you like. | ||
That is, assuming all the cljs has been compiled in development. | ||
<br/> | ||
Open up the browser console: | ||
Typically these specs are run using a headless browser driven by a script. | ||
But you can run them here if you like. | ||
That is, assuming all the cljs has been compiled in development. | ||
<br/> | ||
Open up the browser console: | ||
</p> | ||
<pre style="margin: 1em; padding: 1em; width: 400px; border: 1px dotted slategray; background-color: lightgray;"> | ||
runSpecs() | ||
</pre> | ||
</body> | ||
</html> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,70 @@ | ||
(ns speclj.config-spec | ||
(#?(:cljs :require-macros :clj :require) | ||
[speclj.core :refer [describe it should-not= should= should-throw should-not-contain should-be-same]]) | ||
(:require [speclj.config :refer [load-runner load-reporter default-config | ||
parse-tags config-mappings *tag-filter* config-bindings]] | ||
(:require [speclj.core #?(:clj :refer :cljs :refer-macros) [describe context it should-not= should= should-throw should-not-contain should-not-be-nil should-be-same]] | ||
[speclj.spec-helper #?(:clj :refer :cljs :refer-macros) [test-exported-meta]] | ||
[speclj.config :as sut] | ||
[speclj.platform :as platform] | ||
[speclj.report.progress] | ||
[speclj.report.silent] | ||
[speclj.run.standard :refer [run-specs]])) | ||
|
||
[speclj.run.standard :as standard])) | ||
|
||
(describe "Config" | ||
(it "dynamically loads StandardRunner" | ||
(let [runner (load-runner "standard")] | ||
(let [runner (sut/load-runner "standard")] | ||
(should-not= nil runner) | ||
(should= speclj.run.standard.StandardRunner (type runner)))) | ||
|
||
#?(:clj | ||
(it "dynamically loads VigilantRunner" | ||
(let [runner (load-runner "vigilant")] | ||
(let [runner (sut/load-runner "vigilant")] | ||
(should-not= nil runner) | ||
(should= "speclj.run.vigilant.VigilantRunner" (.getName (type runner)))))) | ||
|
||
(it "throws exception with unrecognized runner" | ||
(should-throw platform/exception "Failed to load runner: blah" (load-runner "blah"))) | ||
(should-throw platform/exception "Failed to load runner: blah" (sut/load-runner "blah"))) | ||
|
||
(it "dynamically loads ProgressReporter" | ||
(let [reporter (load-reporter "progress")] | ||
(let [reporter (sut/load-reporter "progress")] | ||
(should-not= nil reporter) | ||
(should= speclj.report.progress.ProgressReporter (type reporter)))) | ||
|
||
(it "dynamically loads SilentReporter" | ||
(let [reporter (load-reporter "silent")] | ||
(should-not= nil reporter) | ||
(let [reporter (sut/load-reporter "silent")] | ||
(should-not-be-nil reporter) | ||
(should= speclj.report.silent.SilentReporter (type reporter)))) | ||
|
||
(it "throws exception with unrecognized reporter" | ||
(should-throw platform/exception "Failed to load reporter: blah" (load-reporter "blah"))) | ||
(should-throw platform/exception "Failed to load reporter: blah" (sut/load-reporter "blah"))) | ||
|
||
(it "can be given a pre-fabricated reporter" | ||
(let [pre-fabricated-reporter (speclj.report.silent/new-silent-reporter) | ||
reporter (load-reporter pre-fabricated-reporter)] | ||
reporter (sut/load-reporter pre-fabricated-reporter)] | ||
(should-not= nil reporter) | ||
(should-be-same reporter pre-fabricated-reporter))) | ||
|
||
(it "converts tag input to includes/excludes" | ||
(should= {:includes #{} :excludes #{}} (parse-tags [])) | ||
(should= {:includes #{:one} :excludes #{}} (parse-tags [:one])) | ||
(should= {:includes #{:one} :excludes #{}} (parse-tags ["one"])) | ||
(should= {:includes #{:one :two} :excludes #{}} (parse-tags ["one" 'two])) | ||
(should= {:includes #{} :excludes #{:one}} (parse-tags ["~one"])) | ||
(should= {:includes #{} :excludes #{:one :two}} (parse-tags ["~one" "~two"])) | ||
(should= {:includes #{:two} :excludes #{:one}} (parse-tags ["~one" "two"]))) | ||
(should= {:includes #{} :excludes #{}} (sut/parse-tags [])) | ||
(should= {:includes #{:one} :excludes #{}} (sut/parse-tags [:one])) | ||
(should= {:includes #{:one} :excludes #{}} (sut/parse-tags ["one"])) | ||
(should= {:includes #{:one :two} :excludes #{}} (sut/parse-tags ["one" 'two])) | ||
(should= {:includes #{} :excludes #{:one}} (sut/parse-tags ["~one"])) | ||
(should= {:includes #{} :excludes #{:one :two}} (sut/parse-tags ["~one" "~two"])) | ||
(should= {:includes #{:two} :excludes #{:one}} (sut/parse-tags ["~one" "two"]))) | ||
|
||
#?(:clj | ||
(it "should translate tags in config-bindings" | ||
(let [mappings (config-mappings (assoc default-config :tags ["one" "~two"]))] | ||
(let [mappings (sut/config-mappings (assoc sut/default-config :tags ["one" "~two"]))] | ||
(should= | ||
{:includes #{:one} :excludes #{:two}} | ||
(get mappings #'*tag-filter*))))) | ||
(get mappings #'sut/*tag-filter*))))) | ||
#?(:clj | ||
(it "doesn't include *parent-description* in config-bindings" | ||
(let [cb (config-bindings)] | ||
(let [cb (sut/config-bindings)] | ||
(should-not-contain #'speclj.config/*parent-description* cb)))) | ||
|
||
(context "exporting" | ||
(test-exported-meta sut/active-runner) | ||
(test-exported-meta speclj.report.silent/new-silent-reporter) | ||
) | ||
) | ||
|
||
(run-specs) | ||
|
||
|
||
(standard/run-specs) |
Oops, something went wrong.