metabase/hawk — 61★ trên GitHub (Clojure). It watches your code like a hawk! You like tests, right? Then run them with our state-of-the-art Clojure test runner.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
It watches your code like a hawk! You like tests, right? Then run them with our state-of-the-art Clojure test runner.
;;; this is not necessarily up to date; use the latest SHA in GitHub
{io.github.metabase/hawk {:sha "8813c2b0969e9f78025c267af0488c96792b35d1"}}
Hawk is a Clojure-CLI friendly wrapper around Eftest with some extra features
and opinionated behavior. It started out as the Metabase test runner, but we
spun it out so we can use it in other places too.
You can run tests against a single namespace or directory, or one test specifically, by passing :only [argument]:
Arguments to clojure -X are read in as EDN; for things other than plain symbols or numbers you usually need to wrap
them in single quotes in your shell. Our test runner uses this argument to determine where to look for tests. Here's
how different EDN forms are interpreted as our test runner:
Arg type
Example
Description
Unqualified Symbol
my.namespace-test
Run all tests in this namespace
Qualified Symbol
my.namespace-test/my-test
Run one specific test
String (directory)
'"test/metabase/api"'
Run all tests in test namespaces in this directory (including subdirectories)
String (file)
'"test/metabase/api/user_test.clj"'
Run all tests in this specific test file
Vector of symbols/strings
'[my.namespace "test/metabase/some_directory"]'
Union of tests found by the individual items in the vector
Example commands:
Description
Example
Run tests in a specific namespace
clojure -X:test :only my.namespace-test
Run a specific test
clojure -X:test :only my.namespace-test/my-test
Run tests in a specific directory (including subdirectories)
Checking to make sure things don't happen during initialization
You can use mb.hawk.init/assert-tests-are-not-initializing to make sure things that shouldn't be happening as a
side-effect of loading namespaces, such as initializing a database, are not happening where they shouldn't be.
(ns my.namespace
(:require
[mb.hawk.init]))
(defn initialize-database! []
(mb.hawk.init/assert-tests-are-not-initializing "Don't initialize the database in a top-level form!")
...)
Fancy JUnit Output
Hawk automatically generates JUnit output using bespoke JUnit output code that prints diffs using
humane-test-output. JUnit output is automatically output to
target/junit, and only in :cli/ci mode. Not currently configurable! Submit a PR if you want to output it somewhere
else.
Parallel Tests
Unlike Eftest, parallelization in Hawk tests is opt-in. This is mostly a byproduct of it beginning life as the
Metabase test runner. All tests are ran synchronously unless they are given ^:parallel metadata (either the test
itself, or the namespace). A test in a parallel namespace can explicitly opt out with ^:synchronized:
Test metadata takes precedence over namespace metadata, so ^:synchronized is equivalent to ^{:parallel false} on
either a test or namespace. Conversely, an individual ^:parallel test can opt in from a synchronized namespace.
Hawk includes mb.hawk.parallel/assert-test-is-not-parallel, which you can use to make sure things that shouldn't be ran
in parallel tests are not:
re=: checks whether a string is equal to a regular expression
partial=: like = but only compares stuff (using clojure.data/diff) that's in expected. Anything else is ignored.
=?: see Approximately Equal
Test modes:
The Hawk test runner can run in one of three modes.
Mode
Test Suite Failure Behavior
Show Progress Bar?
:repl
Print summary
No
:cli/local
call (System/exit -1)
Yes
:cli/ci
call (System/exit -1)
No
The mode is determined as follows:
If an explicit :mode is passed to the options map (e.g. :exec-args or CLI args passed to clojure -X), it is
used;
Otherwise, if the env var HAWK_MODE or Java system property hawk.mode is specified, it is used;
Otherwise, if the env var CI or system property ci is set, :cli/ci will be used;
If you use mb.hawk.core/find-and-run-tests-cli as your :exec-fn, :cli/local will be used;
If you run tests from the REPL with mb.hawk.core/find-and-run-tests-repl, :repl will be used.
Matching Namespace Patterns
Tell the test runner to only run tests against certain namespaces with :namespace-pattern:
;; only run tests against namespaces that start with `my-project` and end with `test`
{:aliases
{:test
{:exec-fn mb.hawk.core/find-and-run-tests-cli
:exec-args {:namespace-pattern "^my-project.*test$"}}}}
Excluding directories
:exclude-directories passed in the options map will tell Hawk not to look for tests in those directories. This only
works for directories on your classpath, i.e. things included in :paths! If you need something more sophisticated,
please submit a PR.
This allows for exact matching on var names to prevent tests. A typical example might be a test that is failing due to a
leap year. A typical fix might be someone prepares a patch, gets it through CI, and then all jobs hoping to pass CI must
rebase on this change. An alternative is that some central store is updated with
{"ignored": {"vars": ["some.ns/date-test"]}}
And then all of CI can carry on while you fix this. Once fixed, remove this var from the central store and continue.
Only running tests against namespaces or vars with tags
The opposite of :exclude-tags -- you can only run tests against a certain set of tags with :only-tags. If multiple
:only-tags are specified, only namespaces or vars that have all of those tags will be run.
:only-tags can be combined with :only and/or :exclude-tags.
clj -X:test :only-tags [:my-project/e2e-test]
will only run tests in namespaces like
(ns ^:my-project/e2e-test my-namespace
...)
or ones individually marked :my-project/e2e-test like
(deftest ^:my-project/e2e-test my-test
...)
Whole-Suite Hooks
You can specify hooks to run before or after the entire test suite runs like so:
options are the same options passed to the test runner as a whole, i.e. a combination of those specified in your
deps.edn aliases as well as additional command-line options.
The dispatch value is not particularly important -- one hook will run for each dispatch value -- but you should probably
make it a namespaced keyword to avoid conflicts, and give it a docstring so people know why it's there. The order the
hooks are run in is indeterminate. The docstrings for before-run and after-run are updated automatically as new
hooks are added; you can check it to see which hooks are in use. Note that hooks will not be ran unless the namespace
they live in is loaded; this may be affected by :only options passed to the test runner.
Return values of methods are ignored; they are done purely for side effects.
Partitioning tests
You can divide a test suite into multiple partitions using the :partition/total and :partition/index keys. This is
an easy way to speed up CI by diving large test suites into multiple jobs.
clj -X:test '{:partition/total 10, :partition/index 8}'
...
Running tests in partition 9 of 10 (575 tests of 5753)...
Finding tests took 46.6 s.
Running 575 tests
...
:partition/index is zero-based, e.g. if you have ten partitions (:partiton/total 10) then the first partition is 0
and the last is 9.
Tests are partitioned at the var (deftest) level after all tests are found the usual way, but all tests in any given
namespace will always be split into the same partition. All namespaces that would be loaded if you were running the
entire test suite are still loaded. Partitions are split as evenly as possible, but tests are guaranteed to be split
deterministically into exactly the number of partitions you asked for.
Additional options
All other options are passed directly to Eftest; refer to its documentation
for more information.
metabase/hawk có 61 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/metabase/hawk. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
metabase/hawk có những chủ đề gì?
GitHub topics của metabase/hawk: "ci", "clojure", "test", "test-runner", "testing", "tests", "unit-testing". TopGit xếp repo vào nhóm Automation.
metabase/hawk còn đang phát triển không?
Commit gần nhất trên metabase/hawk là 10 ngày trước (theo timestamp GitHub). Repo có 1 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
metabase/hawk là gì?
metabase/hawk (metabase/hawk) là dự án Clojure trên GitHub. Theo mô tả gốc: It watches your code like a hawk! You like tests, right? Then run them with our state-of-the-art Clojure test runner.
metabase/hawk so với các dự án Automation khác thế nào?
metabase/hawk được TopGit xếp vào nhóm Automation, với 61 sao GitHub và viết bằng Clojure. Xem trang chủ đề Automation trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
metabase/hawk viết bằng ngôn ngữ gì?
metabase/hawk chủ yếu viết bằng Clojure. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Vì sao metabase/hawk được xếp vào nhóm Automation?
TopGit xếp metabase/hawk vào nhóm Automation dựa trên GitHub topics và mô tả của repo (gắn thẻ: "ci", "clojure", "test"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về hawk?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về hawk.