Skip to content

Commit

Permalink
fix issue: folder will not add profile is he has no profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Lee committed Jun 3, 2022
1 parent c50fdf1 commit d3ecc51
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
12 changes: 9 additions & 3 deletions web/server/watch/functional_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,24 @@ func LimitDepth(folders messaging.Folders, depth int) {
func AttachProfiles(folders messaging.Folders, items []*FileSystemItem) {
var rootProfile *FileSystemItem
for _, profile := range items {
path, _ := path.Split(profile.Path)
path := path.Dir(profile.Path)
if path == profile.Root && profile.Name == "main.goconvey" {
rootProfile = profile
break
}
}

// put root profile to all folders
if rootProfile != nil {
for _, folder := range folders {
folder.Disabled, folder.BuildTags, folder.TestArguments = rootProfile.ProfileDisabled, rootProfile.ProfileTags, rootProfile.ProfileArguments
}
}

// use folder profile to replace root profile
for _, profile := range items {
if folder, exists := folders[filepath.Dir(profile.Path)]; exists {
folder.Disabled, folder.BuildTags, folder.TestArguments = profile.ProfileDisabled, profile.ProfileTags, profile.ProfileArguments
} else if rootProfile != nil {
folder.Disabled, folder.BuildTags, folder.TestArguments = rootProfile.ProfileDisabled, rootProfile.ProfileTags, rootProfile.ProfileArguments
}
}
}
Expand Down
14 changes: 9 additions & 5 deletions web/server/watch/functional_core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,17 @@ func TestAttachMainProfiles(t *testing.T) {

profiles := []*FileSystemItem{
{
Root: "/root",
Name: "main.goconvey",
Path: "/root/main.goconvey",
ProfileDisabled: true,
ProfileDisabled: false,
ProfileArguments: []string{"1"},
},
{
Root: "/root",
Name: "hi.goconvey",
Path: "/root/1/2/hi.goconvey",
ProfileDisabled: true,
ProfileDisabled: false,
ProfileArguments: []string{"1", "2"},
},
}
Expand All @@ -371,15 +375,15 @@ func TestAttachMainProfiles(t *testing.T) {
AttachProfiles(folders, profiles)

Convey("Main profiles matched the all other folder", func() {
So(folders["/root"].Disabled, ShouldBeTrue)
So(folders["/root"].Disabled, ShouldBeFalse)
So(folders["/root"].TestArguments, ShouldResemble, []string{"1"})

So(folders["/root/1"].Disabled, ShouldBeTrue)
So(folders["/root/1"].Disabled, ShouldBeFalse)
So(folders["/root/1"].TestArguments, ShouldResemble, []string{"1"})
})

Convey("The second folder should match the first profile", func() {
So(folders["/root/1/2"].Disabled, ShouldBeTrue)
So(folders["/root/1/2"].Disabled, ShouldBeFalse)
So(folders["/root/1/2"].TestArguments, ShouldResemble, []string{"1", "2"})
})
})
Expand Down

0 comments on commit d3ecc51

Please sign in to comment.