Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions tool/internal/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ func (sp *SetupPhase) keepForDebug(srcPath string) {
}
}

// This function can be used to check if the setup has been completed.
// isSetup reports whether setup has already been completed for the current
// build by checking for the presence of the matched-rules file written by
// store() at the end of a successful Setup run.
func isSetup() bool {
// TODO: Implement Task
return false
_, err := os.Stat(util.GetMatchedRuleFile())
return err == nil
}

// flagsWithPathValues contains flags that accept a value from "go build" command.
Expand Down
27 changes: 27 additions & 0 deletions tool/internal/setup/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,33 @@ func TestSetupGoCache(t *testing.T) {
})
}

func TestIsSetup(t *testing.T) {
t.Run("returns false when matched.json does not exist", func(t *testing.T) {
tempDir := t.TempDir()
t.Setenv(util.EnvOtelcWorkDir, tempDir)
if err := os.MkdirAll(util.GetBuildTempDir(), 0o755); err != nil {
t.Fatal(err)
}
if isSetup() {
t.Error("isSetup() = true, expected false when matched.json is absent")
}
})

t.Run("returns true when matched.json exists", func(t *testing.T) {
tempDir := t.TempDir()
t.Setenv(util.EnvOtelcWorkDir, tempDir)
if err := os.MkdirAll(util.GetBuildTempDir(), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(util.GetMatchedRuleFile(), []byte("[]"), 0o644); err != nil {
t.Fatal(err)
}
if !isSetup() {
t.Error("isSetup() = false, expected true when matched.json exists")
}
})
}

func TestExtractBuildFlags(t *testing.T) {
tests := []struct {
name string
Expand Down
Loading