Skip to content

Commit 44475b5

Browse files
committedMar 18, 2020
feat: Update the concurrency option to support cpu
The -c option now takes a number or the string ‘cpu’. The string will set the concurrency to the number of cpus - 1.
1 parent b60a783 commit 44475b5

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed
 

Diff for: ‎modules/integration-node/src/cli.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616

1717
import yargs from 'yargs'
18+
import { needs } from '@aws-crypto/client-node'
19+
import { cpus } from 'os'
1820
import { integrationDecryptTestVectors, integrationEncryptTestVectors } from './integration_tests'
1921

2022
const cli = yargs
@@ -59,9 +61,16 @@ const cli = yargs
5961
})
6062
.option('concurrency', {
6163
alias: 'c',
62-
describe: 'an optional concurrency for running tests',
63-
type: 'number',
64-
default: 1
64+
describe: `an optional concurrency for running tests, pass 'cpu' to maximize`,
65+
default: 1,
66+
coerce: (value: any) => {
67+
if (typeof value === 'string') {
68+
needs(value.toLowerCase() === 'cpu', `The only supported string is 'cpu'`)
69+
return cpus().length - 1
70+
}
71+
needs(typeof value === 'number' && value > 0, `Must be a number greater than 0`)
72+
return value
73+
}
6574
})
6675
.demandCommand()
6776

Diff for: ‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"integration-browser-decrypt": "npm run build; integration-browser decrypt -v $npm_package_config_localTestVectors --karma -c cpu",
3333
"integration-browser-encrypt": "npm run build; integration-browser encrypt -m $npm_package_config_encryptManifestList -k $npm_package_config_encryptKeyManifest -o $npm_package_config_decryptOracle --karma -c cpu",
3434
"browser-integration": "run-s integration-browser-*",
35-
"integration-node-decrypt": "npm run build; integration-node decrypt -v $npm_package_config_localTestVectors -c 10",
36-
"integration-node-encrypt": "npm run build; integration-node encrypt -m $npm_package_config_encryptManifestList -k $npm_package_config_encryptKeyManifest -o $npm_package_config_decryptOracle -c 20",
35+
"integration-node-decrypt": "npm run build; integration-node decrypt -v $npm_package_config_localTestVectors -c cpu",
36+
"integration-node-encrypt": "npm run build; integration-node encrypt -m $npm_package_config_encryptManifestList -k $npm_package_config_encryptKeyManifest -o $npm_package_config_decryptOracle -c cpu",
3737
"node-integration": "run-s integration-node-*",
3838
"integration": "run-s integration-*",
3939
"test_conditions": "./util/test_conditions"

0 commit comments

Comments
 (0)