Skip to content

Commit 3016b3b

Browse files
EzioLi01EzioLi1123
andauthored
Package the latest version of extension for smoke test (#2405)
* Package the latest version of extension for smoke test * Update * Update * Update * Update * Update * Update * Update * Update * Update --------- Co-authored-by: EzioLi <[email protected]>
1 parent ac1f930 commit 3016b3b

File tree

11 files changed

+141
-41
lines changed

11 files changed

+141
-41
lines changed

.ci/common-validation.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
steps:
22
- task: NodeTool@0
3-
displayName: "Use Node 18.x"
3+
displayName: "Use Node 20.x"
44
inputs:
5-
versionSpec: 18.x
6-
- bash: npm install gulp react-devtools @vscode/vsce -g --force
7-
displayName: "npm install gulp react-devtools @vscode/vsce -g"
5+
versionSpec: 20.x
6+
- bash: npm install gulp @vscode/vsce -g --force
7+
displayName: "npm install gulp @vscode/vsce -g"
88
- bash: npm ci
99
displayName: "npm ci"
10+
- bash: gulp
11+
displayName: "gulp"
1012
- bash: npm run build
1113
displayName: "npm run build"
1214
- bash: |

.ci/smoke-tests-common-validation.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
steps:
2+
- script: gulp release --nightly --no-yarn --no-prepublish
3+
displayName: "gulp release"
4+
- task: CopyFiles@2
5+
displayName: "Copy Files to: $(Build.ArtifactStagingDirectory)"
6+
inputs:
7+
Contents: |
8+
$(System.DefaultWorkingDirectory)/*.vsix
9+
TargetFolder: "$(System.DefaultWorkingDirectory)/test/smoke/resources/extension"
210
- bash: npm run prepare-smoke-tests
311
displayName: "Prepare smoke tests"
412
- bash: npm run smoke-tests --verbose
@@ -8,6 +16,6 @@ steps:
816
- task: PublishBuildArtifacts@1
917
displayName: "Publish screenshots"
1018
inputs:
11-
PathtoPublish: '$(System.DefaultWorkingDirectory)/test/smoke/screenshots'
19+
PathtoPublish: "$(System.DefaultWorkingDirectory)/test/smoke/screenshots"
1220
ArtifactName: 'smoke-test-screenshots'
1321
publishLocation: 'Container'

gulp_scripts/cleaner.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const del = require("del");
2+
const GulpExtras = require("../tools/gulp-extras");
23

3-
function clean() {
4+
async function clean() {
45
const pathsToDelete = [
56
"src/**/*.js",
67
"src/**/*.js.map",
@@ -14,7 +15,17 @@ function clean() {
1415
"nls.*.json",
1516
"!test/smoke/**/*",
1617
];
17-
return del(pathsToDelete, { force: true });
18+
19+
const TIMEOUT_MS = 5000;
20+
21+
return await GulpExtras.withTimeout(
22+
del(pathsToDelete, { force: true }),
23+
TIMEOUT_MS,
24+
{
25+
onTimeout: () => console.log("Timeout for clean up, will try on next step, but may cause other failures."),
26+
fallbackValue: [],
27+
}
28+
);
1829
}
1930

2031
module.exports = {

gulp_scripts/release.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const GulpExtras = require("../tools/gulp-extras");
77

88
const isNightly = process.argv.includes("--nightly");
99
const useNpm = process.argv.includes("--no-yarn");
10+
const isPrepublish = process.argv.includes("--no-prepublish");
1011
const extensionName = isNightly ? "vscode-react-native-preview" : "vscode-react-native";
1112
const executeCommand = GulpExtras.executeCommand;
1213

@@ -46,6 +47,13 @@ function prepareLicenses() {
4647
.then(() => {
4748
let packageJson = readJson("/package.json");
4849
packageJson.main = "/dist/rn-extension";
50+
51+
if (isPrepublish) {
52+
log("Ignore vscode:prepublish script before vsce package");
53+
const scripts = packageJson.scripts;
54+
delete scripts["vscode:prepublish"];
55+
}
56+
4957
if (isNightly) {
5058
log("Performing gulp release...");
5159
packageJson.version = getVersionNumber();

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
],
3131
"activationEvents": [
3232
"workspaceContains:node_modules/react-native",
33+
"workspaceContains:metro.config.js",
3334
"onDebugResolve:reactnative",
3435
"onDebugResolve:reactnativedirect",
3536
"onDebugDynamicConfigurations:reactnative",
-4.78 MB
Binary file not shown.

test/smoke/suites/commands.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function startCommandPaletteTests(): void {
2929
it("Verify react native command is visible in command palette", async () => {
3030
await initApp();
3131
const page = app.getMainPage();
32+
3233
const cmdKey = process.platform === "darwin" ? "Meta" : "Control";
3334

3435
await page.keyboard.press(`${cmdKey}+Shift+P`);
@@ -44,7 +45,7 @@ export function startCommandPaletteTests(): void {
4445
try {
4546
assert.ok(value?.includes("React Native: Start Packager"));
4647
} catch {
47-
await screenshots.takeScreenshots("CommandVisibleTest");
48+
await screenshots.takeScreenshots("CommandPaletteTest", "VerifyCommandVisible");
4849
}
4950
});
5051
});

test/smoke/suites/helper/application.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ export class Application {
5959
SmokeTestLogger.info("Cannot clean up user data, will try it again in test setup.");
6060
}
6161

62+
try {
63+
await this.cleanExtensionData();
64+
} catch {
65+
SmokeTestLogger.info(
66+
"Cannot clean up extension data, will try it again in test setup.",
67+
);
68+
}
69+
6270
if (this.app) {
6371
await this.app.close();
6472
this.app = null;
@@ -76,7 +84,12 @@ export class Application {
7684

7785
extensionFile = path.join(this.vsixDirectory, extensionFile);
7886
args.push(`--install-extension=${extensionFile}`);
79-
utilities.spawnSync(cliPath, args, { stdio: "inherit", shell: true });
87+
88+
if (process.platform == "win32") {
89+
utilities.spawnSync(cliPath, args, { stdio: "inherit", shell: true });
90+
} else {
91+
utilities.spawnSync(cliPath, args, { stdio: "inherit" });
92+
}
8093

8194
this.extension = new Extension();
8295
return this.extension;
@@ -97,4 +110,11 @@ export class Application {
97110
rimraf.sync(this.userDataDirectory);
98111
}
99112
}
113+
114+
async cleanExtensionData(): Promise<void> {
115+
if (fs.existsSync(this.extensionDirectory)) {
116+
SmokeTestLogger.info(`*** Deleting VS Code extension dir: ${this.extensionDirectory}`);
117+
rimraf.sync(this.extensionDirectory);
118+
}
119+
}
100120
}

test/smoke/suites/helper/screenshot.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,34 @@ export class Screenshots {
77
private application = app;
88
private screenshotFolder = path.join(__dirname, "..", "..", "screenshots");
99

10-
async createScreenshotsFolder(): Promise<void> {
10+
async createScreenshotsFolder(platform: string): Promise<void> {
1111
if (!fs.existsSync(this.screenshotFolder)) {
12-
mkdirp.sync(this.screenshotFolder);
12+
mkdirp.sync(path.join(this.screenshotFolder, platform));
1313
}
1414
}
1515

16-
async takeScreenshots(fileName: string): Promise<void> {
17-
await this.createScreenshotsFolder();
16+
async prepareScreenshotFolderForPlatform(): Promise<string> {
17+
switch (process.platform) {
18+
case "win32":
19+
await this.createScreenshotsFolder("windows");
20+
return "windows";
21+
case "linux":
22+
await this.createScreenshotsFolder("linux");
23+
return "linux";
24+
case "darwin":
25+
await this.createScreenshotsFolder("macos");
26+
return "macos";
27+
default:
28+
return "other";
29+
}
30+
}
31+
32+
async takeScreenshots(suiteName: string, fileName: string): Promise<void> {
33+
const platform = await this.prepareScreenshotFolderForPlatform();
1834

1935
const mainPage = this.application.getMainPage();
2036
await mainPage.screenshot({
21-
path: `screenshots/commandPaletteTest/${fileName}.jpg`,
37+
path: `screenshots/${platform}/${suiteName}/${fileName}.jpg`,
2238
fullPage: true,
2339
});
2440
}

test/smoke/suites/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ startSmokeTests(setUp, cleanUp);
1313
async function setUp(): Promise<void> {
1414
const vscodeExecutablePath = await app.downloadVSCodeExecutable();
1515
await app.cleanUserData();
16+
await app.cleanExtensionData();
1617
await app.installExtensionFromVSIX(vscodeExecutablePath);
17-
await screenshots.createScreenshotsFolder();
18+
await screenshots.prepareScreenshotFolderForPlatform();
1819
}
1920

2021
async function cleanUp(): Promise<void> {

0 commit comments

Comments
 (0)