Skip to content

Commit

Permalink
fix test error
Browse files Browse the repository at this point in the history
  • Loading branch information
tsingbx committed Mar 6, 2025
1 parent cefbc09 commit d799a8d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/llcppcfg/llcppgcfg/cfg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ func Test_parseCFlagsEntry(t *testing.T) {
{OFile: "cJSON_Utils.o", HFile: "cJSON_Utils.h", Deps: []string{"cJSON.h"}},
{OFile: "cJSON.o", HFile: "cJSON.h", Deps: []string{}},
},
InvalidObjFiles: []*ObjFile{},
},
},
{
Expand Down
3 changes: 2 additions & 1 deletion cmd/llcppcfg/llcppgcfg/cfg_test_data/deps/case3/b.h
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include "a.h"
#include "a.h"
#include "c.h"
1 change: 1 addition & 0 deletions cmd/llcppcfg/llcppgcfg/cfg_test_data/deps/case3/c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "b.h"
2 changes: 1 addition & 1 deletion cmd/llcppcfg/llcppgcfg/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (c *CflagEntry) IsEmpty() bool {
if len(c.Include) == 0 {
return true
}
if len(c.ObjFiles) == 0 {
if len(c.ObjFiles) == 0 && len(c.InvalidObjFiles) == 0 {
return true
}
return false
Expand Down
25 changes: 25 additions & 0 deletions cmd/llcppcfg/llcppgcfg/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ func TestIncludeList_AddCflagEntry(t *testing.T) {
_, inc := newCflags("cfg_test_data/same_rel")
inc0 := filepath.Join(inc, "libcjson/include")
inc1 := filepath.Join(inc, "stdcjson/include")
_, depsInc := newCflags("cfg_test_data/deps")
case3Inc := filepath.Join(depsInc, "case3")
type fields struct {
include []string
absPathMap map[string]struct{}
Expand Down Expand Up @@ -387,6 +389,29 @@ func TestIncludeList_AddCflagEntry(t *testing.T) {
},
[]string{},
},
{
"deps/case3",
fields{
make([]string, 0),
make(map[string]struct{}),
make(map[string]struct{}),
},
[]args{
{
0,
&CflagEntry{
Include: case3Inc,
ObjFiles: []*ObjFile{},
InvalidObjFiles: []*ObjFile{
{OFile: "a.h", HFile: "a.h", Deps: []string{}},
{OFile: "b.h", HFile: "b.h", Deps: []string{}},
{OFile: "c.h", HFile: "c.h", Deps: []string{}},
},
},
},
},
[]string{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit d799a8d

Please sign in to comment.