Fix fiber/record-tests to work on windows (slash differences) #8796

Merged
merged 1 commit into from Jan 15, 2017

Projects

None yet

5 participants

@tomgasson
Contributor

Running record-tests on windows modifies the output due to slash incompatibility.

image

This change ensures the output is consistent across platforms which is required since the results are committed back to the repo.

Alternatively we could use slash to do this.

@tomgasson tomgasson Fix fiber/record-tests to work on windows (slash differences) b3c1909
- const file = path.relative(root, fileResult.testFilePath);
+ const filePath = path.relative(root, fileResult.testFilePath);
+ // on windows, we still want to output forward slashes
+ const unixFilePath = filePath.replace(/\\/g, '/');
@gaearon
gaearon Jan 14, 2017 Member

Can you use path.normalize() for this?

@tomgasson
tomgasson Jan 14, 2017 edited Contributor

No, that still uses windows slashes

path.normalize('C:\\temp\\\\foo\\bar\\..\\');
// Returns: 'C:\\temp\\foo\\'

https://nodejs.org/api/path.html#path_path_normalize_path

@gaearon
gaearon Jan 14, 2017 Member

Ah, you're right.

- const file = path.relative(root, fileResult.testFilePath);
+ const filePath = path.relative(root, fileResult.testFilePath);
+ // on windows, we still want to output forward slashes
+ const unixFilePath = filePath.replace(/\\/g, '/');
@gaearon
gaearon Jan 14, 2017 Member

Ah, you're right.

@gaearon
Member
gaearon commented Jan 14, 2017

Let's wait for Travis and if it passes, I'll merge.

@aweary aweary merged commit c776327 into facebook:master Jan 15, 2017

1 check passed

ci/circleci Your tests passed on CircleCI!
Details
@@ -106,12 +106,14 @@ function runJest(maxWorkers) {
function formatResults(runResults, predicate) {
const formatted = [];
runResults.testResults.forEach((fileResult) => {
- const file = path.relative(root, fileResult.testFilePath);
+ const filePath = path.relative(root, fileResult.testFilePath);
@SimenB
SimenB Jan 18, 2017 Contributor

Should be able to just do path.posix.relative here instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment