-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit-id:28a8da67
- Loading branch information
Showing
6 changed files
with
145 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { StatusBar, WebElement } from "vscode-extension-tester"; | ||
|
||
export async function getStatusBarItem(): Promise<WebElement | undefined> { | ||
const items = await new StatusBar().getItems(); | ||
|
||
for (const item of items) { | ||
try { | ||
// This can throw StaleElementReferenceError because item was destroyed before reading its text. | ||
const text = await item.getText(); | ||
|
||
if (text.startsWith("Cairo")) { | ||
return item; | ||
} | ||
} catch { | ||
// No need to do anything here. | ||
// If this was cairo status bar we will simply return after loop. | ||
// Else it is not interesting for us anyway. | ||
} | ||
} | ||
|
||
return undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { StatusBar, VSBrowser, Workbench } from "vscode-extension-tester"; | ||
import { expect } from "chai"; | ||
import * as path from "path"; | ||
import { getStatusBarItem } from "../../test-support/page-objects/cairoStatusBarItem"; | ||
import { homedir } from "os"; | ||
|
||
describe("Toolchain info", function () { | ||
this.timeout(50000); | ||
|
||
it("Checks correct scarb precedence", async function () { | ||
// asdf is in fact in PATH and in our tests it is first scarb in path, special case this. | ||
// It is caused by `@actions/core addPath` implementation. | ||
// See: https://github.com/actions/toolkit/blob/01f21badd5a7522507f84558503b56c4deec5326/packages/core/src/core.ts#L107 | ||
if (process.env.PATH_SCARB_VERSION && process.env.ASDF_SCARB_VERSION) { | ||
process.env.PATH_SCARB_VERSION = process.env.ASDF_SCARB_VERSION; | ||
} | ||
|
||
const scarbs = [ | ||
// Order is important here. | ||
process.env.CONFIG_SCARB_VERSION, | ||
process.env.PATH_SCARB_VERSION, | ||
process.env.ASDF_SCARB_VERSION, | ||
]; | ||
|
||
const expectedScarbVersion = scarbs.find(Boolean); // Find first with value. | ||
|
||
// Ignore this test locally, it is strictly designed for our CI. | ||
if (!expectedScarbVersion) { | ||
this.skip(); | ||
} | ||
|
||
if (process.env.CONFIG_SCARB_VERSION) { | ||
const workbench = new Workbench(); | ||
|
||
const settings = await workbench.openSettings(); | ||
|
||
const setting = await settings.findSetting("Scarb Path", "Cairo1"); | ||
|
||
setting.setValue(path.join(homedir(), ".local", "bin", "scarb")); | ||
} | ||
|
||
await VSBrowser.instance.openResources(path.join("ui-test", "fixtures", "empty")); | ||
|
||
const statusBar = await VSBrowser.instance.driver.wait(getStatusBarItem, 5000); | ||
|
||
expect(statusBar).to.not.be.undefined; | ||
|
||
const title = await statusBar!.getAttribute(StatusBar["locators"].StatusBar.itemTitle); | ||
|
||
const matches = | ||
/Cairo, (?:Cairo Language Server .+ \(.+\)\n)?Cairo Language\nscarb (.+) \(.+\)\ncairo: .+ \(.+\)\nsierra: .+/.exec( | ||
title, | ||
); | ||
|
||
expect(matches).to.not.be.undefined; | ||
|
||
const scarbVersion = matches![1]; | ||
|
||
expect(scarbVersion).to.be.eq(expectedScarbVersion); | ||
}); | ||
}); | ||
|
||
declare global { | ||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
namespace NodeJS { | ||
interface ProcessEnv { | ||
ASDF_SCARB_VERSION?: string; | ||
CONFIG_SCARB_VERSION?: string; | ||
PATH_SCARB_VERSION?: string; | ||
} | ||
} | ||
} |