Skip to content

Commit

Permalink
Add cargo test validation before generating snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
yiwiy9 committed Sep 23, 2023
1 parent dba9471 commit cf8ca5e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .devcontainer/cargo_snippet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
# Navigate to the lib directory within the workspace folder
cd $WORKSPACE_FOLDER/src/lib

# Run the tests silently. Exit with an error if tests fail.
if ! cargo test &>/dev/null; then
echo "Error: Tests failed."
exit 1
fi

# Generate Rust code snippets using cargo-snippet, then modify the output using sed to add a scope for Rust,
# and finally, save the modified output to a rust.code-snippets file in the .vscode directory of the workspace folder
cargo snippet -t vscode | sed -r "s/\"prefix\"/\"scope\": \"rust\",\n \"prefix\"/" > $WORKSPACE_FOLDER/.vscode/rust.code-snippets
echo "Snippets generated."

0 comments on commit cf8ca5e

Please sign in to comment.