|
1 |
| -# Tests |
| 1 | +# Table of Contents |
| 2 | +* [Test directories](#test-directories) |
| 3 | +* [Common module API](#common-module-api) |
| 4 | + |
| 5 | +## Test Directories |
2 | 6 |
|
3 | 7 | ### abort
|
4 | 8 |
|
@@ -126,3 +130,247 @@ and `setInterval`).
|
126 | 130 | | Runs on CI |
|
127 | 131 | |:----------:|
|
128 | 132 | | No |
|
| 133 | + |
| 134 | + |
| 135 | +## Common module API |
| 136 | + |
| 137 | +The common.js module is used by tests for consistency across repeated |
| 138 | +tasks. It has a number of helpful functions and properties to help with |
| 139 | +writing tests. |
| 140 | + |
| 141 | +### allowGlobals(...whitelist) |
| 142 | +* `whitelist` [<Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) Array of Globals |
| 143 | +* return [<Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) |
| 144 | + |
| 145 | +Takes `whitelist` and concats that with predefined `knownGlobals`. |
| 146 | + |
| 147 | +### arrayStream |
| 148 | +A stream to push an array into a REPL |
| 149 | + |
| 150 | +### busyLoop(time) |
| 151 | +* `time` [<Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) |
| 152 | + |
| 153 | +Blocks for `time` amount of time. |
| 154 | + |
| 155 | +### ddCommand(filename, kilobytes) |
| 156 | +* return [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) |
| 157 | + |
| 158 | +Platform normalizes the `dd` command |
| 159 | + |
| 160 | +### enoughTestMem |
| 161 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 162 | + |
| 163 | +Check if there is more than 1gb of total memory. |
| 164 | + |
| 165 | +### expectWarning(name, expected) |
| 166 | +* `name` [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
| 167 | +* `expected` [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [<Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) |
| 168 | + |
| 169 | +Tests whether `name` and `expected` are part of a raised warning. |
| 170 | + |
| 171 | +### hasCrypto |
| 172 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 173 | + |
| 174 | +Checks for 'openssl'. |
| 175 | + |
| 176 | +### hasFipsCrypto |
| 177 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 178 | + |
| 179 | +Checks `hasCrypto` and `crypto` with fips. |
| 180 | + |
| 181 | +### hasIPv6 |
| 182 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 183 | + |
| 184 | +Checks whether `IPv6` is supported on this platform. |
| 185 | + |
| 186 | +### hasMultiLocalhost |
| 187 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 188 | + |
| 189 | +Checks if there are multiple localhosts available. |
| 190 | + |
| 191 | +### fail(msg) |
| 192 | +* `msg` [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
| 193 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 194 | + |
| 195 | +Throws an `AssertionError` with `msg` |
| 196 | + |
| 197 | +### faketimeCli |
| 198 | +* return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
| 199 | + |
| 200 | +Return the path to the fake. |
| 201 | + |
| 202 | +### fileExists(pathname) |
| 203 | +* pathname [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
| 204 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 205 | + |
| 206 | +Checks if `pathname` exists |
| 207 | + |
| 208 | +### fixturesDir |
| 209 | +* return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
| 210 | + |
| 211 | +Path to the 'fixtures' directory. |
| 212 | + |
| 213 | +### globalCheck |
| 214 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 215 | + |
| 216 | +Turn this off if the test should not check for global leaks. |
| 217 | + |
| 218 | +### inFreeBSDJail |
| 219 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 220 | + |
| 221 | +Checks whether free BSD Jail is true or false. |
| 222 | + |
| 223 | +### isAix |
| 224 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 225 | + |
| 226 | +Platform check for Advanced Interactive eXecutive (AIX). |
| 227 | + |
| 228 | +### isAlive(pid) |
| 229 | +* `pid` [<Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) |
| 230 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 231 | + |
| 232 | +Attempts to 'kill' `pid` |
| 233 | + |
| 234 | +### isFreeBSD |
| 235 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 236 | + |
| 237 | +Platform check for Free BSD. |
| 238 | + |
| 239 | +### isLinux |
| 240 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 241 | + |
| 242 | +Platform check for Linux. |
| 243 | + |
| 244 | +### isLinuxPPCBE |
| 245 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 246 | + |
| 247 | +Platform check for Linux on PowerPC. |
| 248 | + |
| 249 | +### isOSX |
| 250 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 251 | + |
| 252 | +Platform check for OS X. |
| 253 | + |
| 254 | +### isSunOS |
| 255 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 256 | + |
| 257 | +Platform check for SunOS. |
| 258 | + |
| 259 | +### isWindows |
| 260 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 261 | + |
| 262 | +Platform check for Windows. |
| 263 | + |
| 264 | +### isWOW64 |
| 265 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 266 | + |
| 267 | +Platform check for Windows 32-bit on Windows 64-bit. |
| 268 | + |
| 269 | +### leakedGlobals |
| 270 | +* return [<Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) |
| 271 | + |
| 272 | +Checks whether any globals are not on the `knownGlobals` list. |
| 273 | + |
| 274 | +### libDir |
| 275 | +* return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
| 276 | + |
| 277 | +Path to the 'lib' directory. |
| 278 | + |
| 279 | +### localhostIPv4 |
| 280 | +* return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
| 281 | + |
| 282 | +Gets IP of localhost |
| 283 | + |
| 284 | +### localIPv6Hosts |
| 285 | +* return [<Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) |
| 286 | + |
| 287 | +Array of IPV6 hosts. |
| 288 | + |
| 289 | +### mustCall(fn[, expected]) |
| 290 | +* fn [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) |
| 291 | +* expected [<Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) default = 1 |
| 292 | + |
| 293 | +Number of times `fn` should be called. |
| 294 | + |
| 295 | +### nodeProcessAborted(exitCode, signal) |
| 296 | +* `exitCode` [<Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) |
| 297 | +* `signal` [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
| 298 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 299 | + |
| 300 | +Returns `true` if the exit code `exitCode` and/or signal name `signal` represent the exit code and/or signal name of a node process that aborted, `false` otherwise. |
| 301 | + |
| 302 | +### opensslCli |
| 303 | +* return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
| 304 | + |
| 305 | +Checks whether 'opensslCli' is supported. |
| 306 | + |
| 307 | +### platformTimeout(ms) |
| 308 | +* `ms` [<Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) |
| 309 | +* return [<Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) |
| 310 | + |
| 311 | +Platform normalizes timeout. |
| 312 | + |
| 313 | +### PIPE |
| 314 | +* return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
| 315 | + |
| 316 | +Path to the test sock. |
| 317 | + |
| 318 | +### PORT |
| 319 | +* return [<Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) default = `12346` |
| 320 | + |
| 321 | +Port tests are running on. |
| 322 | + |
| 323 | +### refreshTmpDir |
| 324 | +* return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
| 325 | + |
| 326 | +Deletes the 'tmp' dir and recreates it |
| 327 | + |
| 328 | +### rootDir |
| 329 | +* return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
| 330 | + |
| 331 | +Path to the 'root' directory. either `/` or `c:\\` (windows) |
| 332 | + |
| 333 | +### skip(msg) |
| 334 | +* `msg` [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
| 335 | + |
| 336 | +Logs '1..0 # Skipped: ' + `msg` |
| 337 | + |
| 338 | +### spawnCat(options) |
| 339 | +* `options` [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) |
| 340 | +* return [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) |
| 341 | + |
| 342 | +Platform normalizes the `cat` command. |
| 343 | + |
| 344 | +### spawnPwd(options) |
| 345 | +* `options` [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) |
| 346 | +* return [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) |
| 347 | + |
| 348 | +Platform normalizes the `pwd` command. |
| 349 | + |
| 350 | +### spawnSyncCat(options) |
| 351 | +* `options` [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) |
| 352 | +* return [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) |
| 353 | + |
| 354 | +Synchronous version of `spawnCat`. |
| 355 | + |
| 356 | +### spawnSyncPwd(options) |
| 357 | +* `options` [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) |
| 358 | +* return [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) |
| 359 | + |
| 360 | +Synchronous version of `spawnPwd`. |
| 361 | + |
| 362 | +### testDir |
| 363 | + |
| 364 | +* return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
| 365 | + |
| 366 | +Path to the 'test' directory. |
| 367 | + |
| 368 | +### tmpDir |
| 369 | +* return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
| 370 | + |
| 371 | +Path to the 'tmp' directory. |
| 372 | + |
| 373 | +### tmpDirName |
| 374 | +* return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
| 375 | + |
| 376 | +Name of the temp directory used by tests. |
0 commit comments