mirror of
https://github.com/lunchcat/sif.git
synced 2026-06-12 19:11:25 -07:00
af0167859a
- git.go and dork.go appended to a shared results slice from every worker goroutine with no mutex - a real race that -race never caught since neither has a test. guard the appends like dirlist/dnslist already do. - progress.go's non-tty milestone path divided by total with no guard, so a zero-total bar panicked when output was piped/redirected. bail early on total <= 0 to match the tty branch, and add an output test for it.
35 lines
1.6 KiB
Go
35 lines
1.6 KiB
Go
/*
|
|
·━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━·
|
|
: :
|
|
: █▀ █ █▀▀ · Blazing-fast pentesting suite :
|
|
: ▄█ █ █▀ · BSD 3-Clause License :
|
|
: :
|
|
: (c) 2022-2026 vmfunc, xyzeva, :
|
|
: lunchcat alumni & contributors :
|
|
: :
|
|
·━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━·
|
|
*/
|
|
|
|
package output
|
|
|
|
import "testing"
|
|
|
|
// the non-tty milestone path divides current*100/total, so a zero-total bar
|
|
// used to panic with integer divide-by-zero when piped or redirected.
|
|
func TestProgressZeroTotalNoPanic(t *testing.T) {
|
|
p := NewProgress(0, "scanning")
|
|
p.Increment("item")
|
|
p.Set(0, "item")
|
|
p.Done()
|
|
}
|
|
|
|
func TestProgressCounts(t *testing.T) {
|
|
p := NewProgress(4, "scanning")
|
|
for i := 0; i < 4; i++ {
|
|
p.Increment("x")
|
|
}
|
|
if p.current != 4 {
|
|
t.Errorf("current = %d, want 4", p.current)
|
|
}
|
|
}
|