generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 17
Add sagemaker unit tests #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,60 @@ | ||
| # SageMaker Code Editor Unit Tests | ||
|
|
||
| This directory contains TypeScript unit tests that validate all patches applied to the VSCode codebase. | ||
|
|
||
| ## Test Structure | ||
|
|
||
| Each patch file in `patches/series` has a corresponding test file: | ||
|
|
||
| - `sagemaker-extension.test.ts` - Validates sagemaker-extension.diff patch | ||
| - `disable-online-services.test.ts` - Validates disable-online-services.diff patch | ||
| - `disable-telemetry.test.ts` - Validates disable-telemetry.diff patch | ||
| - `update-csp.test.ts` - Validates update-csp.diff patch | ||
| - `webview.test.ts` - Validates webview.diff patch | ||
| - `local-storage.test.ts` - Validates local-storage.diff patch | ||
| - `sagemaker-integration.test.ts` - Validates sagemaker-integration.diff patch | ||
| - `license.test.ts` - Validates license.diff patch | ||
| - `base-path-compatibility.test.ts` - Validates base-path-compatibility.diff patch | ||
| - `sagemaker-idle-extension.test.ts` - Validates sagemaker-idle-extension.patch | ||
| - `terminal-crash-mitigation.test.ts` - Validates terminal-crash-mitigation.patch | ||
| - `sagemaker-open-notebook-extension.test.ts` - Validates sagemaker-open-notebook-extension.patch | ||
| - `sagemaker-ui-dark-theme.test.ts` - Validates sagemaker-ui-dark-theme.patch | ||
| - `sagemaker-ui-post-startup.test.ts` - Validates sagemaker-ui-post-startup.patch | ||
| - `sagemaker-extension-smus-support.test.ts` - Validates sagemaker-extension-smus-support.patch | ||
| - `post-startup-notifications.test.ts` - Validates post-startup-notifications.patch | ||
| - `sagemaker-extensions-sync.test.ts` - Validates sagemaker-extensions-sync.patch | ||
| - `custom-extensions-marketplace.test.ts` - Validates custom-extensions-marketplace.diff patch | ||
| - `signature-verification.test.ts` - Validates signature-verification.diff patch | ||
| - `display-language.test.ts` - Validates display-language.patch | ||
|
|
||
| **Total: 20 test files covering all patches in the series** | ||
|
|
||
| ## Running Tests | ||
|
|
||
| ### Locally | ||
| ```bash | ||
| ./scripts/run-unit-tests.sh | ||
| ``` | ||
|
|
||
| ### In CI | ||
| Tests run automatically on every push via GitHub Actions in `.github/workflows/ci.yml` | ||
|
|
||
| ## Test Framework | ||
|
|
||
| Tests use a simple Node.js-based framework defined in `test-framework.ts` with: | ||
| - `describe()` - Test suite grouping | ||
| - `test()` - Individual test cases | ||
|
|
||
| ## What Tests Validate | ||
|
|
||
| Tests check that: | ||
| 1. Patches are properly applied to `patched-vscode/` directory | ||
| 2. Expected code modifications exist in target files | ||
| 3. New files/directories are created where needed | ||
| 4. Configuration changes are present | ||
|
|
||
| ## Requirements | ||
|
|
||
| - Node.js 20+ | ||
| - TypeScript compiler (npx tsc) | ||
| - Patches must be applied (script handles this automatically) |
This file contains hidden or 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,37 @@ | ||
| import { readFileSync, existsSync } from 'fs'; | ||
| import { join } from 'path'; | ||
| import './test-framework'; | ||
|
|
||
| const PATCHED_VSCODE_DIR = join(process.cwd(), 'code-editor-src'); | ||
|
|
||
| describe('base-path-compatibility.diff validation', () => { | ||
| test('serverEnvironmentService.ts should have base-path option added', () => { | ||
| const filePath = join(PATCHED_VSCODE_DIR, 'src/vs/server/node/serverEnvironmentService.ts'); | ||
|
|
||
| if (!existsSync(filePath)) { | ||
| throw new Error(`File not found: ${filePath}`); | ||
| } | ||
|
|
||
| const content = readFileSync(filePath, 'utf8'); | ||
|
|
||
| // Check for base-path option in serverOptions | ||
| const basePathOption = "'base-path': { type: 'string' },"; | ||
| if (!content.includes(basePathOption)) { | ||
| throw new Error(`Expected base-path option not found in ${filePath}`); | ||
| } | ||
|
|
||
| // Check for base-path in ServerParsedArgs interface | ||
| const basePathArg = "'base-path'?: string,"; | ||
| if (!content.includes(basePathArg)) { | ||
| throw new Error(`Expected base-path argument type not found in ${filePath}`); | ||
| } | ||
|
|
||
| // Check for constructor modification | ||
| const constructorLogic = "if (args['base-path']) {\n\t\t\targs['server-base-path'] = args['base-path'];\n\t\t}"; | ||
| if (!content.includes(constructorLogic)) { | ||
| throw new Error(`Expected constructor base-path mapping not found in ${filePath}`); | ||
| } | ||
|
|
||
| console.log('PASS: Base path compatibility modifications found in serverEnvironmentService.ts'); | ||
| }); | ||
| }); |
This file contains hidden or 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,61 @@ | ||
| import { readFileSync, existsSync } from 'fs'; | ||
| import { join } from 'path'; | ||
| import './test-framework'; | ||
|
|
||
| const PATCHED_VSCODE_DIR = join(process.cwd(), 'code-editor-src'); | ||
|
|
||
| describe('custom-extensions-marketplace.diff validation', () => { | ||
| test('product.ts should have custom extensions gallery logic', () => { | ||
| const filePath = join(PATCHED_VSCODE_DIR, 'src/vs/platform/product/common/product.ts'); | ||
| const productPath = join(PATCHED_VSCODE_DIR, 'product.json'); | ||
| if (!existsSync(filePath)) { | ||
| throw new Error(`File not found: ${filePath}`); | ||
| } | ||
|
|
||
| const content = readFileSync(filePath, 'utf8'); | ||
| const productContent = readFileSync(productPath, 'utf8'); | ||
| // Check for custom extensions gallery environment variable check | ||
| const customGalleryCheck = "if (env['EXTENSIONS_GALLERY']) {"; | ||
| if (!content.includes(customGalleryCheck)) { | ||
| throw new Error(`Expected custom extensions gallery check not found in ${filePath}`); | ||
| } | ||
|
|
||
| // Check for custom gallery parsing log | ||
| const customGalleryLog = "console.log(`Custom extensions gallery detected. Parsing...`);"; | ||
| if (!content.includes(customGalleryLog)) { | ||
| throw new Error(`Expected custom gallery log not found in ${filePath}`); | ||
| } | ||
|
|
||
| // Check for default gallery log - not needed for Code Editor, reference patches/web-server/marketplace.diff and patches/common/integration.diff | ||
| // const defaultGalleryLog = "console.log(`Using default extensions gallery.`);"; | ||
| // if (!content.includes(defaultGalleryLog)) { | ||
| // throw new Error(`Expected default gallery log not found in ${filePath}`); | ||
| // } | ||
|
|
||
| // Check for open-vsx gallery configuration | ||
| const openVsxGallery = '"serviceUrl": "https://open-vsx.org/vscode/gallery",'; | ||
| if (!productContent.includes(openVsxGallery)) { | ||
| throw new Error(`Expected open-vsx gallery URL not found in ${productPath}`); | ||
| } | ||
|
|
||
| // Check for item URL | ||
| const itemUrl = '"itemUrl": "https://open-vsx.org/vscode/item",'; | ||
| if (!productContent.includes(itemUrl)) { | ||
| throw new Error(`Expected open-vsx item URL not found in ${productPath}`); | ||
| } | ||
|
|
||
| // Check for resource URL template | ||
| const resourceUrl = '"resourceUrlTemplate": "https://open-vsx.org/vscode/unpkg/{publisher}/{name}/{version}/{path}",'; | ||
| if (!productContent.includes(resourceUrl)) { | ||
| throw new Error(`Expected open-vsx resource URL template not found in ${productPath}`); | ||
| } | ||
|
|
||
| // Check for gallery logging | ||
| const galleryLogging = "console.log(JSON.stringify(product.extensionsGallery, null, 2));"; | ||
| if (!content.includes(galleryLogging)) { | ||
| throw new Error(`Expected gallery logging not found in ${filePath}`); | ||
| } | ||
|
|
||
| console.log('PASS: Custom extensions marketplace logic found in product.ts'); | ||
| }); | ||
| }); |
This file contains hidden or 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 { readFileSync, existsSync } from 'fs'; | ||
| import { join } from 'path'; | ||
| import './test-framework'; | ||
|
|
||
| const PATCHED_VSCODE_DIR = join(process.cwd(), 'code-editor-src'); | ||
|
|
||
| describe('disable-online-services.diff validation', () => { | ||
| test('update.config.contribution.ts should disable automatic updates', () => { | ||
| const filePath = join(PATCHED_VSCODE_DIR, 'src/vs/platform/update/common/update.config.contribution.ts'); | ||
|
|
||
| if (!existsSync(filePath)) { | ||
| throw new Error(`File not found: ${filePath}`); | ||
| } | ||
|
|
||
| const content = readFileSync(filePath, 'utf8'); | ||
|
|
||
| // Check update mode is set to none | ||
| const updateModeDefault = "default: 'none',"; | ||
| if (!content.includes(updateModeDefault)) { | ||
| throw new Error(`Expected update mode 'none' not found in ${filePath}`); | ||
| } | ||
|
|
||
| // Check release notes are disabled | ||
| const releaseNotesDefault = "default: false,"; | ||
| if (!content.includes(releaseNotesDefault)) { | ||
| throw new Error(`Expected release notes disabled not found in ${filePath}`); | ||
| } | ||
|
|
||
| console.log('PASS: Online services disabled in update configuration'); | ||
| }); | ||
| }); |
This file contains hidden or 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,73 @@ | ||
| import { readFileSync, existsSync } from 'fs'; | ||
| import { join } from 'path'; | ||
| import './test-framework'; | ||
|
|
||
| const PATCHED_VSCODE_DIR = join(process.cwd(), 'code-editor-src'); | ||
|
|
||
| describe('disable-telemetry.diff validation', () => { | ||
| test('telemetryService.ts should have telemetry disabled by default', () => { | ||
| const filePath = join(PATCHED_VSCODE_DIR, 'src/vs/platform/telemetry/common/telemetryService.ts'); | ||
|
|
||
| if (!existsSync(filePath)) { | ||
| throw new Error(`File not found: ${filePath}`); | ||
| } | ||
|
|
||
| const content = readFileSync(filePath, 'utf8'); | ||
|
|
||
| // Check that enum only contains OFF | ||
| const enumLine = "'enum': [TelemetryConfiguration.OFF],"; | ||
| if (!content.includes(enumLine)) { | ||
| throw new Error(`Expected telemetry enum restriction not found in ${filePath}`); | ||
| } | ||
|
|
||
| // Check that default is OFF | ||
| const defaultLine = "'default': TelemetryConfiguration.OFF,"; | ||
| if (!content.includes(defaultLine)) { | ||
| throw new Error(`Expected telemetry default OFF not found in ${filePath}`); | ||
| } | ||
|
|
||
| console.log('PASS: Telemetry disabled by default in telemetryService.ts'); | ||
| }); | ||
|
|
||
| test('desktop.contribution.ts should have crash reporter disabled', () => { | ||
| const filePath = join(PATCHED_VSCODE_DIR, 'src/vs/workbench/electron-sandbox/desktop.contribution.ts'); | ||
|
|
||
| if (!existsSync(filePath)) { | ||
| throw new Error(`File not found: ${filePath}`); | ||
| } | ||
|
|
||
| const content = readFileSync(filePath, 'utf8'); | ||
|
|
||
| // Check crash reporter is disabled | ||
| const crashReporterDisabled = "'default': false,"; | ||
| if (!content.includes(crashReporterDisabled)) { | ||
| throw new Error(`Expected crash reporter disabled not found in ${filePath}`); | ||
| } | ||
|
|
||
| console.log('PASS: Crash reporter disabled in desktop.contribution.ts'); | ||
| }); | ||
|
|
||
| test('1dsAppender.ts should have Microsoft endpoints blocked', () => { | ||
| const filePath = join(PATCHED_VSCODE_DIR, 'src/vs/platform/telemetry/common/1dsAppender.ts'); | ||
|
|
||
| if (!existsSync(filePath)) { | ||
| throw new Error(`File not found: ${filePath}`); | ||
| } | ||
|
|
||
| const content = readFileSync(filePath, 'utf8'); | ||
|
|
||
| // Check endpoints are redirected to 0.0.0.0 | ||
| const blockedEndpoint = "const endpointUrl = 'https://0.0.0.0/OneCollector/1.0';"; | ||
| const blockedHealthEndpoint = "const endpointHealthUrl = 'https://0.0.0.0/ping';"; | ||
|
|
||
| if (!content.includes(blockedEndpoint)) { | ||
| throw new Error(`Expected blocked endpoint not found in ${filePath}`); | ||
| } | ||
|
|
||
| if (!content.includes(blockedHealthEndpoint)) { | ||
| throw new Error(`Expected blocked health endpoint not found in ${filePath}`); | ||
| } | ||
|
|
||
| console.log('PASS: Microsoft telemetry endpoints blocked in 1dsAppender.ts'); | ||
| }); | ||
| }); |
This file contains hidden or 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 { readFileSync, existsSync } from 'fs'; | ||
| import { join } from 'path'; | ||
| import './test-framework'; | ||
|
|
||
| const PATCHED_VSCODE_DIR = join(process.cwd(), 'code-editor-src'); | ||
|
|
||
| describe('display-language.diff validation', () => { | ||
| test('remoteLanguagePacks.ts should have locale functions', () => { | ||
| const filePath = join(PATCHED_VSCODE_DIR, 'src/vs/server/node/remoteLanguagePacks.ts'); | ||
|
|
||
| if (!existsSync(filePath)) { | ||
| throw new Error(`File not found: ${filePath}`); | ||
| } | ||
|
|
||
| const content = readFileSync(filePath, 'utf8'); | ||
|
|
||
| if (!content.includes('export const getLocaleFromConfig') || | ||
| !content.includes('export async function getBrowserNLSConfiguration')) { | ||
| throw new Error(`Failed to find locale functions in ${filePath}`); | ||
| } | ||
|
|
||
| console.log('PASS: Locale functions found in remoteLanguagePacks.ts'); | ||
| }); | ||
|
|
||
| test('webClientServer.ts should use locale from args', () => { | ||
| const filePath = join(PATCHED_VSCODE_DIR, 'src/vs/server/node/webClientServer.ts'); | ||
|
|
||
| if (!existsSync(filePath)) { | ||
| throw new Error(`File not found: ${filePath}`); | ||
| } | ||
|
|
||
| const content = readFileSync(filePath, 'utf8'); | ||
|
|
||
| if (!content.includes('this._environmentService.args.locale')) { | ||
| throw new Error(`Failed to find locale from args in ${filePath}`); | ||
| } | ||
|
|
||
| console.log('PASS: Locale from args found in webClientServer.ts'); | ||
| }); | ||
|
|
||
| test('serverEnvironmentService.ts should have locale option', () => { | ||
| const filePath = join(PATCHED_VSCODE_DIR, 'src/vs/server/node/serverEnvironmentService.ts'); | ||
|
|
||
| if (!existsSync(filePath)) { | ||
| throw new Error(`File not found: ${filePath}`); | ||
| } | ||
|
|
||
| const content = readFileSync(filePath, 'utf8'); | ||
|
|
||
| if (!content.includes("'locale': { type: 'string' }")) { | ||
| throw new Error(`Failed to find locale option in ${filePath}`); | ||
| } | ||
|
|
||
| console.log('PASS: Locale option found in serverEnvironmentService.ts'); | ||
| }); | ||
|
|
||
| test('languagePacks.ts should use remote service', () => { | ||
| const filePath = join(PATCHED_VSCODE_DIR, 'src/vs/platform/languagePacks/browser/languagePacks.ts'); | ||
|
|
||
| if (!existsSync(filePath)) { | ||
| throw new Error(`File not found: ${filePath}`); | ||
| } | ||
|
|
||
| const content = readFileSync(filePath, 'utf8'); | ||
|
|
||
| if (!content.includes('ProxyChannel.toService<ILanguagePackService>')) { | ||
| throw new Error(`Failed to find ProxyChannel usage in ${filePath}`); | ||
| } | ||
|
|
||
| console.log('PASS: Remote language pack service found in languagePacks.ts'); | ||
| }); | ||
| }); |
This file contains hidden or 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,6 @@ | ||
| declare global { | ||
| function describe(name: string, fn: () => void): void; | ||
| function test(name: string, fn: () => void): void; | ||
| } | ||
|
|
||
| export {}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? What prompted adding this? Usually
package.jsonfiles are not ignoredThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When running
./scripts/run-sagemaker-unit-tests.shthepackage.jsonis generated, and for now we don't really need to store it, since the only dependency is@types/node, and the tests themselves are not a proper single project (the test files are just compiled one by one and run individually). If the unit tests are expanded in the future then we could add a properpackage.json.