Ejemplo n.º 1
0
func checkSliceEqual(t *testing.T, expected, actual []interface{}, msgAndArgs ...interface{}) bool {
	if fmt.Sprintf("%v", expected) != fmt.Sprintf("%v", actual) {
		return assert.Fail(t, fmt.Sprintf("Not equal: %#v (expected)\n"+
			"        != %#v (actual)", expected, actual), msgAndArgs...)
	}

	return true
}
Ejemplo n.º 2
0
func TestOutdated(t *testing.T) {
	// force txt to be newer than foo, which should run txt
	touch("tmp/sub/1.foo", -1*time.Second)
	touch("tmp/sub/foo.txt", 0)

	ran := ""
	var project *Project
	tasks := func(p *Project) {
		project = p

		p.Task("txt", nil, func(*Context) {
			ran += "T"
		}).
			Src("tmp/sub/*.txt").
			Dest("tmp/sub/*.foo")

		p.Task("parent", S{"txt"}, func(*Context) {
			ran += "P"
		}).Src("tmp/*.txt")
	}

	go func() {
		argv := []string{"parent", "-w"}
		execCLI(tasks, argv, func(code int) {
			assert.Fail(t, "should not have exited")
		})
	}()

	// give the task enough time to setup watches
	<-time.After(testProjectDelay)

	// force txt to have older modtime than foo which should not run "text but run "parent"
	touch("tmp/1.foo", 3*time.Second)   // is not watched
	touch("tmp/foo.txt", 1*time.Second) // txt is watched

	// wait at least watchDelay which is the interval for updating watches
	<-time.After(testWatchDelay)

	assert.Equal(t, "TPP", ran)
}