-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from disneystreaming/dfrancoeur/smithy-build
Read language-server coordinates from smithy-build.json
- Loading branch information
Showing
18 changed files
with
303 additions
and
328 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,11 @@ jobs: | |
- name: Build & test | ||
run: yarn ci | ||
|
||
- name: Run Integration tests | ||
uses: GabrielBB/[email protected] | ||
with: | ||
run: yarn test:it | ||
|
||
deploy: | ||
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v')) | ||
name: Publish | ||
|
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
node_modules | ||
*.vsix | ||
out/ | ||
.vscode-test |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
out/ | ||
node_modules/ | ||
.vscode/ | ||
.vscode-test/ |
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 |
---|---|---|
@@ -1,5 +1,16 @@ | ||
.vscode/** | ||
.github | ||
.gitignore | ||
.vscode-test/** | ||
out/test/** | ||
out/**/*.map | ||
src/** | ||
.vscode/** | ||
.yarnrc | ||
**/.eslintrc.json | ||
**/*.map | ||
**/*.ts | ||
**/tsconfig.json | ||
jest.config.js | ||
jest.e2e.config.js | ||
node_modules/** | ||
out/it/** | ||
out/tests/** | ||
src/** | ||
yarn.lock |
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,31 @@ | ||
import * as path from "path"; | ||
|
||
import { runTests } from "@vscode/test-electron"; | ||
|
||
async function main() { | ||
try { | ||
// The folder containing the Extension Manifest package.json | ||
// Passed to `--extensionDevelopmentPath` | ||
const extensionDevelopmentPath = path.resolve(__dirname, "../../"); | ||
|
||
// The path to test runner | ||
// Passed to --extensionTestsPath | ||
const extensionTestsPath = path.resolve(__dirname, "./suite/index"); | ||
|
||
// Download VS Code, unzip it and run the integration test | ||
await runTests({ | ||
// we use 1.53.0 rather than 1.43.0 because it's the first one | ||
// available to be downloaded. Latest also has the following issue: | ||
//https://github.com/microsoft/vscode/issues/148975 | ||
version: "1.53.0", | ||
extensionDevelopmentPath, | ||
extensionTestsPath, | ||
}); | ||
} catch (err) { | ||
console.error("Failed to run tests"); | ||
console.error(err); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main(); |
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,45 @@ | ||
import * as path from "path"; | ||
import { setTimeout } from "timers/promises"; | ||
import * as vscode from "vscode"; | ||
|
||
import { extensionId } from "./../../src/constants"; | ||
|
||
const testTimeout = 20 * 1000; | ||
|
||
test( | ||
"Sample test", | ||
() => { | ||
const file = path.join(process.cwd(), "it/suite/weather.smithy"); | ||
// this activates the extension | ||
const openSmithyFile = vscode.workspace.openTextDocument( | ||
vscode.Uri.file(file) | ||
); | ||
|
||
return openSmithyFile | ||
.then(() => waitActive(timeout(testTimeout))) | ||
.then((active) => expect(active).toBeTruthy()); | ||
}, | ||
testTimeout + 1000 | ||
); | ||
|
||
function getExt(): vscode.Extension<any> { | ||
return vscode.extensions.getExtension(extensionId); | ||
} | ||
|
||
function timeout(ms: number): number { | ||
return Date.now() + ms; | ||
} | ||
|
||
function waitActive(expired: number): Promise<boolean> { | ||
const ext = getExt(); | ||
const isActive = ext ? ext.isActive : false; | ||
if (isActive) { | ||
return Promise.resolve(true); | ||
} else if (Date.now() > expired) { | ||
return Promise.resolve(false); | ||
} else { | ||
const delayMs = 1000; | ||
console.log(`Retrying active check in ${delayMs} ms.`); | ||
return setTimeout(1000).then(() => waitActive(expired)); | ||
} | ||
} |
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,40 @@ | ||
import { runCLI } from "jest"; | ||
|
||
interface ITestRunner { | ||
run(testsRoot: string, clb: (error?: Error, failures?: number) => void): void; | ||
} | ||
const path = require("path"); | ||
|
||
const jestTestRunnerForVSCodeE2E: ITestRunner = { | ||
run( | ||
testsRoot: string, | ||
reportTestResults: (error?: Error, failures?: number) => void | ||
): void { | ||
const projectRootPath = process.cwd(); | ||
const config = path.join(projectRootPath, "jest.e2e.config.js"); | ||
|
||
runCLI({ config } as any, [projectRootPath]) | ||
.then((jestCliCallResult) => { | ||
jestCliCallResult.results.testResults.forEach((testResult) => { | ||
testResult.testResults | ||
.filter((assertionResult) => assertionResult.status === "passed") | ||
.forEach(({ ancestorTitles, title, status }) => { | ||
console.info(` ● ${ancestorTitles} > ${title} (${status})`); | ||
}); | ||
}); | ||
|
||
jestCliCallResult.results.testResults.forEach((testResult) => { | ||
if (testResult.failureMessage) { | ||
console.error(testResult.failureMessage); | ||
} | ||
}); | ||
|
||
reportTestResults(undefined, jestCliCallResult.results.numFailedTests); | ||
}) | ||
.catch((errorCaughtByJestRunner) => { | ||
reportTestResults(errorCaughtByJestRunner, 0); | ||
}); | ||
}, | ||
}; | ||
|
||
module.exports = jestTestRunnerForVSCodeE2E; |
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,7 @@ | ||
namespace example.weather | ||
|
||
/// Provides weather forecasts. | ||
/// Triple slash comments attach documentation to shapes. | ||
service Weather { | ||
version: "2006-03-01" | ||
} |
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,21 @@ | ||
// see https://github.com/microsoft/vscode-test/issues/37#issuecomment-700167820 | ||
const NodeEnvironment = require("jest-environment-node"); | ||
const vscode = require("vscode"); | ||
|
||
class VsCodeEnvironment extends NodeEnvironment { | ||
async setup() { | ||
await super.setup(); | ||
this.global.vscode = vscode; | ||
} | ||
|
||
async teardown() { | ||
this.global.vscode = {}; | ||
await super.teardown(); | ||
} | ||
|
||
runScript(script) { | ||
return super.runScript(script); | ||
} | ||
} | ||
|
||
module.exports = VsCodeEnvironment; |
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,2 @@ | ||
// see https://github.com/microsoft/vscode-test/issues/37#issuecomment-700167820 | ||
module.exports = global.vscode; |
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,12 @@ | ||
// see https://github.com/microsoft/vscode-test/issues/37#issuecomment-700167820 | ||
const path = require("path"); | ||
|
||
module.exports = { | ||
moduleFileExtensions: ["js"], | ||
testMatch: ["<rootDir>/out/it/suite/**.test.js"], | ||
testEnvironment: "./it/vscode-environment.js", | ||
verbose: true, | ||
moduleNameMapper: { | ||
vscode: path.join(__dirname, "it", "vscode.js"), | ||
}, | ||
}; |
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 @@ | ||
export const extensionId = "disneystreaming.smithy"; |
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
Oops, something went wrong.