Skip to content

Commit

Permalink
Run tests only if forge is available.
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkaMaul committed Jun 12, 2024
1 parent 7b983e3 commit f1df3ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 65 deletions.
65 changes: 3 additions & 62 deletions tests/tools/mutator/test_data/test_source_unit/README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,7 @@
## Foundry
# Counter

**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**

Foundry consists of:

- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.

## Documentation

https://book.getfoundry.sh/

## Usage

### Build

```shell
$ forge build
```

### Test

```shell
$ forge test
```

### Format

```shell
$ forge fmt
```

### Gas Snapshots

```shell
$ forge snapshot
```

### Anvil

```shell
$ anvil
```

### Deploy

```shell
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
```

### Cast

```shell
$ cast <subcommand>
```

### Help
Init using :

```shell
$ forge --help
$ anvil --help
$ cast --help
forge install --no-commit --no-git .
```
16 changes: 13 additions & 3 deletions tests/tools/mutator/test_mutator.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import argparse
from contextlib import contextmanager
import os
from pathlib import Path
import shutil
import subprocess
import tempfile
from pathlib import Path
from unittest import mock
import argparse
from contextlib import contextmanager

import pytest
from slither import Slither
Expand All @@ -15,6 +16,9 @@

TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data"

foundry_available = shutil.which("forge") is not None
project_ready = Path(TEST_DATA_DIR, "test_source_unit/lib/forge-std").exists()


@contextmanager
def change_directory(new_dir):
Expand Down Expand Up @@ -75,6 +79,9 @@ def test_backup_source_file():
assert Path(files_dict[file_path]).exists()


@pytest.mark.skipif(
not foundry_available or not project_ready, reason="requires Foundry and project setup"
)
def test_get_sol_file_list():

project_directory = TEST_DATA_DIR / "test_source_unit"
Expand All @@ -98,6 +105,9 @@ def test_get_sol_file_list():
(project_directory / "test.sol").rmdir()


@pytest.mark.skipif(
not foundry_available or not project_ready, reason="requires Foundry and project setup"
)
def test_run_test(caplog):
with change_directory(TEST_DATA_DIR / "test_source_unit"):
result = run_test_cmd("forge test", timeout=None, target_file=None, verbose=True)
Expand Down

0 comments on commit f1df3ea

Please sign in to comment.