-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: improved local test running (#1441)
- Added node script to add terminal aliases (helps to easily run test groups) - Integrated mocha watch - Removed redundant sh helper scripts - See mochajs/mocha#5149 --------- Co-authored-by: Arya <[email protected]>
- Loading branch information
1 parent
d4999de
commit f60f3e0
Showing
33 changed files
with
145 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* (c) Copyright IBM Corp. 2024 | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const { execSync } = require('child_process'); | ||
const fs = require('fs'); | ||
const os = require('os'); | ||
|
||
const addAliasIfNotExists = (aliasCommand, configFile) => { | ||
let fileContent = ''; | ||
try { | ||
fileContent = fs.readFileSync(configFile, 'utf8'); | ||
} catch (err) { | ||
console.error(`Could not read ${configFile}: ${err.message}`); | ||
return; | ||
} | ||
|
||
if (!fileContent.includes(aliasCommand)) { | ||
fs.appendFileSync(configFile, `\n${aliasCommand}\n`); | ||
console.log(`Added alias: ${aliasCommand}`); | ||
} else { | ||
console.log(`Alias already exists: ${aliasCommand}`); | ||
} | ||
}; | ||
|
||
const output = execSync('lerna list --json', { encoding: 'utf-8' }); | ||
const packages = JSON.parse(output); | ||
const scopeNames = packages.map(pkg => pkg.name); | ||
const shellArg = process.argv[2]; | ||
|
||
if (!shellArg) { | ||
console.error('Error: Please specify either "bash" or "zsh".'); | ||
process.exit(1); | ||
} | ||
|
||
let configFile; | ||
if (shellArg === 'bash') { | ||
configFile = `${os.homedir()}/.bashrc`; | ||
} else if (shellArg === 'zsh') { | ||
configFile = `${os.homedir()}/.zshrc`; | ||
} else { | ||
console.error('Error: Invalid argument. Please specify "bash" or "zsh".'); | ||
process.exit(1); | ||
} | ||
|
||
scopeNames.forEach(scope => { | ||
const cleanedScope = scope.replace('@instana/', ''); | ||
|
||
const watchAlias = `alias run${cleanedScope}='bin/run-tests.sh --scope=${scope} --watch'`; | ||
const nwAlias = `alias run${cleanedScope}-nw='bin/run-tests.sh --scope=${scope}'`; | ||
|
||
addAliasIfNotExists(watchAlias, configFile); | ||
addAliasIfNotExists(nwAlias, configFile); | ||
}); | ||
|
||
console.log('Aliases added. Please run the following command to apply the changes:'); | ||
console.log(` source ${configFile}`); | ||
console.log('Alternatively, restart your terminal.'); | ||
|
||
console.log('Done'); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.