Fix
This commit is contained in:
parent
a361581536
commit
3c626cafd5
4 changed files with 19 additions and 17 deletions
|
@ -1,5 +1,5 @@
|
||||||
- group: Hello World
|
- group: Hello World
|
||||||
start: 13-02-2020 18:00
|
start: 12-02-2020 18:00
|
||||||
deadline: 23-02-2020 23:59
|
deadline: 23-02-2020 23:59
|
||||||
tasks:
|
tasks:
|
||||||
- task: sum
|
- task: sum
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
@ -73,29 +74,17 @@ func findChangedTasks(d Deadlines, files []string) []string {
|
||||||
tasks := map[string]struct{}{}
|
tasks := map[string]struct{}{}
|
||||||
|
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
for {
|
components := strings.Split(f, string(filepath.Separator))
|
||||||
dir, _ := filepath.Split(f)
|
if len(components) == 0 {
|
||||||
if dir == "" {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
f = dir
|
|
||||||
}
|
|
||||||
|
|
||||||
if f == "" {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
group, task := d.FindTask(f)
|
_, task := d.FindTask(components[0])
|
||||||
if task == nil {
|
if task == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if !group.IsOpen() {
|
tasks[task.Name] = struct{}{}
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks[f] = struct{}{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var l []string
|
var l []string
|
||||||
|
|
|
@ -15,3 +15,11 @@ func TestDeadlines(t *testing.T) {
|
||||||
require.NotNil(t, sum)
|
require.NotNil(t, sum)
|
||||||
require.Equal(t, "sum", sum.Name)
|
require.Equal(t, "sum", sum.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDetectChange(t *testing.T) {
|
||||||
|
d, err := loadDeadlines("../../../.deadlines.yml")
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
changed := findChangedTasks(d, []string{"sum/sum.go", "testtool/foo.go", "README.md"})
|
||||||
|
require.Equal(t, []string{"sum"}, changed)
|
||||||
|
}
|
||||||
|
|
|
@ -35,6 +35,11 @@ func grade() error {
|
||||||
|
|
||||||
var failed bool
|
var failed bool
|
||||||
for _, task := range changedTasks {
|
for _, task := range changedTasks {
|
||||||
|
group, _ := deadlines.FindTask(task)
|
||||||
|
if !group.IsOpen() {
|
||||||
|
log.Printf("skipping task %s: not released yet", task)
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("testing task %s", task)
|
log.Printf("testing task %s", task)
|
||||||
|
|
||||||
var testFailed bool
|
var testFailed bool
|
||||||
|
|
Loading…
Reference in a new issue