From 26a55e48a1745a876ed07093a5a936e73110816c Mon Sep 17 00:00:00 2001 From: DJ Schleen Date: Wed, 11 Sep 2024 00:09:19 +0000 Subject: [PATCH] chore: adds launch for smaller sbom, fixes test cases so they can be debugged and executed. --- .devcontainer/devcontainer.json | 2 +- .vscode/launch.json | 42 +++++++++++++++++++ test/cli.rs | 10 ----- .../_TESTDATA_/juiceshop.cyclonedx.json | 0 .../_TESTDATA_/railsgoat.cyclonedx.json | 0 .../_TESTDATA_/trustier.cyclonedx.json | 0 .../_TESTDATA_/trustier.small.cyclonedx.json | 0 tests/cli.rs | 13 ++++++ 8 files changed, 56 insertions(+), 11 deletions(-) delete mode 100644 test/cli.rs rename {test => tests}/_TESTDATA_/juiceshop.cyclonedx.json (100%) rename {test => tests}/_TESTDATA_/railsgoat.cyclonedx.json (100%) rename {test => tests}/_TESTDATA_/trustier.cyclonedx.json (100%) rename {test => tests}/_TESTDATA_/trustier.small.cyclonedx.json (100%) create mode 100644 tests/cli.rs diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ed083bb..e955bab 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,7 +17,7 @@ "editor.formatOnPaste": true, "git.autofetch": true, "[markdown]": { - "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.defaultFormatter": "esbenp.prettier-vscode" } }, "extensions": [ diff --git a/.vscode/launch.json b/.vscode/launch.json index b216ac6..404a599 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -168,6 +168,48 @@ "./test/_TESTDATA_/trustier.cyclonedx.json" ], "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug executable 'trustier' (trustier small SBOM), output to file", + "cargo": { + "args": [ + "build", + "--bin=trustier", + "--package=trustier" + ], + "filter": { + "name": "trustier", + "kind": "bin" + } + }, + "args": [ + "--output-file=output/trustier.json", + "./test/_TESTDATA_/trustier.small.cyclonedx.json" + ], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug unit tests in executable 'trustier' (trustier)", + "cargo": { + "args": [ + "test", + "--no-run", + "--bin=trustier", + "--package=trustier" + ], + "filter": { + "name": "trustier", + "kind": "bin" + } + }, + "args": [ + "./test/_TESTDATA_/trustier.small.cyclonedx.json" + ], + "cwd": "${workspaceFolder}" } ] } \ No newline at end of file diff --git a/test/cli.rs b/test/cli.rs deleted file mode 100644 index 8a6f3b4..0000000 --- a/test/cli.rs +++ /dev/null @@ -1,10 +0,0 @@ -use assert_cmd::Command; -use predicates::prelude::*; - -#[test] -fn dies_no_args() { - let mut cmd = Command::cargo_bin("trustier").unwrap(); - cmd.assert() - .failure() - .stderr(predicate::str::contains("USAGE")); -} diff --git a/test/_TESTDATA_/juiceshop.cyclonedx.json b/tests/_TESTDATA_/juiceshop.cyclonedx.json similarity index 100% rename from test/_TESTDATA_/juiceshop.cyclonedx.json rename to tests/_TESTDATA_/juiceshop.cyclonedx.json diff --git a/test/_TESTDATA_/railsgoat.cyclonedx.json b/tests/_TESTDATA_/railsgoat.cyclonedx.json similarity index 100% rename from test/_TESTDATA_/railsgoat.cyclonedx.json rename to tests/_TESTDATA_/railsgoat.cyclonedx.json diff --git a/test/_TESTDATA_/trustier.cyclonedx.json b/tests/_TESTDATA_/trustier.cyclonedx.json similarity index 100% rename from test/_TESTDATA_/trustier.cyclonedx.json rename to tests/_TESTDATA_/trustier.cyclonedx.json diff --git a/test/_TESTDATA_/trustier.small.cyclonedx.json b/tests/_TESTDATA_/trustier.small.cyclonedx.json similarity index 100% rename from test/_TESTDATA_/trustier.small.cyclonedx.json rename to tests/_TESTDATA_/trustier.small.cyclonedx.json diff --git a/tests/cli.rs b/tests/cli.rs new file mode 100644 index 0000000..4b9451b --- /dev/null +++ b/tests/cli.rs @@ -0,0 +1,13 @@ + +use anyhow::{Ok, Result}; +use assert_cmd::Command; +use predicates::prelude::*; + +#[test] +fn dies_no_args() -> Result<()> { + let mut cmd = Command::cargo_bin("trustier")?; + cmd.assert() + .failure() + .stderr(predicate::str::contains("Usage")); + Ok(()) +} \ No newline at end of file