Skip to content
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

Add "run test", "debug test" and support a hotkey for re-running the last test #57

Closed
wants to merge 21 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
out
node_modules
.vscode-test/
zig-cache
.DS_Store
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.DS_Store belongs in your global .gitignore.

*.vsix

31 changes: 14 additions & 17 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
{
"version": "0.1.0",
"configurations": [
{
"type": "extensionHost",
"request": "launch",
"name": "Launch Extension",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: watch"
}
]
}
"version": "0.1.0",
"configurations": [
{
"type": "extensionHost",
"request": "launch",
"name": "Launch Extension",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"internalConsoleOptions": "openOnSessionStart",

}
]
}
14 changes: 7 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
}
}
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
}
}
51 changes: 29 additions & 22 deletions language-configuration.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
{
"comments": {
"lineComment": "//"
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
"comments": {
"lineComment": "//",
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
{ "open": "{", "close": "}" },
{ "open": "[", "close": "]" },
{ "open": "(", "close": ")" },
{ "open": "'", "close": "'", "notIn": ["string", "comment"] },
{ "open": "\"", "close": "\"", "notIn": ["string"] },
],
"autoCloseBefore": ";:.,=}])>` \n\t",
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["'", "'"]
],

"onEnterRules": [
{
"beforeText": "^\\s*(?:def|for|while|if|else|switch).*?:\\s*$",
"action": { "indent": "indent" }
}
]
}
100 changes: 96 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"url": "https://github.com/zig-lang/vscode-zig"
},
"engines": {
"vscode": "^1.56.0"
"vscode": "^1.58.0"
},
"categories": [
"Programming Languages"
Expand All @@ -21,6 +21,60 @@
],
"main": "./out/extension",
"contributes": {
"snippets": [
{
"language": "zig",
"path": "./snippets.json"
}
],
"taskDefinitions": [
{
"type": "test",
"properties": {
"filter": {
"type": "string",
"description": "Test name to filter against"
},
"args": {
"type": "string",
"description": "Additional args to pass \"zig test\""
},
"file": {
"type": "string",
"description": "The file path to the zig source code to filter the test. Can be omitted."
},
"bin": {
"type": "string",
"description": "The file path to output the test to. Can be omitted."
}
}
},
{
"type": "debug",
"properties": {
"filter": {
"type": "string",
"description": "Test name to filter against"
},
"args": {
"type": "string",
"description": "Additional args to pass \"zig test\""
},
"file": {
"type": "string",
"description": "The file path to the zig source code to filter the test. Can be omitted."
},
"bin": {
"type": "string",
"description": "The file path to output the test to. Can be omitted."
},
"extraFiles": {
"type": "array",
"description": "Extra files to pass"
}
}
}
],
"languages": [
{
"id": "zig",
Expand Down Expand Up @@ -93,6 +147,29 @@
"default": null,
"description": "Set a custom path to the Zig binary. Defaults to 'zig' in your PATH."
},
"zig.testArgs": {
"type": "string",
"default": "",
"description": "Additional flags to pass \"zig test\""
},
"zig.testCmd": {
"type": "string",
"default": "",
"editPresentation": "multilineText",
"title": "Build Test Command",
"markdownDescription": "Custom command to build a test. Useful if you have non-Zig dependencies or multiple packages.\n\nVariables:\n\n- `${file}`\n- `${filter}`\n- `${bin}`\n\nExample:\n```\nzig build test ${file} --filter ${filter} --bin ${bin}```."
},
"zig.beforeDebugCmd": {
"type": "string",
"default": "",
"title": "Debug Test Command",
"markdownDescription": "Custom command to build a test for debugging. Useful if you have non-Zig dependencies or multiple packages.\n\nVariables:\n\n- `${file}`\n- `${filter}`\n- `${bin}`\n\ne.g.\n```\nzig build test-debug ${file} --filter ${filter} --bin ${bin}```"
},
"zig.disableProblemMatcherForTest": {
"type": "boolean",
"default": false,
"description": "Highlight lines where tests failed"
},
"zig.revealOutputChannelOnFormattingError": {
"type": "boolean",
"default": true,
Expand All @@ -105,25 +182,40 @@
"command": "zig.build.workspace",
"title": "Zig: Build Workspace",
"description": "Build the current project using 'zig build'"
},
{
"command": "zig.test.rerun",
"title": "Zig: Re-run last test",
"description": "Re-run the last test",
"enablement": "zig.hasLastTestCommand"
},
{
"command": "zig.test.rerun.debug",
"title": "Zig: Re-run last test with debugging",
"description": "Re-run the last test with debugging",
"enablement": "zig.hasLastTestCommand"
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "esbuild --bundle --sourcemap=external --minify --external:vscode src/extension.ts --outdir=out --platform=node --format=cjs",
"watch": "esbuild --watch --bundle --sourcemap=external --external:vscode src/extension.ts --outdir=out --platform=node --format=cjs",
"compile": "esbuild --bundle --sourcemap=external --minify --external:vscode src/extension.ts --outdir=out --platform=node --format=cjs",
"watch": "esbuild --watch --bundle --sourcemap=inline --external:vscode src/extension.ts --outdir=out --platform=node --format=cjs",
"test": "npm run compile && node ./node_modules/vscode/bin/test"
},
"devDependencies": {
"@types/js-yaml": "^4.0.3",
"@types/mocha": "^2.2.48",
"@types/node": "^15.6.0",
"@types/vscode": "^1.43.0",
"@types/vscode": "^1.58.0",
"vscode-test": "^1.4.0"
},
"dependencies": {
"esbuild": "^0.12.1",
"js-yaml": "^4.1.0",
"lodash-es": "^4.17.21",
"lodash.debounce": "^4.0.8",
"qs": "^6.10.1",
"vsce": "^1.88.0"
}
}
1 change: 1 addition & 0 deletions snippets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading