Skip to content

Commit

Permalink
enable valgrind to check for mem leaks (nim-lang/Nim#24402)
Browse files Browse the repository at this point in the history
  • Loading branch information
lilkeet committed Nov 4, 2024
1 parent 4d13246 commit 4e771ac
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 10 deletions.
5 changes: 3 additions & 2 deletions tests/digraph/t0_fewnodes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ discard """
action: "run"
batchable: true
joinable: true
timeout: 2.0
timeout: 10.0
targets: "c cpp js objc"
matrix: "; -d:release; -d:danger"
valgrind: on
matrix: "-d:useMalloc"
"""

import
Expand Down
5 changes: 3 additions & 2 deletions tests/digraph/t1_manynodes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ discard """
action: "run"
batchable: true
joinable: true
timeout: 20.0
timeout: 40.0
targets: "c cpp js objc"
matrix: "; -d:release; -d:danger"
valgrind: on
matrix: "-d:useMalloc"
"""

import
Expand Down
31 changes: 29 additions & 2 deletions tests/digraph/t2_cycles.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ discard """
action: "run"
batchable: true
joinable: true
timeout: 2.0
timeout: 10.0
targets: "c cpp js objc"
matrix: "; -d:release; -d:danger"
valgrind: on
matrix: "-d:useMalloc"
"""

##[This test verifies that the cycle detection algorithms correctly identify
Expand Down Expand Up @@ -46,7 +47,33 @@ block simple:
doAssert myDig.hasTwoCycle(Kahns)
doAssert myDig.hasTwoCycle(PathBasedStrongComponent)

block loop:
var myDig = DiGraph[int]()
with myDig:
inclEdge 1, 2
inclEdge 2, 3
inclEdge 3, 4
inclEdge 4, 5

inclEdge 3, 5

inclEdge 10, 2

inclEdge 55, 2

# Verify that the graph currently has no cycles
doAssert not myDig.hasCycle
doAssert not myDig.hasLoop
doAssert not myDig.hasTwoCycle(Kahns)
doAssert not myDig.hasTwoCycle(PathBasedStrongComponent)

myDig.inclEdge 5, 5 # Add an edge from node 5 to node 5, creating a loop

# Verify that the graph now contains a cycle
doAssert myDig.hasCycle
doAssert not myDig.hasTwoCycle(Kahns)
doAssert not myDig.hasTwoCycle(PathBasedStrongComponent)
doAssert myDig.hasLoop

block complex:
var complexDigraph = DiGraph[int]()
Expand Down
3 changes: 2 additions & 1 deletion tests/digraph/t3_simpleIterators.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ discard """
joinable: true
timeout: 2.0
targets: "c cpp js objc"
matrix: "; -d:release; -d:danger"
valgrind: on
matrix: "-d:useMalloc"
"""

import
Expand Down
3 changes: 2 additions & 1 deletion tests/digraph/t4_walkFrom.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ discard """
joinable: true
timeout: 5.0
targets: "c cpp js objc"
matrix: "; -d:release; -d:danger"
valgrind: on
matrix: "-d:useMalloc"
"""

import
Expand Down
3 changes: 2 additions & 1 deletion tests/digraph/t5_properties.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ discard """
joinable: true
timeout: 5.0
targets: "c cpp js objc"
matrix: "; -d:release; -d:danger"
valgrind: on
matrix: "-d:useMalloc"
"""

import
Expand Down
3 changes: 2 additions & 1 deletion tests/unsafetables/tests.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ discard """
joinable: true
timeout: 2.0
targets: "c cpp js objc"
matrix: ""
valgrind: on
matrix: "-d:useMalloc"
"""

import
Expand Down

0 comments on commit 4e771ac

Please sign in to comment.