
Research
/Security News
Malicious npm Packages Target WhatsApp Developers with Remote Kill Switch
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
github.com/cognitect-labs/test-runner
test-runner
is a small library for discovering and running tests in
projects using native Clojure deps (i.e, those that use only Clojure's
built-in dependency tooling, not Leiningen/boot/etc.)
Clojure's 1.9 release included standalone tools for dependency
resolution, classpath construction, and launching processes. Clojure
also ships with a straightforward testing library, clojure.test
.
Using these tools, however, there was no standard way to discover and run unit tests. Including a heavyweight project tool such as Leiningen or Boot just for the purpose of testing is overkill. Projects can build their own ad-hoc test runners, but these tend to lack features that will eventually be desired, and tend towards the "quick and dirty," besides being nonstandard from project to project.
This library aims to fill in the gap and provide a standardized, easy-to-use entry point for discovering and running unit and property-based tests while remaining a lightweight entry in Clojure's suite of decomplected project management tools.
Include a dependency on this project in your deps.edn
. You will
probably wish to put it in the test
alias:
;; v0.4.0
:aliases {:test {:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner
{:git/url "https://github.com/cognitect-labs/test-runner.git"
:sha "8c3f22363d63715de4087b038d79ae0de36a3263"}}
:main-opts ["-m" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test}}
clojure -X
(exec style)Invoking the test-runner with clojure -X
will call the test function with a map of arguments,
which can be supplied either in the alias (via :exec-args
) or on the command-line, or both.
Create the alias with :exec-fn
to simplify the call:
:aliases {:test {:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner
{:git/url "https://github.com/cognitect-labs/test-runner.git"
:sha "8c3f22363d63715de4087b038d79ae0de36a3263"}}
:exec-fn cognitect.test-runner.api/test}}
Invoke it with:
clj -X:test ...args...
This will scan your project's test
directory for any tests defined
using clojure.test
and run them.
You may also supply any of the additional command line options:
:dirs - coll of directories containing tests, default= ["test"]
:nses - coll of namespace symbols to test
:patterns - coll of regex strings to match namespaces
:vars - coll of fully qualified symbols to run tests on
:includes - coll of test metadata keywords to include
:excludes - coll of test metadata keywords to exclude"
If neither :dirs or :nses is supplied, will use:
:patterns [".*-test$"]
clojure -M
(clojure.main)To use the older clojure.main command line style:
clj -M:test ...args...
Use any of the additional command line options:
-d, --dir DIRNAME Name of the directory containing tests. Defaults to "test".
-n, --namespace SYMBOL Symbol indicating a specific namespace to test.
-r, --namespace-regex REGEX Regex for namespaces to test. Defaults to #".*-test$"
(i.e, only namespaces ending in '-test' are evaluated)
-v, --var SYMBOL Symbol indicating the fully qualified name of a specific test.
-i, --include KEYWORD Run only tests that have this metadata keyword.
-e, --exclude KEYWORD Exclude tests with this metadata keyword.
-H, --test-help Display this help message
There are three main steps to test execution:
You can use inclusions and exclusions to run only a subset of your tests, identified by metadata on the test var.
For example, you could tag your integration tests like so:
(deftest ^:integration test-live-system
(is (= 200 (:status (http/get "http://example.com")))))
Then to run only integration tests, you could do one of:
clj -X:test :includes '[:integration]'
clj -M:test -i :integration
Or to run all tests except for integration tests, one of:
clj -X:test :excludes '[:integration]'
clj -M:test -e :integration
If both inclusions and exclusions are present, exclusions take priority over inclusions.
Copyright © 2018-2021 Cognitect
Licensed under the Eclipse Public License, Version 2.0
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.