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
39 changes: 39 additions & 0 deletions spread/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,38 @@ func (p *Project) backendNames() []string {
return bnames
}

func listAllowsSystem(system string, list []string) (bool, error) {
if len(list) == 0 {
return true, nil
}
numRemoved := 0
for _, name := range list {
add := strings.HasPrefix(name, "+")
remove := strings.HasPrefix(name, "-")
if remove {
numRemoved++
continue
}
if add {
name = name[1:]
}
if system == name {
return true, nil
}
matched, err := filepath.Match(name, system)
if err != nil {
return false, err
}
if matched {
return true, nil
}
}
if numRemoved == len(list) {
return true, nil
}
return false, nil
}

func (p *Project) Jobs(options *Options) ([]*Job, error) {
var jobs []*Job

Expand Down Expand Up @@ -1024,6 +1056,13 @@ func (p *Project) Jobs(options *Options) ([]*Job, error) {
if system == nil {
continue
}
suiteok, err := listAllowsSystem(sysname, suite.Systems)
if err != nil {
return nil, err
}
if !suiteok {
continue
}
yenv := envmap{system, system.Environment}
yevr := strmap{system, evars(system.Environment, "+")}
yvar := strmap{system, system.Variants}
Expand Down
1 change: 1 addition & 0 deletions tests/suite-systems/22
5 changes: 5 additions & 0 deletions tests/suite-systems/24/main/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
summary: Empty spread task
systems:
- ubuntu-24.04
- ubuntu-22.04
execute: exit 0
1 change: 1 addition & 0 deletions tests/suite-systems/empty-sys
1 change: 1 addition & 0 deletions tests/suite-systems/not-22
29 changes: 29 additions & 0 deletions tests/suite-systems/spread.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
project: spread

backends:
lxd:
systems:
- ubuntu-22.04

path: /home/test

suites:
24/:
summary: Verification tasks.
systems:
- ubuntu-24.*

not-22/:
summary: Verification tasks.
systems:
- -ubuntu-22.04

22/:
summary: Verification tasks.
systems:
- ubuntu-22.04

empty-sys/:
summary: Verification tasks.

# vim:ts=4:sw=4:et
16 changes: 16 additions & 0 deletions tests/suite-systems/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
summary: Test suite systems

prepare: |
if [ ! -f .spread-reuse.yaml ]; then
touch /run/spread-reuse.yaml
ln -s /run/spread-reuse.yaml .spread-reuse.yaml
fi

debug: FAIL_CHECK=0 spread -list lxd:ubuntu-22.04

execute: |
list="$(FAIL_CHECK=0 spread -list lxd:ubuntu-22.04)"
MATCH "22/main" <<<"$list"
MATCH "empty-sys/main" <<<"$list"
NOMATCH "24/main" <<<"$list"
NOMATCH "not-22/main" <<<"$list"
Loading