Skip to content

Commit

Permalink
test(cli): exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Jul 8, 2024
1 parent 2010b9f commit 12d7319
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .changeset/five-mice-kiss.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"@wagmi/cli": patch
---

Fixed an issue that made the exclude options of the hardhat & Foundry plugins ignored
Fixed an issue where the Foundry and Hardhat plugins' `exclude` option was ignored.
11 changes: 11 additions & 0 deletions packages/cli/src/plugins/__fixtures__/foundry/src/Foo.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

contract Foo {
string public bar;

function setFoo(string memory baz) public {
bar = baz;
}
}

10 changes: 10 additions & 0 deletions packages/cli/src/plugins/__fixtures__/hardhat/contracts/Foo.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

contract Foo {
string public bar;

function setFoo(string memory baz) public {
bar = baz;
}
}
15 changes: 10 additions & 5 deletions packages/cli/src/plugins/foundry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ afterEach(() => {

test('forge not installed', async () => {
const dir = f.temp()
await expect(
expect(
foundry({
project: dir,
forge: {
Expand Down Expand Up @@ -44,13 +44,14 @@ test('validates without project', async () => {
const spy = vi.spyOn(process, 'cwd')
spy.mockImplementation(() => dir)

await expect(foundry().validate()).resolves.toBeUndefined()
expect(foundry().validate()).resolves.toBeUndefined()
})

test('contracts', async () => {
await expect(
test('contracts', () => {
expect(
foundry({
project: resolve(__dirname, '__fixtures__/foundry/'),
exclude: ['Foo.sol/**'],
}).contracts(),
).resolves.toMatchInlineSnapshot(`
[
Expand Down Expand Up @@ -102,7 +103,11 @@ test('contracts without project', async () => {
const spy = vi.spyOn(process, 'cwd')
spy.mockImplementation(() => dir)

await expect(foundry().contracts()).resolves.toMatchInlineSnapshot(`
expect(
foundry({
exclude: ['Foo.sol/**'],
}).contracts(),
).resolves.toMatchInlineSnapshot(`
[
{
"abi": [
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/src/plugins/hardhat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ afterEach(() => {

test('validate', async () => {
const temp = f.temp()
await expect(
expect(
hardhat({ project: temp }).validate(),
).rejects.toThrowErrorMatchingInlineSnapshot(
'[Error: hardhat must be installed to use Hardhat plugin.]',
Expand All @@ -34,9 +34,10 @@ test('project does not exist', async () => {
})

test('contracts', async () => {
await expect(
expect(
hardhat({
project: resolve(__dirname, '__fixtures__/hardhat/'),
exclude: ['Foo.sol/**'],
}).contracts(),
).resolves.toMatchInlineSnapshot(`
[
Expand Down

0 comments on commit 12d7319

Please sign in to comment.