Skip to content

Commit

Permalink
Ignore chmod test on windows
Browse files Browse the repository at this point in the history
As the underlying implementation of chmod is not tested on
windows, there is no reason to test this one as well.
  • Loading branch information
nkaradzhov committed Jan 7, 2025
1 parent 954424a commit 2251d73
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions ext/node/polyfills/internal/fs/handle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { EventEmitter } from "node:events";
import { Buffer } from "node:buffer";
import { promises, read, write } from "node:fs";
import { Mode, promises, read, write } from "node:fs";
export type { BigIntStats, Stats } from "ext:deno_node/_fs/_fs_stat.ts";
import {
BinaryOptionsArgument,
Expand Down Expand Up @@ -148,7 +148,7 @@ export class FileHandle extends EventEmitter {
stat(options?: { bigint: boolean }): Promise<Stats | BigIntStats> {
return fsCall(promises.fstat, this, options);
}
chmod(mode: number): Promise<void> {
chmod(mode: Mode): Promise<void> {
assertNotClosed(this, promises.chmod.name);
return promises.chmod(this.#path, mode);
}
Expand Down
30 changes: 17 additions & 13 deletions tests/unit_node/_fs/_fs_handle_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,20 @@ Deno.test(
},
);

Deno.test("[node/fs filehandle.chmod] Change the permissions of the file", async function () {
const fileHandle = await fs.open(testData);

const readOnly = 0o444;
await fileHandle.chmod(readOnly.toString(8));
assertEquals(Deno.statSync(testData).mode! & 0o777, readOnly);

const readWrite = 0o666;
await fileHandle.chmod(readWrite.toString(8));
assertEquals(Deno.statSync(testData).mode! & 0o777, readWrite);

await fileHandle.close();
});
Deno.test({
name: "[node/fs filehandle.chmod] Change the permissions of the file",
ignore: Deno.build.os === "windows",
async fn() {
const fileHandle = await fs.open(testData);

const readOnly = 0o444;
await fileHandle.chmod(readOnly.toString(8));
assertEquals(Deno.statSync(testData).mode! & 0o777, readOnly);

const readWrite = 0o666;
await fileHandle.chmod(readWrite.toString(8));
assertEquals(Deno.statSync(testData).mode! & 0o777, readWrite);

await fileHandle.close();
},
});

0 comments on commit 2251d73

Please sign in to comment.