Skip to content

Commit a238371

Browse files
committed
run the read-only test suite for read-only compass builds
1 parent b4cb693 commit a238371

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

packages/compass-smoke-tests/src/cli.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { SUPPORTED_TESTS } from './tests/types';
66
import { type SmokeTestsContext } from './context';
77
import { SUPPORTED_PACKAGES } from './packages';
88
import { testTimeToFirstQuery } from './tests/time-to-first-query';
9+
import { testReadOnly } from './tests/read-only';
910
import { testAutoUpdateFrom } from './tests/auto-update-from';
1011
import { testAutoUpdateTo } from './tests/auto-update-to';
1112

@@ -123,6 +124,8 @@ async function run() {
123124

124125
if (testName === 'time-to-first-query') {
125126
await testTimeToFirstQuery(context);
127+
} else if (testName === 'read-only') {
128+
await testReadOnly(context);
126129
} else if (testName === 'auto-update-from') {
127130
await testAutoUpdateFrom(context);
128131
} else if (testName === 'auto-update-to') {
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import fs from 'node:fs';
2+
import { type SmokeTestsContext } from '../context';
3+
import { execute } from '../execute';
4+
import { getInstaller } from '../installers';
5+
import { createSandbox } from '../directories';
6+
import { getTestSubject } from '../test-subject';
7+
8+
export async function testReadOnly(context: SmokeTestsContext) {
9+
const sandboxPath = createSandbox();
10+
const { kind, appName, filepath } = await getTestSubject({
11+
...context,
12+
sandboxPath,
13+
});
14+
15+
try {
16+
const install = getInstaller(kind);
17+
18+
const { appPath, uninstall } = install({
19+
appName,
20+
filepath,
21+
destinationPath: sandboxPath,
22+
});
23+
24+
try {
25+
execute(
26+
'npm',
27+
[
28+
'run',
29+
'--unsafe-perm',
30+
'test-packaged',
31+
'--workspace',
32+
'compass-e2e-tests',
33+
'--',
34+
'--test-filter=read-only',
35+
],
36+
{
37+
// We need to use a shell to get environment variables setup correctly
38+
shell: true,
39+
env: {
40+
...process.env,
41+
COMPASS_APP_NAME: appName,
42+
COMPASS_APP_PATH: appPath,
43+
},
44+
}
45+
);
46+
} finally {
47+
await uninstall();
48+
}
49+
} finally {
50+
if (context.skipCleanup) {
51+
console.log(`Skipped cleaning up sandbox: ${sandboxPath}`);
52+
} else {
53+
console.log(`Cleaning up sandbox: ${sandboxPath}`);
54+
fs.rmSync(sandboxPath, { recursive: true });
55+
}
56+
}
57+
}

packages/compass-smoke-tests/src/tests/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const SUPPORTED_TESTS = [
22
'time-to-first-query',
3+
'read-only',
34
'auto-update-from',
45
'auto-update-to',
56
] as const;

0 commit comments

Comments
 (0)