Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a8e63c8

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
test: relax accessible sketch path test condition
- Do not expect `EACCESS` on Linux. - Run the test only if `EACCESS` occurs via the `stat` syscall. Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 0b2410d commit a8e63c8

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

‎arduino-ide-extension/src/test/node/sketches-service-impl.slow-test.ts‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { isWindows } from '@theia/core/lib/common/os';
66
import { FileUri } from '@theia/core/lib/node/file-uri';
77
import { Container } from '@theia/core/shared/inversify';
88
import { expect } from 'chai';
9-
import { rejects } from 'node:assert/strict';
109
import { promises as fs } from 'node:fs';
1110
import { basename, join } from 'node:path';
1211
import { sync as rimrafSync } from 'rimraf';
@@ -67,19 +66,30 @@ describe('isAccessibleSketchPath', () => {
6766
expect(actual).to.be.equal(aSketchFilePath);
6867
});
6968

70-
it('should ignore EACCESS (non-Windows)', async function () {
71-
if (isWindows) {
72-
// `stat` syscall does not result in an EACCESS on Windows after stripping the file permissions.
73-
// an `open` syscall would, but IDE2 on purpose does not check the files.
74-
// the sketch files are provided by the CLI after loading the sketch.
75-
return this.skip();
76-
}
69+
it('should ignore EACCESS', async function () {
7770
const sketchFolderPath = join(testDirPath, 'my_sketch');
7871
const mainSketchFilePath = join(sketchFolderPath, 'my_sketch.ino');
7972
await fs.mkdir(sketchFolderPath, { recursive: true });
8073
await fs.writeFile(mainSketchFilePath, '', { encoding: 'utf8' });
8174
await fs.chmod(mainSketchFilePath, 0o000); // remove all permissions
82-
await rejects(fs.readFile(mainSketchFilePath), ErrnoException.isEACCES);
75+
try {
76+
await fs.readFile(mainSketchFilePath);
77+
// If reading the file without sufficient permissions does not result in EACCESS error, do not run the test.
78+
// For example, a `stat` syscall does not result in an EACCESS on Windows after stripping the file permissions.
79+
// an `open` syscall would, but IDE2 on purpose does not check the files.
80+
// the sketch files are provided by the CLI after loading the sketch.
81+
console.info(
82+
'Skip. Reading the file content without permissions was successful.'
83+
);
84+
return this.skip();
85+
} catch (err) {
86+
expect(
87+
ErrnoException.isEACCES(err),
88+
`Expected an error with EACCES code. Got: ${
89+
typeof err === 'object' ? JSON.stringify(err) : err
90+
}`
91+
).to.be.true;
92+
}
8393
const actual = await isAccessibleSketchPath(sketchFolderPath);
8494
expect(actual).to.be.equal(mainSketchFilePath);
8595
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /