1
1
/**
2
- * If on a windows system, there are no unix sockets.
3
- * So we skip this test and defaulting the asserts in the
4
- * process.on('exit', [...]) function to false, when we find the
5
- * enviroment variable 'windir' is set. I assume 'windir' will not be set on
6
- * *nix-systems.
2
+ * This test is skipped, if the environment variable "windir" is set.
3
+ * It assumes that it runs on a windows system then.
7
4
*/
5
+ if ( process . env . windir ) {
6
+ return console . log ( 'Skipping "test-unix-domain-socket.js" - Environment'
7
+ + ' variable "windir" is set. Skipping this, because we seem to be on'
8
+ + ' a windows system' ) ;
9
+ }
8
10
var common = require ( '../../common' ) ;
9
11
var connection = common . createConnection ( { socketPath : common . fakeServerSocket } ) ;
10
12
var assert = require ( 'assert' ) ;
11
13
12
14
var server = common . createFakeServer ( ) ;
13
15
var didConnect = false ;
14
- if ( ! process . env . windir ) {
15
- server . listen ( common . fakeServerSocket , function ( err ) {
16
- if ( err ) throw err ;
17
16
18
- connection . connect ( function ( err ) {
17
+ server . listen ( common . fakeServerSocket , function ( err ) {
18
+ if ( err ) throw err ;
19
+
20
+ connection . connect ( function ( err ) {
19
21
if ( err ) throw err ;
20
22
21
23
assert . equal ( didConnect , false ) ;
22
24
didConnect = true ;
23
25
24
26
connection . destroy ( ) ;
25
27
server . destroy ( ) ;
26
- } ) ;
27
28
} ) ;
28
- }
29
+ } ) ;
29
30
30
31
var hadConnection = false ;
31
- if ( ! process . env . windir ) {
32
- server . on ( 'connection' , function ( connection ) {
33
- connection . handshake ( ) ;
32
+ server . on ( 'connection' , function ( connection ) {
33
+ connection . handshake ( ) ;
34
34
35
- assert . equal ( hadConnection , false ) ;
36
- hadConnection = true ;
37
- } ) ;
38
- }
35
+ assert . equal ( hadConnection , false ) ;
36
+ hadConnection = true ;
37
+ } ) ;
39
38
40
39
process . on ( 'exit' , function ( ) {
41
- if ( process . env . windir ) {
42
- assert . equal ( didConnect , false ) ;
43
- assert . equal ( hadConnection , false ) ;
44
- } else {
45
40
assert . equal ( didConnect , true ) ;
46
41
assert . equal ( hadConnection , true ) ;
47
- }
48
- } ) ;
42
+ } ) ;
0 commit comments