@@ -476,26 +476,35 @@ task 'bench', 'quick benchmark of compilation time', ->
476476
477477
478478class PatternSet
479- constructor : (patternStrings = []) ->
479+ constructor : (patternStrings = [], { @negated = no } = {} ) ->
480480 @matchers = (new RegExp p for p in patternStrings when p isnt ' ' )
481481
482482 isEmpty : -> @matchers .length is 0
483483
484484 iterMatchers : -> @matchers [Symbol .iterator ]()
485485
486- matches : (arg ) -> if @ isEmpty () then yes else @ iterMatchers ().some (m) -> (m .exec arg)?
486+ test_ : (arg ) -> @ iterMatchers ().some (m) -> m .exec arg
487+
488+ allows : (arg ) ->
489+ return yes if @ isEmpty ()
490+ if @negated
491+ not @ test_ arg
492+ else
493+ @ test_ arg
487494
488495 @ fromCommaDelimitedList: (commaListStr ) => new @ (commaListStr ? ' ' ).split / ,/
489- @ empty: = > new @ []
496+ @ empty: ({ negated = no } = {}) = > new @ [], {negated}
490497
491498
492499# Run the CoffeeScript test suite.
493- runTests = (CoffeeScript , {filePatterns , descPatterns } = {}) ->
500+ runTests = (CoffeeScript , {filePatterns , negFilePatterns , descPatterns , negDescPatterns } = {}) ->
494501 CoffeeScript .register () unless global .testingBrowser
495502
496503 filePatterns ?= PatternSet .empty ()
504+ negFilePatterns ?= PatternSet .empty {negated : yes }
497505 descPatterns ?= PatternSet .empty ()
498- console .log {filePatterns, descPatterns}
506+ negDescPatterns ?= PatternSet .empty {negated : yes }
507+ console .dir {filePatterns, negFilePatterns, descPatterns, negDescPatterns}
499508
500509 # These are attached to `global` so that they’re accessible from within
501510 # `test/async.coffee`, which has an async-capable version of
@@ -538,7 +547,7 @@ runTests = (CoffeeScript, {filePatterns, descPatterns} = {}) ->
538547
539548 # Our test helper function for delimiting different test cases.
540549 global .test = (description , fn ) ->
541- unless descPatterns .matches description
550+ unless ( descPatterns .allows description) and ( negDescPatterns . allows description)
542551 onFilteredOut description, fn
543552 return
544553 try
@@ -593,7 +602,7 @@ runTests = (CoffeeScript, {filePatterns, descPatterns} = {}) ->
593602
594603 startTime = Date .now ()
595604 for file in files when helpers .isCoffee file
596- unless filePatterns .matches file
605+ unless ( filePatterns .allows file) and ( negFilePatterns . allows file)
597606 onFilteredFile file
598607 continue
599608 literate = helpers .isLiterate file
@@ -608,13 +617,17 @@ runTests = (CoffeeScript, {filePatterns, descPatterns} = {}) ->
608617 Promise .reject () if failures .length isnt 0
609618
610619
611- option ' -f' , ' --file [REGEXP*]' , ' test file patterns to match'
612- option ' -d' , ' --desc [REGEXP*]' , ' test description patterns to match'
620+ option ' -f' , ' --file [REGEXP*]' , ' test file patterns to positively match'
621+ option null , ' --negFile [REGEXP*]' , ' test file patterns to negatively match'
622+ option ' -d' , ' --desc [REGEXP*]' , ' test description patterns to positively match'
623+ option null , ' --negDesc [REGEXP*]' , ' test description patterns to negatively match'
613624
614- consoleTask ' test' , ' run the CoffeeScript language test suite' , ({file, desc} = {}) ->
625+ consoleTask ' test' , ' run the CoffeeScript language test suite' , ({file, negFile, desc, negDesc } = {}) ->
615626 testOptions =
616627 filePatterns : new PatternSet file
628+ negFilePatterns : new PatternSet negFile, {negated : yes }
617629 descPatterns : new PatternSet desc
630+ negDescPatterns : new PatternSet negDesc, {negated : yes }
618631 runTests (CoffeeScript, testOptions).catch -> process .exit 1
619632
620633task ' test:browser' , ' run the test suite against the modern browser compiler in a headless browser' , ->
0 commit comments