Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@

This extension requires:

- **[PostScript Language](https://marketplace.visualstudio.com/items?itemName=mxschmitt.postscript)** extension for syntax highlighting
- **[PostScript Language](https://marketplace.visualstudio.com/items?itemName=mxschmitt.postscript)** extension — required for the preview button to appear (it registers `.ps`/`.eps` files as PostScript, which this extension's preview button and activation depend on; it also provides syntax highlighting). Installed automatically alongside this extension.
- **GhostScript** (provides `ps2pdf`)
- **Poppler** (provides `pdftocairo` and `pdfinfo`)

> **No preview button?** If the preview icon does not appear in the editor title bar, your `.ps`/`.eps` file is likely opening as *Plain Text* (check the language indicator in the status bar). Make sure the [PostScript Language](https://marketplace.visualstudio.com/items?itemName=mxschmitt.postscript) extension is installed and enabled, then reload VS Code.

### macOS

```bash
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"activationEvents": [
"onLanguage:postscript"
],
"extensionDependencies": [
"mxschmitt.postscript"
],
"main": "./out/extension.js",
"contributes": {
"commands": [
Expand Down
63 changes: 60 additions & 3 deletions src/test/runTest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,56 @@
import * as cp from "child_process";
import * as fs from "fs";
import * as path from "path";
import { runTests } from "@vscode/test-electron";
import {
downloadAndUnzipVSCode,
resolveCliArgsFromVSCodeExecutablePath,
runTests,
} from "@vscode/test-electron";

const POSTSCRIPT_LANGUAGE_VSIX_URL =
"https://marketplace.visualstudio.com/_apis/public/gallery/publishers/mxschmitt/vsextensions/postscript/latest/vspackage";

/**
* This extension declares an extension dependency on mxschmitt.postscript
* (it registers the `postscript` language for .ps/.eps files), so the
* extension under test cannot activate unless that dependency is present in
* the test instance. Install it from a downloaded VSIX file: installing by id
* can fail in the test CLI when the marketplace signature verification
* tooling is unavailable ("Signature verification failed with 'ENOENT'").
*/
async function installPostscriptLanguageExtension(
vscodeExecutablePath: string
) {
const vsixPath = path.resolve(
__dirname,
"../../.vscode-test/mxschmitt.postscript.vsix"
);
const response = await fetch(POSTSCRIPT_LANGUAGE_VSIX_URL);
if (!response.ok) {
throw new Error(
`Failed to download PostScript Language extension: HTTP ${response.status}`
);
}
fs.mkdirSync(path.dirname(vsixPath), { recursive: true });
fs.writeFileSync(vsixPath, Buffer.from(await response.arrayBuffer()));

const [cliPath, ...cliArgs] =
resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath);
const result = cp.spawnSync(
cliPath,
[...cliArgs, "--install-extension", vsixPath],
{
encoding: "utf-8",
stdio: "inherit",
shell: process.platform === "win32",
}
);
if (result.status !== 0) {
throw new Error(
`Failed to install PostScript Language extension (exit code ${result.status})`
);
}
}

async function main() {
try {
Expand All @@ -11,14 +62,20 @@ async function main() {
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, "./suite/index");

// Download VS Code, unzip it and run the integration test
// Download VS Code and install the PostScript Language dependency
// into the test instance before running the tests.
const vscodeExecutablePath = await downloadAndUnzipVSCode();
await installPostscriptLanguageExtension(vscodeExecutablePath);

// Run the integration test
await runTests({
vscodeExecutablePath,
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: [extensionDevelopmentPath],
});
} catch (err) {
console.error("Failed to run tests");
console.error("Failed to run tests", err);
process.exit(1);
}
}
Expand Down