मुख्य सामग्री पर जाएँ
Skillpedia
टेस्टिंग9.1k · #12301

filtering

यह क्या करती है

यह स्किल Go में Ginkgo टेस्ट के सबसेट चलाने के कई तरीके समझाती है। यह उन डेवलपर्स के लिए है जो एक समूह चलाना, कुछ को छोड़ना या टेस्ट को तैयार न होने का निशान लगाना चाहते हैं।

कब इस्तेमाल करें

  • ✓जब आप बड़े Ginkgo टेस्ट सूट के एक हिस्से को ही चलाना चाहते हों।
  • ✓जब कोई टेस्ट अभी तैयार न हो और उसे फ़िलहाल छोड़ना हो।
  • ✓जब आप किसी खास label वाले टेस्ट चलाना चाहते हों, जैसे slow या integration।

Skill का लिंक

https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/filtering/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/filtering/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“केवल integration लेबल वाले Ginkgo टेस्ट चलाइए, और जो pending निशान वाले हैं उन्हें छोड़ दीजिए।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट compile-time pending निशान, runtime skips, focus, label filters और name filters में से चुनता है, फिर समझाता है कि वे कैसे जुड़ते हैं, क्योंकि कुछ विकल्प दूसरों को ओवरराइड कर देते हैं।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Filtering specs: running a subset

Ginkgo offers many ways to run fewer specs — ad-hoc (Pending/Skip/Focus) and structured (labels, semver, file/description filters). They combine by a strict precedence (see bottom). Decorator specifics live in ginkgo:decorators; label-driven CI in ginkgo:ci. Docs: https://onsi.github.io/ginkgo/#filtering-specs.

Pending — compile-time skip, uncoercible

Marks a spec/container as under development. Nothing can override Pending and make it run — not focus, not labels.

It("needs work", Pending, func() { ... })
It("placeholder", Pending)            // pending specs need no closure
PDescribe("not ready", func() { ... }) // == Describe(..., Pending); X-prefix is identical
PIt(...) / XIt(...) / PEntry(...)

Pending specs don't fail the suite. ginkgo --fail-on-pending makes them fail CI — a policy that pending specs shouldn't be committed. Pending is compile-time only; you cannot make a spec pending at runtime — for that, use Skip.

Skip — runtime skip

Call Skip("reason") from any subject or setup node to skip during the run phase. It panics to halt the spec (like Fail) and records the reason; it does not fail the suite (even skipping every spec passes).

It("if it can", func() {
	if !someCondition { Skip("special condition wasn't met") }
	...
})

Scope matters: in a BeforeEach it skips the current spec; in a BeforeAll it skips all specs in the Ordered container; in a BeforeSuite it skips the entire suite. You cannot call Skip in a container body — it only applies during the run phase.

Focus — programmatic, for iterating (don't commit it)

When any spec is focused, Ginkgo runs only focused specs.

FIt("just me", func() { ... })   // or It(..., Focus, ...)
FDescribe(...) / FContext(...) / FEntry(...)

Child focus unfocuses focused ancestors. F an inner It inside an FDescribe and only that It runs — matches how you narrow while debugging.

The danger: committing focus breaks CI quietly-loudly. A passing suite with programmatic focus exits non-zero (logs say it succeeded but flags focused specs) so CI catches it. Strip them all with ginkgo unfocus (removes F prefixes and Focus decorators).

Labels and --label-filter

Label("a", "b") (→ ginkgo:decorators) tags container/subject nodes; a spec's labels are the union down its hierarchy. No &|!,()/" chars in a label. Filter with ginkgo --label-filter=QUERY:

Operator Meaning
&& AND
`
! NOT
() grouping
/regexp/ regex match against labels

Bare words match label literals — case-insensitive, whitespace-trimmed.

ginkgo --label-filter="network && !slow"
ginkgo --label-filter="integration, smoke"   # comma == ||
ginkgo --label-filter=/library/              # regex

Consistent labelling is a best-practice for maintainable filtering.

Label sets — KEY:VALUE

A label KEY:VALUE adds VALUE to set KEY (multiple values accumulate, e.g. Label("API:Library", "API:Geo") → API = {Library, Geo}). Filter with KEY: OP <arg> where arg is a single value or {V1, V2}:

Op Matches when set KEY…
isEmpty has no KEY:* labels
containsAny contains any arg element
containsAll contains all arg elements
consistsOf equals exactly the args
isSubsetOf is a subset of args — note: an empty set always matches
ginkgo --label-filter="integration && !slow && Readiness: isSubsetOf {Beta, RC}"
ginkgo --label-filter="API: consistsOf {Library, Geo}"

Set values are literals (no regex). Prefer sets over regexes for structured filtering.

  • Suite-level labels: RunSpecs(t, "Books Suite", Label("books")) apply to the whole suite — filter out entire suites.
  • Runtime check: Label("perf").MatchesLabelFilter(GinkgoLabelFilter()) lets a spec branch on the active --label-filter (GinkgoLabelFilter() returns it).
  • Discover/iterate: ginkgo labels lists labels in a package; ginkgo --dry-run -v --label-filter=Q shows what a filter selects without running.

SemVer filtering

SemVerConstraint(">= 3.2.0") (and ComponentSemVerConstraint("redis", ">= 8.0.0")) gate specs by version; run with --sem-ver-filter. Constraints follow Masterminds/semver (~, ^, comma-ANDed). Hierarchical: child constraints *narrow

अक्सर पूछे जाने वाले सवाल

क्या pending टेस्ट को ज़बरदस्ती चलाया जा सकता है?

नहीं। कोई भी चीज़ pending निशान को ओवरराइड नहीं कर सकती, इसलिए टेस्ट छूटा रहता है।

pending और skip में क्या अंतर है?

pending compile समय पर तय होता है, जबकि skip रन के दौरान तय होता है।

क्या pending टेस्ट build को फ़ेल करते हैं?

डिफ़ॉल्ट रूप से नहीं, लेकिन fail-on-pending विकल्प से मौजूद होने पर CI फ़ेल हो जाता है।

जानकारी

लेखक का मूल विवरण

Run a subset of a Ginkgo suite — Pending/PIt/XIt, runtime Skip, programmatic Focus/FIt (and ginkgo unfocus), Label with the --label-filter query language and label sets, suite-level labels, SemVerConstraint/--sem-ver-filter, --focus/--skip and --focus-file/--skip-file, the filtering precedence rules, and --fail-on-pending/--fail-on-empty. Use when you want to run, skip, focus, label, or version-gate specs, or debug why specs were or weren't selected.

repo: onsi/ginkgo

लोकप्रियता

GitHub स्टार
9.1k
रैंकिंग में स्थान
#12301
लाइसेंस
MIT
अपडेट की गई
9/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills