Files
projectdiscovery-subfinder/pkg/testutils/integration.go
T
Mikel Olasagasti Uranga 6867e076f1 refactor: move v2 module code to root directory for cleaner structure
Keeps module path as github.com/projectdiscovery/subfinder/v2 to
preserve import compatibility.

Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
2025-07-10 15:27:42 +02:00

43 lines
852 B
Go

package testutils
import (
"fmt"
"os"
"os/exec"
"strings"
)
func RunSubfinderAndGetResults(debug bool, domain string, extra ...string) ([]string, error) {
cmd := exec.Command("bash", "-c")
cmdLine := fmt.Sprintf("echo %s | %s", domain, "./subfinder ")
cmdLine += strings.Join(extra, " ")
cmd.Args = append(cmd.Args, cmdLine)
if debug {
cmd.Args = append(cmd.Args, "-v")
cmd.Stderr = os.Stderr
fmt.Println(cmd.String())
} else {
cmd.Args = append(cmd.Args, "-silent")
}
data, err := cmd.Output()
if debug {
fmt.Println(string(data))
}
if err != nil {
return nil, err
}
var parts []string
items := strings.SplitSeq(string(data), "\n")
for i := range items {
if i != "" {
parts = append(parts, i)
}
}
return parts, nil
}
// TestCase is a single integration test case
type TestCase interface {
Execute() error
}