Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: config file #43

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,29 @@ Options:
--incremental TEXT File where incremental mutation state is
stored

--config TEXT File to parse vertigo options from
--help Show this message and exit.

```

### Using Configuration File

At this time a limited set of options have been implemented.

A user can create a config file in the project root (see sample below) to limit the number of command line parameters used.
```bash
vertigo run --config vertigo_config.yml
```

Sample config file:
```
//vertigo_config.yml
hardhat_parallel: 8
output: output.txt
```

Note that unused fields in the config file should be `false`.

### Known Issues

**Ganache** is generally used only for a single run of the entire test suite.
Expand Down
17 changes: 14 additions & 3 deletions eth_vertigo/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import click
import yaml
from os import getcwd
from pathlib import Path
from eth_vertigo.core import MutationResult
Expand Down Expand Up @@ -32,8 +33,9 @@ def cli():
@click.option('--truffle-location', help="Location of truffle cli", nargs=1, type=str, default="truffle")
@click.option('--sample-ratio', help="If this option is set. Vertigo will apply the sample filter with the given ratio", nargs=1, type=float)
@click.option('--exclude', help="Vertigo won't mutate files in these directories", multiple=True)
@click.option('--incremental', help="File where incremental mutation state is stored",
type=str)
@click.option('--incremental', help="File where incremental mutation state is stored",type=str)
@click.option('--config', help="Pulls CLI parameters from .yml file. (requires file name)", nargs=1, type=str)

def run(
output,
network,
Expand All @@ -45,7 +47,8 @@ def run(
truffle_location,
sample_ratio,
exclude,
incremental
incremental,
config
):
""" Run command """
click.echo("[*] Starting mutation testing")
Expand All @@ -55,6 +58,7 @@ def run(
working_directory = getcwd()
project_type = _directory_type(working_directory)
filters = []

if exclude:
filters.append(ExcludeFilter(exclude))

Expand All @@ -74,6 +78,13 @@ def run(
store = IncrementalMutationStore.from_file(incremental_store_file)
test_suggesters.append(IncrementalSuggester(store))

if config:
with open(config, 'r') as file:
config_params = yaml.safe_load(file)

output = config_params['output']
hardhat_parallel = config_params['hardhat_parallel']

click.echo("[*] Starting analysis on project")
project_path = Path(working_directory)

Expand Down