Skip to content
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

fix: make test paths Windows safe #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

refack
Copy link

@refack refack commented Jan 28, 2017

No description provided.

Copy link
Member

@alangpierce alangpierce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Some thoughts, and there's a test failure, but generally makes sense to me.


import getFilesUnderPath from '../src/util/getFilesUnderPath';

let originalCwd = process.cwd();

async function mkdTempSafe (prefix) {
let parts = normalize(prefix).split(sep);
// let last = parts.pop();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you left this line in by mistake?

@@ -52,10 +70,10 @@ async function assertFilesEqual(actualFile, expectedFile) {
* given example.
*/
async function runWithTemplateDir(exampleName, fn) {
let suffix = Math.floor(Math.random() * 1000000000000);
let newDir = `./test/tmp-projects/${exampleName}-${suffix}`;
let newDirPref = `./test/tmp-projects/${exampleName}/tmp-`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the whole word "prefix" instead of "pref"? In my mind, "pref" means "preference".

Also, looks like you added an extra level of nesting here, which is causing the test failure. I'd rather just keep the same nesting level as before (which also make makes it easier to potentially avoid mkdTempSafe), but I don't have a strong preference.


import getFilesUnderPath from '../src/util/getFilesUnderPath';

let originalCwd = process.cwd();

async function mkdTempSafe (prefix) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment explaining what safe means here? Looks like it's doing the equivalent of mkdir -p? You could probably also skip this by making sure the tmp-projects folder always exists. I think one way people do that is to commit an empty .gitkeep file in the directory (since git doesn't allow empty tracked directories).

throw e;
}
}
return await mkdtemp(prefix);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I hadn't seen mkdtemp. Does this fix anything for Windows, or is it just a more robust alternative to my manual random directory thing?

@@ -3,17 +3,35 @@ import 'babel-polyfill';

import assert from 'assert';
import { exec } from 'mz/child_process';
import { exists, readFile, writeFile } from 'mz/fs';
import { exists, readFile, writeFile, mkdtemp, mkdir } from 'mz/fs';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, looks like mkdtemp was introduced in node 5, and I'd like to support node 4, so probably best to stick with the old random number approach unless there's a problem with it.

@alangpierce
Copy link
Member

BTW, I was running into nodegit issues when setting up the build for https://github.com/decaffeinate/decaffeinate-examples . Turns out it doesn't build at all on node 7 ( nodegit/nodegit#1157 ). So that's more motivation to drop it as a dependency.

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.

2 participants