Skip to content

Commit cf8ca5e

Browse files
committed
Add cargo test validation before generating snippets
1 parent dba9471 commit cf8ca5e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

.devcontainer/cargo_snippet.sh

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
# Navigate to the lib directory within the workspace folder
66
cd $WORKSPACE_FOLDER/src/lib
77

8+
# Run the tests silently. Exit with an error if tests fail.
9+
if ! cargo test &>/dev/null; then
10+
echo "Error: Tests failed."
11+
exit 1
12+
fi
13+
814
# Generate Rust code snippets using cargo-snippet, then modify the output using sed to add a scope for Rust,
915
# and finally, save the modified output to a rust.code-snippets file in the .vscode directory of the workspace folder
1016
cargo snippet -t vscode | sed -r "s/\"prefix\"/\"scope\": \"rust\",\n \"prefix\"/" > $WORKSPACE_FOLDER/.vscode/rust.code-snippets
17+
echo "Snippets generated."

0 commit comments

Comments
 (0)