From a614cdbf2700a7904a6b83a87107d4ddaf9e3a64 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 16 Sep 2021 03:30:47 -0500 Subject: [PATCH] feat: add cppcheck --- README.md | 2 +- src/cppcheck/__tests__/cppcheck.test.ts | 14 ++++++++++++++ src/cppcheck/cppcheck.ts | 20 ++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/cppcheck/__tests__/cppcheck.test.ts create mode 100644 src/cppcheck/cppcheck.ts diff --git a/README.md b/README.md index 2ac8b83a..327be75a 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,8 @@ The package will be usable from any environment (locally, GitHub Actions, etc). - [x] setup gcovr - [x] setup python - [x] setup msvc +- [x] setup cppcheck - [ ] setup gcc/mingw - [ ] setup OpenCppCoverage -- [ ] setup cppcheck - [ ] setup doxygen - [ ] setup vcpkg diff --git a/src/cppcheck/__tests__/cppcheck.test.ts b/src/cppcheck/__tests__/cppcheck.test.ts new file mode 100644 index 00000000..65cbc808 --- /dev/null +++ b/src/cppcheck/__tests__/cppcheck.test.ts @@ -0,0 +1,14 @@ +import { setupCppcheck } from "../cppcheck" +import { spawnSync as spawn } from "child_process" + +jest.setTimeout(200000) +describe("setup-cppcheck", () => { + it("should setup cppcheck", async () => { + await setupCppcheck() + + const { status } = spawn("cppcheck", ["--version"], { + encoding: "utf8", + }) + expect(status).toBe(0) + }) +}) diff --git a/src/cppcheck/cppcheck.ts b/src/cppcheck/cppcheck.ts new file mode 100644 index 00000000..b108e007 --- /dev/null +++ b/src/cppcheck/cppcheck.ts @@ -0,0 +1,20 @@ +import { setupAptPack } from "../utils/setup/setupAptPack" +import { setupBrewPack } from "../utils/setup/setupBrewPack" +import { setupChocoPack } from "../utils/setup/setupChocoPack" + +export function setupCppcheck(version?: string) { + switch (process.platform) { + case "win32": { + return setupChocoPack("cppcheck", version) + } + case "darwin": { + return setupBrewPack("cppcheck", version) + } + case "linux": { + return setupAptPack("cppcheck", version) + } + default: { + throw new Error(`Unsupported platform`) + } + } +}