Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
b4e08f9b
Unverified
Commit
b4e08f9b
authored
1 year ago
by
Chris Truter
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Scope find-root-test-failure! to same ns by default (#38600)
parent
e578f47b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dev/src/dev.clj
+13
-6
13 additions, 6 deletions
dev/src/dev.clj
with
13 additions
and
6 deletions
dev/src/dev.clj
+
13
−
6
View file @
b4e08f9b
...
...
@@ -329,6 +329,10 @@
[
form
]
(
hashp/p*
form
))
(
defn-
tests-in-var-ns
[
test-var
]
(
->>
test-var
meta
:ns
ns-interns
vals
(
filter
(
comp
:test
meta
))))
(
defn
find-root-test-failure!
"Sometimes tests fail due to another test not cleaning up after itself properly (e.g. leaving permissions in a dirty
state). This is a common cause of tests failing in CI, or when run via `find-and-run-tests`, but not when run alone.
...
...
@@ -339,13 +343,16 @@
When the passed test starts failing, it throws an exception notifying you of the test that caused it to start
failing. At that point, you can start investigating what pleasant surprises that test is leaving behind in the
database."
[
failing-test-var
]
[
failing-test-var
&
{
:keys
[
scope
]
:or
{
scope
:same-ns
}}
]
(
let
[
failed?
(
fn
[]
(
not=
[
0
0
]
((
juxt
:fail
:error
)
(
clojure.test/run-test-var
failing-test-var
))))]
(
when
(
failed?
)
(
throw
(
ex-info
"Test is already failing! Better go fix it."
{
:failed-test
failing-test-var
})))
(
doseq
[
test
(
metabase.test-runner/find-tests
)]
(
clojure.test/run-test-var
test
)
(
when
(
failed?
)
(
throw
(
ex-info
(
format
"Test failed after running: `%s`"
test
)
{
:test
test
}))))))
(
let
[
tests
(
case
scope
:same-ns
(
tests-in-var-ns
failing-test-var
)
:full-suite
(
metabase.test-runner/find-tests
))]
(
doseq
[
test
tests
]
(
clojure.test/run-test-var
test
)
(
when
(
failed?
)
(
throw
(
ex-info
(
format
"Test failed after running: `%s`"
test
)
{
:test
test
})))))))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment