Skip to content

Comments

Allow optional configuration of expected line endings for TAPTestEngine#20

Open
farrago wants to merge 1 commit intotagview:masterfrom
farrago:tap-line-endings
Open

Allow optional configuration of expected line endings for TAPTestEngine#20
farrago wants to merge 1 commit intotagview:masterfrom
farrago:tap-line-endings

Conversation

@farrago
Copy link

@farrago farrago commented Oct 23, 2017

Summary

Add optional "unit.engine.tap.eol" config option for specifying line ending to split results by.
Defaults to PHP_EOL if not configured.

Discussion

Previously TAPTestEngine splits the lines of TAP output on PHP_EOL. This is a problem if the output it is parsing has any other line endings. For example, the Mocha test framework for NodeJS always outputs its TAP results with "\n" as the line ending, even on Windows.

This revision adds a new, optional, config parameter to allow the line ending to be specified in .arcconfig.

E.g. in the case above with Mocha tests run through gulp, the following config would allow the results to be correctly parsed:

  "unit.engine": "TAPTestEngine",
  "unit.engine.tap.command": "gulp test",
  "unit.engine.tap.eol": "\n"

Backwards compatibility

If the config line is not added, the default remains as PHP_EOL, so existing users will be unaffected.

Test Plan

On Windows (i.e. PHP_EOL == "\r\n"):

  • Leave "unit.engine.tap.eol" unset (i.e. legacy configs)

    • Test TAP output with "\r\n" end-of-lines and check it is parsed correctly
    • Test TAP output with "\n" end-of-lines and check it is NOT parsed
  • Set "unit.engine.tap.eol": "\n" in .arcconfig (i.e. different line ending than OS)

    • Test TAP output with "\r\n" end-of-lines and check it is now NOT parsed
    • Test TAP output with "\n" end-of-lines and check it is parsed correctly
  • Set "unit.engine.tap.eol": "\r\n" in .arcconfig (i.e. explicitly same line ending as OS)

    • Test TAP output with "\r\n" end-of-lines and check it is parsed correctly
    • Test TAP output with "\n" end-of-lines and check it is NOT parsed

= Summary

Add optional `"unit.engine.tap.eol"` config option for specifying line ending to split results by.
Defaults to `PHP_EOL` if not configured.

= Discussion

Previously `TAPTestEngine` splits the lines of TAP output on `PHP_EOL`.

This is a problem if the output it is parsing has any other line endings.
For example, [mochajs](mochajs.org) always outputs its TAP results with
`"\n"` as the line ending, even on windows.

This revision adds a new, optional, config parameter to allow the line ending to be specified in `.arcconfig`.

E.g. in the case above with `mochajs` tests run through `gulp`, the
following config would allow the results to be correctly parsed:

```
  "unit.engine": "TAPTestEngine",
  "unit.engine.tap.command": "gulp test",
  "unit.engine.tap.eol": "\n"
```

= Backwards compatibility

If the config line is not added, the default remains as `PHP_EOL`, so
existing users will be unaffected.

= Test Plan

On Windows (i.e. `PHP_EOL` == `"\r\n"`):

* Leave `"unit.engine.tap.eol"` unset (i.e. legacy configs)
  * Test TAP output with `"\r\n"` end-of-lines and check it is parsed correctly
  * Test TAP output with `"\n"` end-of-lines and check it is NOT parsed

* Set `"unit.engine.tap.eol": "\n"` in `.arcconfig` (i.e. different line ending than OS)
  * Test TAP output with `"\r\n"` end-of-lines and check it is now NOT parsed
  * Test TAP output with `"\n"` end-of-lines and check it is parsed correctly

* Set `"unit.engine.tap.eol": "\n"` in `.arcconfig` (i.e. explicitly same line ending as OS)
  * Test TAP output with `"\r\n"` end-of-lines and check it is parsed correctly
  * Test TAP output with `"\n"` end-of-lines and check it is NOT parsed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant