From 9edbe049aa4c4ba3b57fccc2d00dc10beadfcabd Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Tue, 31 May 2022 17:05:30 +0200 Subject: build: run integration tests in CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kristóf Marussy --- .../config/impl/__tests__/ConfigFile.integ.test.ts | 34 +++++++++++++--------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'packages/main/src') diff --git a/packages/main/src/infrastructure/config/impl/__tests__/ConfigFile.integ.test.ts b/packages/main/src/infrastructure/config/impl/__tests__/ConfigFile.integ.test.ts index dd4aaaa..c443d99 100644 --- a/packages/main/src/infrastructure/config/impl/__tests__/ConfigFile.integ.test.ts +++ b/packages/main/src/infrastructure/config/impl/__tests__/ConfigFile.integ.test.ts @@ -29,10 +29,11 @@ import { utimes, writeFile, } from 'node:fs/promises'; -import { tmpdir } from 'node:os'; +import { platform, tmpdir, userInfo } from 'node:os'; import path from 'node:path'; import { jest } from '@jest/globals'; +import { testIf } from '@sophie/test-utils'; import { mocked } from 'jest-mock'; import Disposer from '../../../../utils/Disposer.js'; @@ -249,19 +250,24 @@ describe('watchConfig', () => { expect(callback).toHaveBeenCalled(); }); - test('handles other filesystem errors', async () => { - const { mode } = await stat(userDataDir!); - await writeFile(configFilePath, 'Hi Mars!', 'utf8'); - // Remove permission to force a filesystem error. - // eslint-disable-next-line no-bitwise -- Compute reduced permissions. - await chmod(userDataDir!, mode & 0o666); - try { - await catchUpWithFilesystem(); - expect(callback).not.toHaveBeenCalled(); - } finally { - await chmod(userDataDir!, mode); - } - }); + // We can only cause a filesystem error by changing permissions if we run on a POSIX-like + // system and we aren't root (i.e., not in CI). + testIf(platform() !== 'win32' && userInfo().uid !== 0)( + 'handles other filesystem errors', + async () => { + const { mode } = await stat(userDataDir!); + await writeFile(configFilePath, 'Hi Mars!', 'utf8'); + // Remove permission to force a filesystem error. + // eslint-disable-next-line no-bitwise -- Compute reduced permissions. + await chmod(userDataDir!, mode & 0o666); + try { + await catchUpWithFilesystem(); + expect(callback).not.toHaveBeenCalled(); + } finally { + await chmod(userDataDir!, mode); + } + }, + ); test('does not notify when the modification date is prior to the last write', async () => { await repository.writeConfig('Hello World!'); -- cgit v1.2.3-54-g00ecf