Skip to content

Commit 0510a72

Browse files
committed
control which tests run with a command line parameter
1 parent 6eaf996 commit 0510a72

File tree

4 files changed

+48
-27
lines changed

4 files changed

+48
-27
lines changed

.evergreen/functions.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,14 +700,17 @@ functions:
700700
if [[ "$IS_WINDOWS" == "true" ]]; then
701701
# TODO: windows_setup
702702
# TODO: windows_msi
703-
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=windows_zip
703+
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=windows_zip --tests=auto-update-from
704704
fi
705705
706706
if [[ "$IS_OSX" == "true" ]]; then
707707
echo "Disabling clipboard usage in e2e tests (TODO: https://jira.mongodb.org/browse/BUILD-14780)"
708708
export COMPASS_E2E_DISABLE_CLIPBOARD_USAGE="true"
709-
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=osx_zip
710-
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=osx_dmg
709+
# NOTE: We're also skipping auto-update of the macOS app in CI
710+
# because it doesn't work. Running a different test to make sure it
711+
# can install and run successfully at least.
712+
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=osx_zip --tests=time-to-first-query
713+
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=osx_dmg --tests=time-to-first-query
711714
fi
712715
713716
#if [[ "$IS_UBUNTU" == "true" ]]; then

packages/compass-e2e-tests/tests/auto-update.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function wait(ms: number) {
1414

1515
describe('Auto-update', function () {
1616
it('auto-update from', async function () {
17-
if (process.env.TEST_NAME !== 'AUTO_UPDATE_FROM') {
17+
if (process.env.TEST_NAME !== 'auto-update-from') {
1818
// we don't want this test to execute along with all the others under
1919
// normal circumstances because it is destructive - it overwrites Compass
2020
// itself

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

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import { installWindowsZIP } from './installers/windows-zip';
2626
const SUPPORTED_PLATFORMS = ['win32', 'darwin', 'linux'] as const;
2727
const SUPPORTED_ARCHS = ['x64', 'arm64'] as const;
2828

29+
const SUPPORTED_TESTS = ['time-to-first-query', 'auto-update-from'] as const;
30+
2931
function isSupportedPlatform(
3032
value: unknown
3133
): value is typeof SUPPORTED_PLATFORMS[number] {
@@ -100,7 +102,14 @@ const argv = yargs(hideBin(process.argv))
100102
.option('localPackage', {
101103
type: 'boolean',
102104
description: 'Use the local package instead of downloading',
103-
});
105+
})
106+
.option('tests', {
107+
type: 'string',
108+
choices: SUPPORTED_TESTS,
109+
description: 'Which tests to run',
110+
})
111+
.array('tests')
112+
.default('tests', []);
104113

105114
type TestSubject = PackageDetails & {
106115
filepath: string;
@@ -178,6 +187,7 @@ async function run() {
178187
'platform',
179188
'arch',
180189
'package',
190+
'tests',
181191
])
182192
);
183193

@@ -187,30 +197,37 @@ async function run() {
187197
const install = getInstaller(kind);
188198

189199
try {
190-
const { appPath, uninstall } = install({
191-
appName,
192-
filepath,
193-
destinationPath: context.sandboxPath,
194-
});
200+
if (context.tests.length === 0) {
201+
console.log('Warning: not performing any tests. Pass --tests.');
202+
}
203+
204+
for (const testName of context.tests) {
205+
const { appPath, uninstall } = install({
206+
appName,
207+
filepath,
208+
destinationPath: context.sandboxPath,
209+
});
195210

196-
try {
197-
if (context.platform === 'darwin' && process.env.CI) {
198-
// Auto-update does not work on mac in CI at the moment. So in that case
199-
// we just run the E2E tests to make sure the app at least starts up.
200-
runTimeToFirstQuery({
201-
appName,
202-
appPath,
203-
});
204-
} else {
205-
runUpdateTest({
206-
appName,
207-
appPath,
208-
autoUpdatable,
209-
testName: 'AUTO_UPDATE_FROM',
210-
});
211+
try {
212+
if (testName === 'time-to-first-query') {
213+
// Auto-update does not work on mac in CI at the moment. So in that case
214+
// we just run the E2E tests to make sure the app at least starts up.
215+
runTimeToFirstQuery({
216+
appName,
217+
appPath,
218+
});
219+
}
220+
if (testName === 'auto-update-from') {
221+
runUpdateTest({
222+
appName,
223+
appPath,
224+
autoUpdatable,
225+
testName,
226+
});
227+
}
228+
} finally {
229+
await uninstall();
211230
}
212-
} finally {
213-
await uninstall();
214231
}
215232
} finally {
216233
console.log('Cleaning up sandbox');

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ export type SmokeTestsContext = {
99
forceDownload?: boolean;
1010
localPackage?: boolean;
1111
sandboxPath: string;
12+
tests: string[];
1213
};

0 commit comments

Comments
 (0)