@@ -42,3 +42,85 @@ t.test('os wrong (negation)', async t =>
42
42
43
43
t . test ( 'nothing wrong (negation)' , async t =>
44
44
checkPlatform ( { cpu : '!enten-cpu' , os : '!enten-os' } ) )
45
+
46
+ t . test ( 'libc' , ( t ) => {
47
+ let PLATFORM = ''
48
+
49
+ const _processPlatform = Object . getOwnPropertyDescriptor ( process , 'platform' )
50
+ Object . defineProperty ( process , 'platform' , {
51
+ enumerable : true ,
52
+ configurable : true ,
53
+ get : ( ) => PLATFORM ,
54
+ } )
55
+
56
+ let REPORT = { }
57
+ const _processReport = process . report . getReport
58
+ process . report . getReport = ( ) => REPORT
59
+
60
+ t . teardown ( ( ) => {
61
+ Object . defineProperty ( process , 'platform' , _processPlatform )
62
+ process . report . getReport = _processReport
63
+ } )
64
+
65
+ t . test ( 'ignored when not in linux' , ( t ) => {
66
+ PLATFORM = 'darwin'
67
+
68
+ t . doesNotThrow ( ( ) => checkPlatform ( { libc : 'glibc' } ) , 'allows glibc' )
69
+ t . doesNotThrow ( ( ) => checkPlatform ( { libc : 'musl' } ) , 'allows musl' )
70
+ t . end ( )
71
+ } )
72
+
73
+ t . test ( 'report missing info' , ( t ) => {
74
+ PLATFORM = 'linux'
75
+
76
+ t . end ( )
77
+ } )
78
+
79
+ t . test ( 'glibc' , ( t ) => {
80
+ PLATFORM = 'linux'
81
+
82
+ REPORT = { }
83
+ t . throws ( ( ) => checkPlatform ( { libc : 'glibc' } ) , { code : 'EBADPLATFORM' } ,
84
+ 'fails when report is missing header property' )
85
+
86
+ REPORT = { header : { } }
87
+ t . throws ( ( ) => checkPlatform ( { libc : 'glibc' } ) , { code : 'EBADPLATFORM' } ,
88
+ 'fails when header is missing glibcRuntimeVersion property' )
89
+
90
+ REPORT = { header : { glibcRuntimeVersion : '1' } }
91
+ t . doesNotThrow ( ( ) => checkPlatform ( { libc : 'glibc' } ) , 'allows glibc on glibc' )
92
+ t . throws ( ( ) => checkPlatform ( { libc : 'musl' } ) , { code : 'EBADPLATFORM' } ,
93
+ 'does not allow musl on glibc' )
94
+
95
+ t . end ( )
96
+ } )
97
+
98
+ t . test ( 'musl' , ( t ) => {
99
+ PLATFORM = 'linux'
100
+
101
+ REPORT = { }
102
+ t . throws ( ( ) => checkPlatform ( { libc : 'musl' } ) , { code : 'EBADPLATFORM' } ,
103
+ 'fails when report is missing sharedObjects property' )
104
+
105
+ REPORT = { sharedObjects : { } }
106
+ t . throws ( ( ) => checkPlatform ( { libc : 'musl' } ) , { code : 'EBADPLATFORM' } ,
107
+ 'fails when sharedObjects property is not an array' )
108
+
109
+ REPORT = { sharedObjects : [ ] }
110
+ t . throws ( ( ) => checkPlatform ( { libc : 'musl' } ) , { code : 'EBADPLATFORM' } ,
111
+ 'fails when sharedObjects does not contain musl' )
112
+
113
+ REPORT = { sharedObjects : [ 'ld-musl-foo' ] }
114
+ t . doesNotThrow ( ( ) => checkPlatform ( { libc : 'musl' } ) , 'allows musl on musl as ld-musl-' )
115
+
116
+ REPORT = { sharedObjects : [ 'libc.musl-' ] }
117
+ t . doesNotThrow ( ( ) => checkPlatform ( { libc : 'musl' } ) , 'allows musl on musl as libc.musl-' )
118
+
119
+ t . throws ( ( ) => checkPlatform ( { libc : 'glibc' } ) , { code : 'EBADPLATFORM' } ,
120
+ 'does not allow glibc on musl' )
121
+
122
+ t . end ( )
123
+ } )
124
+
125
+ t . end ( )
126
+ } )
0 commit comments