Browse Source

Limit alterfiles to a single operation per file

Lode Hoste 10 years ago
parent
commit
58b15f9452
1 changed files with 5 additions and 12 deletions
  1. 5 12
      test/util.go

+ 5 - 12
test/util.go

@@ -134,9 +134,7 @@ func alterFiles(dir string) error {
 		case r == 0 && comps > 2:
 			// Delete every tenth file or directory, except top levels
 			err := removeAll(path)
-			if err != nil {
-				return err
-			}
+			return err
 
 		case r == 1 && info.Mode().IsRegular():
 			if info.Mode()&0200 != 0200 {
@@ -162,9 +160,7 @@ func alterFiles(dir string) error {
 				return err
 			}
 			err = fd.Close()
-			if err != nil {
-				return err
-			}
+			return err
 
 		// Change capitalization
 		case r == 2 && comps > 3 && rand.Float64() < 0.2:
@@ -177,9 +173,7 @@ func alterFiles(dir string) error {
 				}
 			}
 			err = os.Rename(path, strings.Replace(path, filepath.Base(path), string(base), 1))
-			if err != nil {
-				return err
-			}
+			return err
 
 		// Switch between files and directories
 		case r == 2 && comps > 3 && rand.Float64() < 0.2:
@@ -204,6 +198,7 @@ func alterFiles(dir string) error {
 				}
 				generateFiles(path, 10, 20, "../LICENSE")
 			}
+			return err
 
 		case r == 3 && comps > 2 && (info.Mode().IsRegular() || rand.Float64() < 0.2):
 			rpath := filepath.Dir(path)
@@ -213,9 +208,7 @@ func alterFiles(dir string) error {
 				}
 			}
 			err = os.Rename(path, filepath.Join(rpath, randomName()))
-			if err != nil {
-				return err
-			}
+			return err
 		}
 		return nil
 	})