Plumb through the ogletest context.

geesefs-0-30-9
Aaron Jacobs 2015-05-01 11:11:32 +10:00
parent 18af108bac
commit a76742833c
2 changed files with 6 additions and 5 deletions

View File

@ -59,7 +59,7 @@ type SampleTest struct {
// //
// REQUIRES: t.Server has been set. // REQUIRES: t.Server has been set.
func (t *SampleTest) SetUp(ti *ogletest.TestInfo) { func (t *SampleTest) SetUp(ti *ogletest.TestInfo) {
err := t.initialize(t.Server, &t.MountConfig) err := t.initialize(ti.Ctx, t.Server, &t.MountConfig)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -67,10 +67,11 @@ func (t *SampleTest) SetUp(ti *ogletest.TestInfo) {
// Like SetUp, but doens't panic. // Like SetUp, but doens't panic.
func (t *SampleTest) initialize( func (t *SampleTest) initialize(
ctx context.Context,
server fuse.Server, server fuse.Server,
config *fuse.MountConfig) (err error) { config *fuse.MountConfig) (err error) {
// Initialize the context. // Initialize the context.
t.Ctx = context.Background() t.Ctx = ctx
// Initialize the clock. // Initialize the clock.
t.Clock.SetTime(time.Date(2012, 8, 15, 22, 56, 0, 0, time.Local)) t.Clock.SetTime(time.Date(2012, 8, 15, 22, 56, 0, 0, time.Local))

View File

@ -68,7 +68,7 @@ type SubprocessTest struct {
// Mount the file system and initialize the other exported fields of the // Mount the file system and initialize the other exported fields of the
// struct. Panics on error. // struct. Panics on error.
func (t *SubprocessTest) SetUp(ti *ogletest.TestInfo) { func (t *SubprocessTest) SetUp(ti *ogletest.TestInfo) {
err := t.initialize() err := t.initialize(ti.Ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -184,9 +184,9 @@ func waitForReady(readyReader *os.File, c chan<- struct{}) {
} }
// Like SetUp, but doens't panic. // Like SetUp, but doens't panic.
func (t *SubprocessTest) initialize() (err error) { func (t *SubprocessTest) initialize(ctx context.Context) (err error) {
// Initialize the context. // Initialize the context.
t.Ctx = context.Background() t.Ctx = ctx
// Set up a temporary directory. // Set up a temporary directory.
t.Dir, err = ioutil.TempDir("", "sample_test") t.Dir, err = ioutil.TempDir("", "sample_test")