This commit is contained in:
Fedor Korotkiy 2020-02-13 02:28:27 +03:00
parent a361581536
commit 3c626cafd5
4 changed files with 19 additions and 17 deletions

View file

@ -1,5 +1,5 @@
- group: Hello World
start: 13-02-2020 18:00
start: 12-02-2020 18:00
deadline: 23-02-2020 23:59
tasks:
- task: sum

View file

@ -5,6 +5,7 @@ import (
"io/ioutil"
"path/filepath"
"sort"
"strings"
"time"
"gopkg.in/yaml.v2"
@ -73,29 +74,17 @@ func findChangedTasks(d Deadlines, files []string) []string {
tasks := map[string]struct{}{}
for _, f := range files {
for {
dir, _ := filepath.Split(f)
if dir == "" {
break
}
f = dir
}
if f == "" {
components := strings.Split(f, string(filepath.Separator))
if len(components) == 0 {
continue
}
group, task := d.FindTask(f)
_, task := d.FindTask(components[0])
if task == nil {
continue
}
if !group.IsOpen() {
continue
}
tasks[f] = struct{}{}
tasks[task.Name] = struct{}{}
}
var l []string

View file

@ -15,3 +15,11 @@ func TestDeadlines(t *testing.T) {
require.NotNil(t, sum)
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)
}

View file

@ -35,6 +35,11 @@ func grade() error {
var failed bool
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)
var testFailed bool