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

add line number to TestParseException exception message #4446

Merged
merged 1 commit into from Aug 24, 2017

Conversation

Projects
None yet
3 participants
@gaainf
Contributor

gaainf commented Aug 11, 2017

add line number to debug easier

@Naktibalda

This comment has been minimized.

Show comment
Hide comment
@Naktibalda

Naktibalda Aug 11, 2017

Member

Have you tested it? Does it work as expected?
I would expect getLine to return a line where TestParseException was thrown and not where the syntax error is.

Member

Naktibalda commented Aug 11, 2017

Have you tested it? Does it work as expected?
I would expect getLine to return a line where TestParseException was thrown and not where the syntax error is.

@gaainf

This comment has been minimized.

Show comment
Hide comment
@gaainf

gaainf Aug 11, 2017

Contributor

You are right. I have to pass line number as separate parameter. Probably passing of $exception is more appropriate solution, but in some modules I saw throw new TestParseException($file, $some_string).

Fixed and tested with php:

$ php -l cli/DryRunCest.php
PHP Parse error:  syntax error, unexpected '$I' (T_VARIABLE) in cli/DryRunCest.php on line 12

Parse error: syntax error, unexpected '$I' (T_VARIABLE) in cli/DryRunCest.php on line 12

Errors parsing cli/DryRunCest.php

and with codecept:

$ docker-compose run --rm codecept run cli DryRunCest
Codeception PHP Testing Framework v2.3.5
Powered by PHPUnit 6.2.4 by Sebastian Bergmann and contributors.


  [Codeception\Exception\TestParseException]
  Couldn't parse test '/repo/tests/cli/DryRunCest.php' on line 12
  syntax error, unexpected '$I' (T_VARIABLE)
Contributor

gaainf commented Aug 11, 2017

You are right. I have to pass line number as separate parameter. Probably passing of $exception is more appropriate solution, but in some modules I saw throw new TestParseException($file, $some_string).

Fixed and tested with php:

$ php -l cli/DryRunCest.php
PHP Parse error:  syntax error, unexpected '$I' (T_VARIABLE) in cli/DryRunCest.php on line 12

Parse error: syntax error, unexpected '$I' (T_VARIABLE) in cli/DryRunCest.php on line 12

Errors parsing cli/DryRunCest.php

and with codecept:

$ docker-compose run --rm codecept run cli DryRunCest
Codeception PHP Testing Framework v2.3.5
Powered by PHPUnit 6.2.4 by Sebastian Bergmann and contributors.


  [Codeception\Exception\TestParseException]
  Couldn't parse test '/repo/tests/cli/DryRunCest.php' on line 12
  syntax error, unexpected '$I' (T_VARIABLE)
@Naktibalda

Looks good to me now.

@DavertMik

This comment has been minimized.

Show comment
Hide comment
@DavertMik

DavertMik Aug 24, 2017

Member

Thanks!

Member

DavertMik commented Aug 24, 2017

Thanks!

@DavertMik DavertMik merged commit 215bab0 into Codeception:2.3 Aug 24, 2017

4 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
semaphoreci The build passed on Semaphore.
Details
wercker/build Wercker pipeline passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment