all: Revert the underscore sillyness
This commit is contained in:
@@ -33,7 +33,7 @@ func TestChmodFile(t *testing.T) {
|
||||
path := filepath.Join(dir, "file")
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
defer func() { _ = os.Chmod(path, 0666) }()
|
||||
defer os.Chmod(path, 0666)
|
||||
|
||||
fd, err := os.Create(path)
|
||||
if err != nil {
|
||||
@@ -74,7 +74,7 @@ func TestChownFile(t *testing.T) {
|
||||
path := filepath.Join(dir, "file")
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
defer func() { _ = os.Chmod(path, 0666) }()
|
||||
defer os.Chmod(path, 0666)
|
||||
|
||||
fd, err := os.Create(path)
|
||||
if err != nil {
|
||||
@@ -116,7 +116,7 @@ func TestChmodDir(t *testing.T) {
|
||||
mode = os.FileMode(0777)
|
||||
}
|
||||
|
||||
defer func() { _ = os.Chmod(path, mode) }()
|
||||
defer os.Chmod(path, mode)
|
||||
|
||||
if err := os.Mkdir(path, mode); err != nil {
|
||||
t.Error(err)
|
||||
@@ -147,7 +147,7 @@ func TestChtimes(t *testing.T) {
|
||||
|
||||
mtime := time.Now().Add(-time.Hour)
|
||||
|
||||
_ = fs.Chtimes("file", mtime, mtime)
|
||||
fs.Chtimes("file", mtime, mtime)
|
||||
|
||||
stat, err := os.Stat(path)
|
||||
if err != nil {
|
||||
|
||||
@@ -98,7 +98,7 @@ func TestWatchInclude(t *testing.T) {
|
||||
|
||||
file := "file"
|
||||
ignored := "ignored"
|
||||
_ = testFs.MkdirAll(filepath.Join(name, ignored), 0777)
|
||||
testFs.MkdirAll(filepath.Join(name, ignored), 0777)
|
||||
included := filepath.Join(ignored, "included")
|
||||
|
||||
testCase := func() {
|
||||
@@ -274,7 +274,7 @@ func TestWatchSymlinkedRoot(t *testing.T) {
|
||||
if err := testFs.MkdirAll(name, 0755); err != nil {
|
||||
panic(fmt.Sprintf("Failed to create directory %s: %s", name, err))
|
||||
}
|
||||
defer func() { _ = testFs.RemoveAll(name) }()
|
||||
defer testFs.RemoveAll(name)
|
||||
|
||||
root := filepath.Join(name, "root")
|
||||
if err := testFs.MkdirAll(root, 0777); err != nil {
|
||||
@@ -376,7 +376,7 @@ func testScenario(t *testing.T, name string, testCase func(), expectedEvents, al
|
||||
if err := testFs.MkdirAll(name, 0755); err != nil {
|
||||
panic(fmt.Sprintf("Failed to create directory %s: %s", name, err))
|
||||
}
|
||||
defer func() { _ = testFs.RemoveAll(name) }()
|
||||
defer testFs.RemoveAll(name)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
@@ -105,22 +105,22 @@ func newFakeFilesystem(root string) *fakefs {
|
||||
for (files == 0 || createdFiles < files) && (maxsize == 0 || writtenData>>20 < int64(maxsize)) {
|
||||
dir := filepath.Join(fmt.Sprintf("%02x", rng.Intn(255)), fmt.Sprintf("%02x", rng.Intn(255)))
|
||||
file := fmt.Sprintf("%016x", rng.Int63())
|
||||
_ = fs.MkdirAll(dir, 0755)
|
||||
fs.MkdirAll(dir, 0755)
|
||||
|
||||
fd, _ := fs.Create(filepath.Join(dir, file))
|
||||
createdFiles++
|
||||
|
||||
fsize := int64(sizeavg/2 + rng.Intn(sizeavg))
|
||||
_ = fd.Truncate(fsize)
|
||||
fd.Truncate(fsize)
|
||||
writtenData += fsize
|
||||
|
||||
ftime := time.Unix(1000000000+rng.Int63n(10*365*86400), 0)
|
||||
_ = fs.Chtimes(filepath.Join(dir, file), ftime, ftime)
|
||||
fs.Chtimes(filepath.Join(dir, file), ftime, ftime)
|
||||
}
|
||||
}
|
||||
|
||||
// Also create a default folder marker for good measure
|
||||
_ = fs.Mkdir(".stfolder", 0700)
|
||||
fs.Mkdir(".stfolder", 0700)
|
||||
|
||||
fakefsFs[root] = fs
|
||||
return fs
|
||||
@@ -583,7 +583,7 @@ func (f *fakeFile) readShortAt(p []byte, offs int64) (int, error) {
|
||||
// name.
|
||||
if f.seed == 0 {
|
||||
hf := fnv.New64()
|
||||
_, _ = hf.Write([]byte(f.name))
|
||||
hf.Write([]byte(f.name))
|
||||
f.seed = int64(hf.Sum64())
|
||||
}
|
||||
|
||||
@@ -601,7 +601,7 @@ func (f *fakeFile) readShortAt(p []byte, offs int64) (int, error) {
|
||||
diff := offs - minOffs
|
||||
if diff > 0 {
|
||||
lr := io.LimitReader(f.rng, diff)
|
||||
_, _ = io.Copy(ioutil.Discard, lr)
|
||||
io.Copy(ioutil.Discard, lr)
|
||||
}
|
||||
|
||||
f.offset = offs
|
||||
|
||||
@@ -130,10 +130,10 @@ func TestFakeFSRead(t *testing.T) {
|
||||
|
||||
// Create
|
||||
fd, _ := fs.Create("test")
|
||||
_ = fd.Truncate(3 * 1 << randomBlockShift)
|
||||
fd.Truncate(3 * 1 << randomBlockShift)
|
||||
|
||||
// Read
|
||||
_, _ = fd.Seek(0, io.SeekStart)
|
||||
fd.Seek(0, io.SeekStart)
|
||||
bs0, err := ioutil.ReadAll(fd)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -143,7 +143,7 @@ func TestFakeFSRead(t *testing.T) {
|
||||
}
|
||||
|
||||
// Read again, starting at an odd offset
|
||||
_, _ = fd.Seek(0, io.SeekStart)
|
||||
fd.Seek(0, io.SeekStart)
|
||||
buf0 := make([]byte, 12345)
|
||||
n, _ := fd.Read(buf0)
|
||||
if n != len(buf0) {
|
||||
|
||||
@@ -53,7 +53,7 @@ func (f *MtimeFS) Chtimes(name string, atime, mtime time.Time) error {
|
||||
}
|
||||
|
||||
// Do a normal Chtimes call, don't care if it succeeds or not.
|
||||
_ = f.chtimes(name, atime, mtime)
|
||||
f.chtimes(name, atime, mtime)
|
||||
|
||||
// Stat the file to see what happened. Here we *do* return an error,
|
||||
// because it might be "does not exist" or similar.
|
||||
|
||||
@@ -18,10 +18,10 @@ import (
|
||||
func TestMtimeFS(t *testing.T) {
|
||||
os.RemoveAll("testdata")
|
||||
defer os.RemoveAll("testdata")
|
||||
_ = os.Mkdir("testdata", 0755)
|
||||
_ = ioutil.WriteFile("testdata/exists0", []byte("hello"), 0644)
|
||||
_ = ioutil.WriteFile("testdata/exists1", []byte("hello"), 0644)
|
||||
_ = ioutil.WriteFile("testdata/exists2", []byte("hello"), 0644)
|
||||
os.Mkdir("testdata", 0755)
|
||||
ioutil.WriteFile("testdata/exists0", []byte("hello"), 0644)
|
||||
ioutil.WriteFile("testdata/exists1", []byte("hello"), 0644)
|
||||
ioutil.WriteFile("testdata/exists2", []byte("hello"), 0644)
|
||||
|
||||
// a random time with nanosecond precision
|
||||
testTime := time.Unix(1234567890, 123456789)
|
||||
@@ -73,7 +73,7 @@ func TestMtimeFS(t *testing.T) {
|
||||
// filesystems.
|
||||
|
||||
testTime = time.Now().Add(5 * time.Hour).Truncate(time.Minute)
|
||||
_ = os.Chtimes("testdata/exists0", testTime, testTime)
|
||||
os.Chtimes("testdata/exists0", testTime, testTime)
|
||||
if info, err := mtimefs.Lstat("testdata/exists0"); err != nil {
|
||||
t.Error("Lstat shouldn't fail:", err)
|
||||
} else if !info.ModTime().Equal(testTime) {
|
||||
@@ -93,8 +93,8 @@ func TestMtimeFSInsensitive(t *testing.T) {
|
||||
theTest := func(t *testing.T, fs *MtimeFS, shouldSucceed bool) {
|
||||
os.RemoveAll("testdata")
|
||||
defer os.RemoveAll("testdata")
|
||||
_ = os.Mkdir("testdata", 0755)
|
||||
_ = ioutil.WriteFile("testdata/FiLe", []byte("hello"), 0644)
|
||||
os.Mkdir("testdata", 0755)
|
||||
ioutil.WriteFile("testdata/FiLe", []byte("hello"), 0644)
|
||||
|
||||
// a random time with nanosecond precision
|
||||
testTime := time.Unix(1234567890, 123456789)
|
||||
|
||||
@@ -51,7 +51,7 @@ func TempNameWithPrefix(name, prefix string) string {
|
||||
tbase := filepath.Base(name)
|
||||
if len(tbase) > maxFilenameLength {
|
||||
hash := md5.New()
|
||||
_, _ = hash.Write([]byte(name))
|
||||
hash.Write([]byte(name))
|
||||
tbase = fmt.Sprintf("%x", hash.Sum(nil))
|
||||
}
|
||||
tname := fmt.Sprintf("%s%s.tmp", prefix, tbase)
|
||||
|
||||
Reference in New Issue
Block a user