Skip to content

Commit

Permalink
tests: graphviz output
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtekgrinder committed Sep 28, 2024
1 parent b676164 commit 08936cf
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions cmd/tlin/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"encoding/json"
"fmt"
"go/token"
"io"
"os"
Expand Down Expand Up @@ -88,6 +87,15 @@ func TestParseFlags(t *testing.T) {
ConfidenceThreshold: defaultConfidenceThreshold,
},
},
{
name: "Output",
args: []string{"-o", "output.svg", "file.go"},
expected: Config{
Paths: []string{"file.go"},
Output: "output.svg",
ConfidenceThreshold: defaultConfidenceThreshold,
},
},
}

for _, tt := range tests {
Expand All @@ -101,6 +109,7 @@ func TestParseFlags(t *testing.T) {
assert.Equal(t, tt.expected.ConfidenceThreshold, config.ConfidenceThreshold)
assert.Equal(t, tt.expected.Paths, config.Paths)
assert.Equal(t, tt.expected.JsonOutput, config.JsonOutput)
assert.Equal(t, tt.expected.Output, config.Output)
})
}
}
Expand Down Expand Up @@ -159,7 +168,7 @@ func ignoredFunc() { // 19
ctx := context.Background()

output := captureOutput(t, func() {
runCFGAnalysis(ctx, logger, []string{tempFile}, "targetFunc")
runCFGAnalysis(ctx, logger, []string{tempFile}, "targetFunc", "")
})

assert.Contains(t, output, "CFG for function targetFunc in file")
Expand All @@ -172,7 +181,7 @@ func ignoredFunc() { // 19
t.Logf("output: %s", output)

output = captureOutput(t, func() {
runCFGAnalysis(ctx, logger, []string{tempFile}, "nonExistentFunc")
runCFGAnalysis(ctx, logger, []string{tempFile}, "nonExistentFunc", "")
})

assert.Contains(t, output, "Function not found: nonExistentFunc")
Expand Down Expand Up @@ -286,7 +295,6 @@ func TestRunJsonOutput(t *testing.T) {

tempDir, err := os.MkdirTemp("", "json-test")
assert.NoError(t, err)
fmt.Println(tempDir)

testFile := filepath.Join(tempDir, "test.go")
err = os.WriteFile(testFile, []byte(sliceRangeIssueExample), 0644)
Expand Down

0 comments on commit 08936cf

Please sign in to comment.