Skip to content

Commit

Permalink
fix e2e v2
Browse files Browse the repository at this point in the history
  • Loading branch information
dbale-altoros committed May 11, 2024
1 parent d86157f commit 9ef5c69
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Solhint changed how the exit codes are implemented:
#### Solhint QUIET mode
QUIET mode (-c quiet) option now works with the warnings and may exit with 1 if there are more than defined by user

Thanks to [@juanpcapurro](https://github.com/juanpcapurro) for providing the code

<br><br>
## [4.5.4] - 2024-04-10
Expand Down
24 changes: 17 additions & 7 deletions e2e/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,14 @@ describe('e2e', function () {
expect(stdout.trim()).to.equal('')
})

it('should show warning when using --init', function () {
it.only('should show warning when using --init', function () {
shell.exec(`pwd`)
shell.exec(`ls`)

const { code, stdout } = shell.exec(`${NODE}solhint --init`)

console.log("code: ", code)
console.log("stdout: ", stdout)

expect(code).to.equal(EXIT_CODES.BAD_OPTIONS)
expect(stdout.trim()).to.equal('Configuration file already exists')
Expand All @@ -96,14 +102,12 @@ describe('e2e', function () {
const PATH = '03-no-empty-blocks'
const { PREFIX, SUFFIX } = prepareContext(PATH)

describe('No contracts to lint', function () {
it('should fail with appropiate message', function () {
const { code, stderr } = shell.exec(`${NODE}solhint Foo.sol ${SUFFIX}`)

it('No contracts to lint should fail with appropiate message', function () {
const { code, stderr } = shell.exec(`${NODE}solhint Foo1.sol ${SUFFIX}`)

expect(code).to.equal(EXIT_CODES.BAD_OPTIONS)
expect(stderr).to.include('No files to lint!')
})
})

it('should end with REPORTED_ERRORS = 1 because report contains errors', function () {
const { code, stdout } = shell.exec(`${NODE}solhint ${PREFIX}Foo.sol ${SUFFIX}`)
Expand Down Expand Up @@ -211,10 +215,16 @@ describe('e2e', function () {
expect(stdout.trim()).to.contain('Code contains empty blocks')
})

it(`should raise error for wrongFunctionDefinitionName() only`, () => {
it.only(`should raise error for wrongFunctionDefinitionName() only`, () => {
shell.exec(`pwd`)
shell.exec(`ls`)
console.log('command :>> ', `${NODE}solhint ${PREFIX}test/FooTest.sol ${SUFFIX2}`)
const SUFFIX2 = `-c ${PREFIX}test/.solhint.json --disc`
const { code, stdout } = shell.exec(`${NODE}solhint ${PREFIX}test/FooTest.sol ${SUFFIX2}`)

console.log("code: ", code)
console.log("stdout: ", stdout)

expect(code).to.equal(EXIT_CODES.OK)
expect(stdout.trim()).to.contain(
'Function wrongFunctionDefinitionName() must match Foundry test naming convention '
Expand Down
2 changes: 2 additions & 0 deletions solhint.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ function writeSampleConfigFile() {
"extends": "solhint:default"
}
`
console.log('configPath :>> ', configPath);

Check failure on line 218 in solhint.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on MacOS

Delete `;`

Check failure on line 218 in solhint.js

View workflow job for this annotation

GitHub Actions / Test on MacOS

Delete `;`

Check failure on line 218 in solhint.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Windows

Delete `;`

Check failure on line 218 in solhint.js

View workflow job for this annotation

GitHub Actions / Test on Windows

Delete `;`

Check failure on line 218 in solhint.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Linux (16)

Delete `;`

Check failure on line 218 in solhint.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Linux (18)

Delete `;`

Check failure on line 218 in solhint.js

View workflow job for this annotation

GitHub Actions / Test on Linux with Node 18

Delete `;`

Check failure on line 218 in solhint.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Linux (20)

Delete `;`

Check failure on line 218 in solhint.js

View workflow job for this annotation

GitHub Actions / Test on Linux with Node 20

Delete `;`

Check failure on line 219 in solhint.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on MacOS

Delete `··`

Check failure on line 219 in solhint.js

View workflow job for this annotation

GitHub Actions / Test on MacOS

Delete `··`

Check failure on line 219 in solhint.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Windows

Delete `··`

Check failure on line 219 in solhint.js

View workflow job for this annotation

GitHub Actions / Test on Windows

Delete `··`

Check failure on line 219 in solhint.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Linux (16)

Delete `··`

Check failure on line 219 in solhint.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Linux (18)

Delete `··`

Check failure on line 219 in solhint.js

View workflow job for this annotation

GitHub Actions / Test on Linux with Node 18

Delete `··`

Check failure on line 219 in solhint.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Linux (20)

Delete `··`

Check failure on line 219 in solhint.js

View workflow job for this annotation

GitHub Actions / Test on Linux with Node 20

Delete `··`
if (!fs.existsSync(configPath)) {
fs.writeFileSync(configPath, sampleConfig)

Expand Down

0 comments on commit 9ef5c69

Please sign in to comment.