Skip to content

Commit a8f8532

Browse files
authored
Merge pull request #84 from Debashis08/feature-cl-compiler-update
core: cmakepresets.json, yml updated to use cl.exe
2 parents 1c21006 + 699b2c2 commit a8f8532

File tree

4 files changed

+27
-38
lines changed

4 files changed

+27
-38
lines changed

.github/workflows/datastructures-algorithms-ci-cd.yaml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,44 @@ on:
88

99
jobs:
1010
lint-build-test:
11-
runs-on: ubuntu-latest
11+
runs-on: windows-latest
1212

1313
steps:
1414
- name: Checkout code
1515
uses: actions/checkout@v3
1616

17+
- name: Setup MSVC
18+
uses: ilammy/msvc-dev-cmd@v1
19+
with:
20+
arch: x64
21+
1722
- name: Install dependencies
23+
shell: pwsh
1824
run: |
19-
sudo apt-get update
20-
sudo apt-get install -y cmake libgtest-dev clang-tidy
25+
choco install cmake -y
26+
choco install ninja -y
27+
choco install llvm -y
2128
2229
- name: Configure CMake
23-
run: cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
30+
shell: pwsh
31+
run: cmake -S . -B build -G "Ninja" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
2432

2533
- name: Run clang-tidy
34+
shell: pwsh
2635
run: |
27-
find include -name '*.h' -o -name '*.hpp' ; find source -name '*.cpp' -o -name '*.cc' -o -name '*.cxx' | \
28-
xargs clang-tidy -p build --warnings-as-errors=*
36+
clang-tidy --version
37+
$files = Get-ChildItem -Recurse -Path source -Include *.cpp,*.cc,*.cxx -File
38+
39+
# These source/.* files would be checked using .clang-tidy maintained at projectroot
40+
foreach ($file in $files) {
41+
Write-Host "Running clang-tidy on source $($file.FullName)"
42+
clang-tidy -p build "$($file.FullName)" --warnings-as-errors=*
43+
}
2944
3045
- name: Build
46+
shell: pwsh
3147
run: cmake --build build
3248

3349
- name: Run tests
34-
run: ctest --test-dir build --output-on-failure
50+
shell: pwsh
51+
run: ctest --test-dir build --output-on-failure

CMakePresets.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"binaryDir": "${sourceDir}/artifact/build/${presetName}",
99
"installDir": "${sourceDir}/artifact/install/${presetName}",
1010
"cacheVariables": {
11-
"CMAKE_C_COMPILER": "gcc",
12-
"CMAKE_CXX_COMPILER": "g++"
11+
"CMAKE_C_COMPILER": "cl.exe",
12+
"CMAKE_CXX_COMPILER": "cl.exe"
1313
},
1414
"condition": {
1515
"type": "equals",

source/0003_Graph/0003_TopologicalSort.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ namespace TopologicalSort
138138
{
139139
if (this->_hasCycle == true)
140140
{
141-
throw runtime_error("Cycle Detected");
141+
return {};
142142
}
143143
vector<pair<int, pair<int, int>>> result;
144144
for (auto& node : this->_topologicalSortedNodeList)

test/0003_Graph/0003_TopologicalSortTest.cc

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,6 @@ namespace TopologicalSort
9191
EXPECT_EQ(actualResult, expectedResult);
9292
}
9393

94-
// Test with a cyclic graph to verify it can detect cycles (assuming cycle detection is implemented)
95-
TEST(TopoSortTesting, CyclicGraph)
96-
{
97-
Graph graph;
98-
graph.PushDirectedEdge(1, 2);
99-
graph.PushDirectedEdge(2, 3);
100-
graph.PushDirectedEdge(3, 1); // Cycle: 1 -> 2 -> 3 -> 1
101-
102-
graph.TopologicalSort();
103-
104-
// Expected output if cycle detection is implemented
105-
EXPECT_THROW(graph.ShowTopologicalSortResult(), runtime_error);
106-
}
107-
10894
TEST(TopoSortTesting, ShowTopoSortResultUsingKahnAlgorithm)
10995
{
11096
Graph graph;
@@ -127,18 +113,4 @@ namespace TopologicalSort
127113

128114
EXPECT_EQ(actualResult, expectedResult);
129115
}
130-
131-
// Test with a cyclic graph to verify it can detect cycles
132-
TEST(TopoSortTesting, CyclicGraphUsingKahnAlgorithm)
133-
{
134-
Graph graph;
135-
graph.PushDirectedEdge(1, 2);
136-
graph.PushDirectedEdge(2, 3);
137-
graph.PushDirectedEdge(3, 1); // Cycle: 1 -> 2 -> 3 -> 1
138-
139-
graph.KahnTopologicalSort();
140-
141-
// Expected output if cycle detection is implemented
142-
EXPECT_THROW(graph.ShowTopologicalSortResult(), runtime_error);
143-
}
144116
}

0 commit comments

Comments
 (0)