misc: add race flag to devcam and fix fallout

This commit is contained in:
Michael Hoffmann 2022-12-31 16:03:46 +01:00 committed by Brad Fitzpatrick
parent d1e67a4ba3
commit ad7454c304
2 changed files with 13 additions and 0 deletions

View File

@ -36,6 +36,7 @@ type testCmd struct {
verbose bool
precommit bool
short bool
race bool
run string
sqlite bool
}
@ -44,6 +45,7 @@ func init() {
cmdmain.RegisterMode("test", func(flags *flag.FlagSet) cmdmain.CommandRunner {
cmd := new(testCmd)
flags.BoolVar(&cmd.short, "short", false, "Use '-short' with go test.")
flags.BoolVar(&cmd.race, "race", false, "Use '-race' with go test.")
flags.BoolVar(&cmd.precommit, "precommit", true, "Run the pre-commit githook as part of tests.")
flags.BoolVar(&cmd.verbose, "v", false, "Use '-v' (for verbose) with go test.")
flags.StringVar(&cmd.run, "run", "", "Use '-run' with go test.")
@ -128,6 +130,9 @@ func (c *testCmd) runTests(args []string) error {
if c.short {
targs = append(targs, "-short")
}
if c.race {
targs = append(targs, "-race")
}
if c.verbose {
targs = append(targs, "-v")
}

View File

@ -254,6 +254,7 @@ func TestInitNeededMaps(t *testing.T) {
}
ix.InitBlobSource(bs)
{
ix.Lock()
needs, neededBy, _ := ix.NeededMapsForTest()
needsWant := map[blob.Ref][]blob.Ref{
fileBlobRef: {chunk1ref, chunk2ref, chunk3ref},
@ -269,11 +270,13 @@ func TestInitNeededMaps(t *testing.T) {
if !reflect.DeepEqual(neededBy, neededByWant) {
t.Errorf("neededBy = %v; want %v", neededBy, neededByWant)
}
ix.Unlock()
}
ix.Exp_noteBlobIndexed(chunk2ref)
{
ix.Lock()
needs, neededBy, ready := ix.NeededMapsForTest()
needsWant := map[blob.Ref][]blob.Ref{
fileBlobRef: {chunk1ref, chunk3ref},
@ -291,11 +294,13 @@ func TestInitNeededMaps(t *testing.T) {
if len(ready) != 0 {
t.Errorf("ready = %v; want nothing", ready)
}
ix.Unlock()
}
ix.Exp_noteBlobIndexed(chunk1ref)
{
ix.Lock()
needs, neededBy, ready := ix.NeededMapsForTest()
needsWant := map[blob.Ref][]blob.Ref{
fileBlobRef: {chunk3ref},
@ -312,11 +317,13 @@ func TestInitNeededMaps(t *testing.T) {
if len(ready) != 0 {
t.Errorf("ready = %v; want nothing", ready)
}
ix.Unlock()
}
ix.Exp_noteBlobIndexed(chunk3ref)
{
ix.Lock()
needs, neededBy, ready := ix.NeededMapsForTest()
needsWant := map[blob.Ref][]blob.Ref{}
neededByWant := map[blob.Ref][]blob.Ref{}
@ -329,6 +336,7 @@ func TestInitNeededMaps(t *testing.T) {
if !ready[fileBlobRef] {
t.Error("fileBlobRef not ready")
}
ix.Unlock()
}
// We also technically don't need to wait for the ooo indexing goroutine
// to finish for this unit test, but it's cleaner.