{"action":"closed","issue":{"url":"https://api.github.com/repos/LightBDD/LightBDD/issues/137","repository_url":"https://api.github.com/repos/LightBDD/LightBDD","labels_url":"https://api.github.com/repos/LightBDD/LightBDD/issues/137/labels{/name}","comments_url":"https://api.github.com/repos/LightBDD/LightBDD/issues/137/comments","events_url":"https://api.github.com/repos/LightBDD/LightBDD/issues/137/events","html_url":"https://github.com/LightBDD/LightBDD/issues/137","id":350909557,"node_id":"MDU6SXNzdWUzNTA5MDk1NTc=","number":137,"title":"Unable to specify absolute path to report location on Linux","user":{"login":"tillig","id":1156571,"node_id":"MDQ6VXNlcjExNTY1NzE=","avatar_url":"https://avatars2.githubusercontent.com/u/1156571?v=4","gravatar_id":"","url":"https://api.github.com/users/tillig","html_url":"https://github.com/tillig","followers_url":"https://api.github.com/users/tillig/followers","following_url":"https://api.github.com/users/tillig/following{/other_user}","gists_url":"https://api.github.com/users/tillig/gists{/gist_id}","starred_url":"https://api.github.com/users/tillig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tillig/subscriptions","organizations_url":"https://api.github.com/users/tillig/orgs","repos_url":"https://api.github.com/users/tillig/repos","events_url":"https://api.github.com/users/tillig/events{/privacy}","received_events_url":"https://api.github.com/users/tillig/received_events","type":"User","site_admin":false},"labels":[{"id":55392077,"node_id":"MDU6TGFiZWw1NTM5MjA3Nw==","url":"https://api.github.com/repos/LightBDD/LightBDD/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/LightBDD/LightBDD/milestones/11","html_url":"https://github.com/LightBDD/LightBDD/milestone/11","labels_url":"https://api.github.com/repos/LightBDD/LightBDD/milestones/11/labels","id":3530345,"node_id":"MDk6TWlsZXN0b25lMzUzMDM0NQ==","number":11,"title":"2.4.2","description":"","creator":{"login":"Suremaker","id":1894621,"node_id":"MDQ6VXNlcjE4OTQ2MjE=","avatar_url":"https://avatars3.githubusercontent.com/u/1894621?v=4","gravatar_id":"","url":"https://api.github.com/users/Suremaker","html_url":"https://github.com/Suremaker","followers_url":"https://api.github.com/users/Suremaker/followers","following_url":"https://api.github.com/users/Suremaker/following{/other_user}","gists_url":"https://api.github.com/users/Suremaker/gists{/gist_id}","starred_url":"https://api.github.com/users/Suremaker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Suremaker/subscriptions","organizations_url":"https://api.github.com/users/Suremaker/orgs","repos_url":"https://api.github.com/users/Suremaker/repos","events_url":"https://api.github.com/users/Suremaker/events{/privacy}","received_events_url":"https://api.github.com/users/Suremaker/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":4,"state":"open","created_at":"2018-07-29T12:32:26Z","updated_at":"2018-08-15T22:50:20Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2018-08-15T18:11:17Z","updated_at":"2018-08-15T22:50:20Z","closed_at":"2018-08-15T22:50:20Z","author_association":"NONE","body":"#### Description\r\nUsing .NET Core on Linux, I'm trying to use the ability to write reports by modifying `LightBddConfiguration` and specifying a report location. It looks like:\r\n\r\n```csharp\r\nconfiguration\r\n  .ReportWritersConfiguration()\r\n  .AddFileWriter<PlainTextReportFormatter>(\r\n    \"/out/{TestDateTimeUtc:yyyy-MM-dd-HH_mm_ss}_features.txt\")\r\n```\r\nIn doing that, it appeared that no reports at all were being generated. It was only after digging a bit that I found the reports were being generated... in the `bin/Debug/netcoreapp2.1/out` folder relative to my `.csproj`.\r\n\r\nHere's how that happens:\r\n\r\nWhen the [`ReportFileWriter` calculates the output path](https://github.com/LightBDD/LightBDD/blob/b2f4c1d886bba12f1998bafc64ebc356817eb354/src/LightBDD.Framework/Reporting/ReportFileWriter.cs#L51) it calls `ReportPathFormatter.ToFormattablePath` which [uses the `FilePathHelper`](https://github.com/LightBDD/LightBDD/blob/b2f4c1d886bba12f1998bafc64ebc356817eb354/src/LightBDD.Framework/Reporting/ReportPathFormatter.cs#L67) to [resolve the absolute path](https://github.com/LightBDD/LightBDD/blob/b2f4c1d886bba12f1998bafc64ebc356817eb354/src/LightBDD.Framework/Reporting/Implementation/FilePathHelper.cs#L8) for the report file.\r\n\r\nHowever, the logic in there in attempting to resolve the absolute path [does some directory combining with trimming of path characters](https://github.com/LightBDD/LightBDD/blob/b2f4c1d886bba12f1998bafc64ebc356817eb354/src/LightBDD.Framework/Reporting/Implementation/FilePathHelper.cs#L29) that doesn't work on Linux.\r\n\r\nThe real key is in [`LightBDD.Framework.Reporting.Implementation.FilePathHelper`](https://github.com/LightBDD/LightBDD/blob/b2f4c1d886bba12f1998bafc64ebc356817eb354/src/LightBDD.Framework/Reporting/Implementation/FilePathHelper.cs), which is internal so I can't provide a unit test but I can walk through the issue.\r\n\r\n**On Windows** let's say the tests are running from `C:\\app\\tests` and you specify the output path for reporting as `C:\\logs\\report.txt`.\r\n  - `ReportFileWriter` constructor calls `ReportPathFormatter.ToFormattablePath(@\"C:\\logs\\report.txt\")`\r\n  - `ReportPathFormatter.ToFormattablePath` sees no parameters, so no replacement happens.\r\n  - `ReportPathFormatter.ToFormattablePath` calls `FilePathHelper.ResolveAbsolutePath(@\"C:\\logs\\report.txt\")`\r\n  - `FilePathHelper.ResolveAbsolutePath` skips the bit where the path starts with `~` and calls `FilePathHelper.Combine(@\"C:\\app\\tests\", @\"C:\\logs\\report.txt\")`.\r\n  - `FilePathHelper.Combine` returns (simplifying each step)...\r\n    - `Path.Combine(@\"C:\\app\\tests\".TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar), @\"C:\\logs\\report.txt\".TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar))`\r\n    - `Path.Combine(@\"C:\\app\\tests\".TrimEnd('\\\\', '/'), @\"C:\\logs\\report.txt\".TrimStart('\\\\', '/'))`\r\n    - `Path.Combine(@\"C:\\app\\tests\", @\"C:\\logs\\report.txt\")`\r\n    - `@\"C:\\logs\\report.txt\"`\r\n\r\nSo, on Windows, specifying an absolute path works great. However...\r\n\r\n**On Linux** let's say the tests are running from `/app/tests` and you specify the output path for reporting as `/logs/report.txt`.\r\n  - `ReportFileWriter` constructor calls `ReportPathFormatter.ToFormattablePath(\"/logs/report.txt\")`\r\n  - `ReportPathFormatter.ToFormattablePath` sees no parameters, so no replacement happens.\r\n  - `ReportPathFormatter.ToFormattablePath` calls `FilePathHelper.ResolveAbsolutePath(\"/logs/report.txt\")`\r\n  - `FilePathHelper.ResolveAbsolutePath` skips the bit where the path starts with `~` and calls `FilePathHelper.Combine(\"/app/tests\", \"/logs/report.txt\")`.\r\n  - `FilePathHelper.Combine` returns (simplifying each step)...\r\n    - `Path.Combine(\"/app/tests\".TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar), \"/logs/report.txt\".TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar))`\r\n    - `Path.Combine(\"/app/tests\".TrimEnd('/', '\\\\'), \"/logs/report.txt\".TrimStart('/', '\\\\'))`\r\n    - `Path.Combine(\"/app/tests\", \"logs/report.txt\")`\r\n    - `\"/app/tests/logs/report.txt\"`\r\n\r\nUh oh! By trimming the leading directory separators on the subpath it breaks the ability for Linux to specify an absolute location where reports can be written.\r\n\r\n#### Progress\r\n<!-- This section should be updated during development, not reporting an issue. Add more steps as needed. -->\r\n- [x] Feature is implemented,\r\n- [ ] Ensured backward-compatibility,\r\n- [ ] Ensured good debugging experience"}}
{"actor":{"display_login":"Suremaker"}}