1
1
var assert = require ( 'assert' ) ;
2
2
var exec = require ( 'child_process' ) . exec ;
3
+ var execSync = require ( 'child_process' ) . execSync ;
3
4
var fs = require ( 'fs' ) ;
4
5
var http = require ( 'http' ) ;
5
6
var path = require ( 'path' ) ;
@@ -12,6 +13,8 @@ var vows = require('vows');
12
13
13
14
function binaryContext ( options , context ) {
14
15
context . topic = function ( ) {
16
+ ( context . setup || Function . prototype ) ( ) ;
17
+
15
18
// We add __DIRECT__=1 to force binary into 'non-piped' mode
16
19
exec ( '__DIRECT__=1 ./bin/cleancss ' + options , this . callback ) ;
17
20
} ;
@@ -788,68 +791,72 @@ vows.describe('cleancss')
788
791
assert . equal ( stdout , '.one{color:red}' ) ;
789
792
}
790
793
} ) ,
791
- 'batch processing with explicitely given paths' : binaryContext ( '-b ./test/fixtures/partials/one.css ./test/fixtures/partials/five.css' , {
794
+ 'batch processing with explicitely given paths' : binaryContext ( '-b ./test/fixtures-batch-1/partials/one.css ./test/fixtures-batch-1/partials/five.css' , {
795
+ 'setup' : function ( ) {
796
+ execSync ( 'cp -fr test/fixtures test/fixtures-batch-1' ) ;
797
+ } ,
792
798
'creates two separate minified files' : function ( ) {
793
- assert . isTrue ( fs . existsSync ( 'test/fixtures/partials/one-min.css' ) ) ;
794
- assert . isFalse ( fs . existsSync ( 'test/fixtures/partials/two-min.css' ) ) ;
795
- assert . isTrue ( fs . existsSync ( 'test/fixtures/partials/five-min.css' ) ) ;
799
+ assert . isTrue ( fs . existsSync ( 'test/fixtures-batch-1 /partials/one-min.css' ) ) ;
800
+ assert . isFalse ( fs . existsSync ( 'test/fixtures-batch-1 /partials/two-min.css' ) ) ;
801
+ assert . isTrue ( fs . existsSync ( 'test/fixtures-batch-1 /partials/five-min.css' ) ) ;
796
802
} ,
797
803
'teardown' : function ( ) {
798
- deleteFile ( 'test/fixtures/partials/one-min.css' ) ;
799
- deleteFile ( 'test/fixtures/partials/five-min.css' ) ;
804
+ execSync ( 'rm -fr test/fixtures-batch-1' ) ;
800
805
}
801
806
} )
802
807
} )
803
808
. addBatch ( {
804
- 'batch processing with wildard paths' : binaryContext ( '-b ./test/fixtures/partials/\\*\\*/*.css' , {
809
+ 'batch processing with wildard paths' : binaryContext ( '-b ./test/fixtures-batch-2/partials/\\*\\*/*.css' , {
810
+ 'setup' : function ( ) {
811
+ execSync ( 'cp -fr test/fixtures test/fixtures-batch-2' ) ;
812
+ } ,
805
813
'creates two separate minified files' : function ( ) {
806
- assert . isTrue ( fs . existsSync ( 'test/fixtures/partials/extra/four-min.css' ) ) ;
807
- assert . isTrue ( fs . existsSync ( 'test/fixtures/partials/extra/three-min.css' ) ) ;
808
- assert . isTrue ( fs . existsSync ( 'test/fixtures/partials/one-min.css' ) ) ;
809
- assert . isTrue ( fs . existsSync ( 'test/fixtures/partials/two-min.css' ) ) ;
810
- assert . isTrue ( fs . existsSync ( 'test/fixtures/partials/quoted-svg-min.css' ) ) ;
811
- assert . isTrue ( fs . existsSync ( 'test/fixtures/partials/five-min.css' ) ) ;
814
+ assert . isTrue ( fs . existsSync ( 'test/fixtures-batch-2 /partials/extra/four-min.css' ) ) ;
815
+ assert . isTrue ( fs . existsSync ( 'test/fixtures-batch-2 /partials/extra/three-min.css' ) ) ;
816
+ assert . isTrue ( fs . existsSync ( 'test/fixtures-batch-2 /partials/one-min.css' ) ) ;
817
+ assert . isTrue ( fs . existsSync ( 'test/fixtures-batch-2 /partials/two-min.css' ) ) ;
818
+ assert . isTrue ( fs . existsSync ( 'test/fixtures-batch-2 /partials/quoted-svg-min.css' ) ) ;
819
+ assert . isTrue ( fs . existsSync ( 'test/fixtures-batch-2 /partials/five-min.css' ) ) ;
812
820
} ,
813
821
'teardown' : function ( ) {
814
- deleteFile ( 'test/fixtures/partials/extra/four-min.css' ) ;
815
- deleteFile ( 'test/fixtures/partials/extra/three-min.css' ) ;
816
- deleteFile ( 'test/fixtures/partials/one-min.css' ) ;
817
- deleteFile ( 'test/fixtures/partials/two-min.css' ) ;
818
- deleteFile ( 'test/fixtures/partials/quoted-svg-min.css' ) ;
819
- deleteFile ( 'test/fixtures/partials/five-min.css' ) ;
822
+ execSync ( 'rm -fr test/fixtures-batch-2' ) ;
820
823
}
821
824
} )
822
825
} )
823
826
. addBatch ( {
824
- 'batch processing with custom suffix' : binaryContext ( '--batch --batch-suffix \'.min\' ./test/fixtures/partials/one.css ./test/fixtures/partials/five.css' , {
827
+ 'batch processing with custom suffix' : binaryContext ( '--batch --batch-suffix \'.min\' ./test/fixtures-batch-3/partials/one.css ./test/fixtures-batch-3/partials/five.css' , {
828
+ 'setup' : function ( ) {
829
+ execSync ( 'cp -fr test/fixtures test/fixtures-batch-3' ) ;
830
+ } ,
825
831
'creates two separate minified files' : function ( ) {
826
- assert . isFalse ( fs . existsSync ( 'test/fixtures/partials/one-min.css' ) ) ;
827
- assert . isFalse ( fs . existsSync ( 'test/fixtures/partials/two-min.css' ) ) ;
828
- assert . isFalse ( fs . existsSync ( 'test/fixtures/partials/five-min.css' ) ) ;
832
+ assert . isFalse ( fs . existsSync ( 'test/fixtures-batch-3 /partials/one-min.css' ) ) ;
833
+ assert . isFalse ( fs . existsSync ( 'test/fixtures-batch-3 /partials/two-min.css' ) ) ;
834
+ assert . isFalse ( fs . existsSync ( 'test/fixtures-batch-3 /partials/five-min.css' ) ) ;
829
835
830
- assert . isTrue ( fs . existsSync ( 'test/fixtures/partials/one.min.css' ) ) ;
831
- assert . isFalse ( fs . existsSync ( 'test/fixtures/partials/two.min.css' ) ) ;
832
- assert . isTrue ( fs . existsSync ( 'test/fixtures/partials/five.min.css' ) ) ;
836
+ assert . isTrue ( fs . existsSync ( 'test/fixtures-batch-3 /partials/one.min.css' ) ) ;
837
+ assert . isFalse ( fs . existsSync ( 'test/fixtures-batch-3 /partials/two.min.css' ) ) ;
838
+ assert . isTrue ( fs . existsSync ( 'test/fixtures-batch-3 /partials/five.min.css' ) ) ;
833
839
} ,
834
840
'teardown' : function ( ) {
835
- deleteFile ( 'test/fixtures/partials/one.min.css' ) ;
836
- deleteFile ( 'test/fixtures/partials/five.min.css' ) ;
841
+ execSync ( 'rm -fr test/fixtures-batch-3' ) ;
837
842
}
838
843
} )
839
844
} )
840
845
. addBatch ( {
841
- 'batch processing with output given' : binaryContext ( '-b -o ./test ./test/fixtures/partials/one.css ./test/fixtures/partials/five.css' , {
846
+ 'batch processing with output given' : binaryContext ( '-b -o ./test ./test/fixtures-batch-4/partials/one.css ./test/fixtures-batch-4/partials/five.css' , {
847
+ 'setup' : function ( ) {
848
+ execSync ( 'cp -fr test/fixtures test/fixtures-batch-4' ) ;
849
+ } ,
842
850
'does not produce any errors' : function ( error ) {
843
851
assert . equal ( error , '' ) ;
844
852
} ,
845
853
'creates two separate minified files' : function ( ) {
846
- assert . isTrue ( fs . existsSync ( 'test/fixtures/partials/one-min.css' ) ) ;
847
- assert . isFalse ( fs . existsSync ( 'test/fixtures/partials/two-min.css' ) ) ;
848
- assert . isTrue ( fs . existsSync ( 'test/fixtures/partials/five-min.css' ) ) ;
854
+ assert . isTrue ( fs . existsSync ( 'test/fixtures-batch-4 /partials/one-min.css' ) ) ;
855
+ assert . isFalse ( fs . existsSync ( 'test/fixtures-batch-4 /partials/two-min.css' ) ) ;
856
+ assert . isTrue ( fs . existsSync ( 'test/fixtures-batch-4 /partials/five-min.css' ) ) ;
849
857
} ,
850
858
'teardown' : function ( ) {
851
- deleteFile ( 'test/fixtures/partials/one-min.css' ) ;
852
- deleteFile ( 'test/fixtures/partials/five-min.css' ) ;
859
+ execSync ( 'rm -fr test/fixtures-batch-4' ) ;
853
860
}
854
861
} )
855
862
} )
0 commit comments