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

test: create test files inside temp directory #1150

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions test/mkdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,18 @@ test('try to make a subdirectory of a file', t => {
test('Check for invalid permissions', t => {
utils.skipOnWin(t, () => {
// This test case only works on unix, but should work on Windows as well
const dirName = 'nowritedir';
const dirName = `${t.context.tmp}/nowritedir`;
shell.mkdir(dirName);
t.falsy(shell.error());
shell.chmod('-w', dirName);
const result = shell.mkdir(dirName + '/foo');
t.is(result.code, 1);
t.is(
result.stderr,
'mkdir: cannot create directory nowritedir/foo: Permission denied'
`mkdir: cannot create directory ${t.context.tmp}/nowritedir/foo: Permission denied`
);
t.truthy(shell.error());
t.falsy(fs.existsSync(dirName + '/foo'));
shell.rm('-rf', dirName); // clean up
});
});

Expand Down Expand Up @@ -142,7 +141,6 @@ test('-p flag', t => {
t.falsy(shell.error());
t.is(result.code, 0);
t.truthy(fs.existsSync(`${t.context.tmp}/a/b/c`));
shell.rm('-Rf', `${t.context.tmp}/a`); // revert
});

test('-p flag: multiple dirs', t => {
Expand Down
6 changes: 3 additions & 3 deletions test/touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ test('file array', t => {

test('touching broken link creates a new file', t => {
utils.skipOnWin(t, () => {
const result = shell.touch('test/resources/badlink');
shell.ln('-s', 'not_existed_file', `${t.context.tmp}/badlink2`);
const result = shell.touch(`${t.context.tmp}/badlink2`);
t.is(result.code, 0);
t.falsy(shell.error());
t.truthy(fs.existsSync('test/resources/not_existed_file'));
shell.rm('test/resources/not_existed_file');
t.truthy(fs.existsSync(`${t.context.tmp}/not_existed_file`));
});
});