@@ -476,26 +476,35 @@ task 'bench', 'quick benchmark of compilation time', ->
476
476
477
477
478
478
class PatternSet
479
- constructor : (patternStrings = []) ->
479
+ constructor : (patternStrings = [], { @negated = no } = {} ) ->
480
480
@matchers = (new RegExp p for p in patternStrings when p isnt ' ' )
481
481
482
482
isEmpty : -> @matchers .length is 0
483
483
484
484
iterMatchers : -> @matchers [Symbol .iterator ]()
485
485
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
487
494
488
495
@ fromCommaDelimitedList: (commaListStr ) => new @ (commaListStr ? ' ' ).split / ,/
489
- @ empty: = > new @ []
496
+ @ empty: ({ negated = no } = {}) = > new @ [], {negated}
490
497
491
498
492
499
# Run the CoffeeScript test suite.
493
- runTests = (CoffeeScript , {filePatterns , descPatterns } = {}) ->
500
+ runTests = (CoffeeScript , {filePatterns , negFilePatterns , descPatterns , negDescPatterns } = {}) ->
494
501
CoffeeScript .register () unless global .testingBrowser
495
502
496
503
filePatterns ?= PatternSet .empty ()
504
+ negFilePatterns ?= PatternSet .empty {negated : yes }
497
505
descPatterns ?= PatternSet .empty ()
498
- console .log {filePatterns, descPatterns}
506
+ negDescPatterns ?= PatternSet .empty {negated : yes }
507
+ console .dir {filePatterns, negFilePatterns, descPatterns, negDescPatterns}
499
508
500
509
# These are attached to `global` so that they’re accessible from within
501
510
# `test/async.coffee`, which has an async-capable version of
@@ -538,7 +547,7 @@ runTests = (CoffeeScript, {filePatterns, descPatterns} = {}) ->
538
547
539
548
# Our test helper function for delimiting different test cases.
540
549
global .test = (description , fn ) ->
541
- unless descPatterns .matches description
550
+ unless ( descPatterns .allows description) and ( negDescPatterns . allows description)
542
551
onFilteredOut description, fn
543
552
return
544
553
try
@@ -593,7 +602,7 @@ runTests = (CoffeeScript, {filePatterns, descPatterns} = {}) ->
593
602
594
603
startTime = Date .now ()
595
604
for file in files when helpers .isCoffee file
596
- unless filePatterns .matches file
605
+ unless ( filePatterns .allows file) and ( negFilePatterns . allows file)
597
606
onFilteredFile file
598
607
continue
599
608
literate = helpers .isLiterate file
@@ -608,13 +617,17 @@ runTests = (CoffeeScript, {filePatterns, descPatterns} = {}) ->
608
617
Promise .reject () if failures .length isnt 0
609
618
610
619
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'
613
624
614
- consoleTask ' test' , ' run the CoffeeScript language test suite' , ({file, desc} = {}) ->
625
+ consoleTask ' test' , ' run the CoffeeScript language test suite' , ({file, negFile, desc, negDesc } = {}) ->
615
626
testOptions =
616
627
filePatterns : new PatternSet file
628
+ negFilePatterns : new PatternSet negFile, {negated : yes }
617
629
descPatterns : new PatternSet desc
630
+ negDescPatterns : new PatternSet negDesc, {negated : yes }
618
631
runTests (CoffeeScript, testOptions).catch -> process .exit 1
619
632
620
633
task ' test:browser' , ' run the test suite against the modern browser compiler in a headless browser' , ->
0 commit comments