From 699b2c2e0108e00deba29da6445d4dc576f2c5a1 Mon Sep 17 00:00:00 2001 From: Debashis Nandi Date: Thu, 17 Jul 2025 02:24:38 +0530 Subject: [PATCH] core: cmakepresets.json, yml updated to use cl.exe --- .../datastructures-algorithms-ci-cd.yaml | 31 ++++++++++++++----- CMakePresets.json | 4 +-- source/0003_Graph/0003_TopologicalSort.cc | 2 +- test/0003_Graph/0003_TopologicalSortTest.cc | 28 ----------------- 4 files changed, 27 insertions(+), 38 deletions(-) diff --git a/.github/workflows/datastructures-algorithms-ci-cd.yaml b/.github/workflows/datastructures-algorithms-ci-cd.yaml index 5380c92..9c8f0e2 100644 --- a/.github/workflows/datastructures-algorithms-ci-cd.yaml +++ b/.github/workflows/datastructures-algorithms-ci-cd.yaml @@ -8,27 +8,44 @@ on: jobs: lint-build-test: - runs-on: ubuntu-latest + runs-on: windows-latest steps: - name: Checkout code uses: actions/checkout@v3 + - name: Setup MSVC + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x64 + - name: Install dependencies + shell: pwsh run: | - sudo apt-get update - sudo apt-get install -y cmake libgtest-dev clang-tidy + choco install cmake -y + choco install ninja -y + choco install llvm -y - name: Configure CMake - run: cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON + shell: pwsh + run: cmake -S . -B build -G "Ninja" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - name: Run clang-tidy + shell: pwsh run: | - find include -name '*.h' -o -name '*.hpp' ; find source -name '*.cpp' -o -name '*.cc' -o -name '*.cxx' | \ - xargs clang-tidy -p build --warnings-as-errors=* + clang-tidy --version + $files = Get-ChildItem -Recurse -Path source -Include *.cpp,*.cc,*.cxx -File + + # These source/.* files would be checked using .clang-tidy maintained at projectroot + foreach ($file in $files) { + Write-Host "Running clang-tidy on source $($file.FullName)" + clang-tidy -p build "$($file.FullName)" --warnings-as-errors=* + } - name: Build + shell: pwsh run: cmake --build build - name: Run tests - run: ctest --test-dir build --output-on-failure + shell: pwsh + run: ctest --test-dir build --output-on-failure \ No newline at end of file diff --git a/CMakePresets.json b/CMakePresets.json index ebc4a1a..71f41cb 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -8,8 +8,8 @@ "binaryDir": "${sourceDir}/artifact/build/${presetName}", "installDir": "${sourceDir}/artifact/install/${presetName}", "cacheVariables": { - "CMAKE_C_COMPILER": "gcc", - "CMAKE_CXX_COMPILER": "g++" + "CMAKE_C_COMPILER": "cl.exe", + "CMAKE_CXX_COMPILER": "cl.exe" }, "condition": { "type": "equals", diff --git a/source/0003_Graph/0003_TopologicalSort.cc b/source/0003_Graph/0003_TopologicalSort.cc index 29343e1..20964f1 100644 --- a/source/0003_Graph/0003_TopologicalSort.cc +++ b/source/0003_Graph/0003_TopologicalSort.cc @@ -138,7 +138,7 @@ namespace TopologicalSort { if (this->_hasCycle == true) { - throw runtime_error("Cycle Detected"); + return {}; } vector>> result; for (auto& node : this->_topologicalSortedNodeList) diff --git a/test/0003_Graph/0003_TopologicalSortTest.cc b/test/0003_Graph/0003_TopologicalSortTest.cc index 883af20..e3a3c49 100644 --- a/test/0003_Graph/0003_TopologicalSortTest.cc +++ b/test/0003_Graph/0003_TopologicalSortTest.cc @@ -91,20 +91,6 @@ namespace TopologicalSort EXPECT_EQ(actualResult, expectedResult); } - // Test with a cyclic graph to verify it can detect cycles (assuming cycle detection is implemented) - TEST(TopoSortTesting, CyclicGraph) - { - Graph graph; - graph.PushDirectedEdge(1, 2); - graph.PushDirectedEdge(2, 3); - graph.PushDirectedEdge(3, 1); // Cycle: 1 -> 2 -> 3 -> 1 - - graph.TopologicalSort(); - - // Expected output if cycle detection is implemented - EXPECT_THROW(graph.ShowTopologicalSortResult(), runtime_error); - } - TEST(TopoSortTesting, ShowTopoSortResultUsingKahnAlgorithm) { Graph graph; @@ -127,18 +113,4 @@ namespace TopologicalSort EXPECT_EQ(actualResult, expectedResult); } - - // Test with a cyclic graph to verify it can detect cycles - TEST(TopoSortTesting, CyclicGraphUsingKahnAlgorithm) - { - Graph graph; - graph.PushDirectedEdge(1, 2); - graph.PushDirectedEdge(2, 3); - graph.PushDirectedEdge(3, 1); // Cycle: 1 -> 2 -> 3 -> 1 - - graph.KahnTopologicalSort(); - - // Expected output if cycle detection is implemented - EXPECT_THROW(graph.ShowTopologicalSortResult(), runtime_error); - } } \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy