Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added main.goconvey #663

Merged
merged 2 commits into from
Apr 7, 2023
Merged
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
18 changes: 18 additions & 0 deletions web/server/watch/functional_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package watch

import (
"os"
"path"
"path/filepath"
"strings"

Expand Down Expand Up @@ -114,6 +115,23 @@ func LimitDepth(folders messaging.Folders, depth int) {
///////////////////////////////////////////////////////////////////////////////

func AttachProfiles(folders messaging.Folders, items []*FileSystemItem) {
var rootProfile *FileSystemItem
for _, profile := range items {
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
Expand Down
53 changes: 53 additions & 0 deletions web/server/watch/functional_core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,59 @@ func TestAttachProfiles(t *testing.T) {
})
}

func TestAttachMainProfiles(t *testing.T) {
Convey("Subject: Attaching profile information to a folder", t, func() {
folders := map[string]*messaging.Folder{
"/root": {
Path: "/root",
Root: "/root",
},
"/root/1": {
Path: "/root/1",
Root: "/root",
},
"/root/1/2": {
Path: "/root/1/2",
Root: "/root",
},
}

profiles := []*FileSystemItem{
{
Root: "/root",
Name: "main.goconvey",
Path: "/root/main.goconvey",
ProfileDisabled: false,
ProfileArguments: []string{"1"},
},
{
Root: "/root",
Name: "hi.goconvey",
Path: "/root/1/2/hi.goconvey",
ProfileDisabled: false,
ProfileArguments: []string{"1", "2"},
},
}

Convey("Main profiles at root should be merged with all folders without folder profile", func() {
AttachProfiles(folders, profiles)

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

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, ShouldBeFalse)
So(folders["/root/1/2"].TestArguments, ShouldResemble, []string{"1", "2"})
})
})
})
}

func TestMarkIgnored(t *testing.T) {
Convey("Subject: folders that have been ignored should be marked as such", t, func() {
folders := map[string]*messaging.Folder{
Expand Down