
The primary improvement is in early clearing of analyzed package's TypeInfo, facts, etc for whole program analyzers (`unused`). Clear it when it becomes unused and GC collects them early. Initially this clearing was performed for all analyzers except `unused`. Update staticcheck from v0.0.1-2019.2.3 to v0.0.1-2020.1.4 Also in this commit: * speed up loading packages from export data (2.5s -> 2.1s for std) by not using mutex for export data since it was allowed in x/tools#07722704da13 * make an order of execution of linters stable * update renameio and robustio * use robustio in caching Relates: #987, #994, #995, #1011
43 lines
948 B
Go
43 lines
948 B
Go
// Copyright 2019 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build !plan9,!windows,!js
|
|
|
|
package renameio
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
"syscall"
|
|
"testing"
|
|
)
|
|
|
|
func TestWriteFileModeAppliesUmask(t *testing.T) {
|
|
dir, err := ioutil.TempDir("", "renameio")
|
|
if err != nil {
|
|
t.Fatalf("Failed to create temporary directory: %v", err)
|
|
}
|
|
defer os.RemoveAll(dir)
|
|
|
|
const mode = 0644
|
|
const umask = 0007
|
|
defer syscall.Umask(syscall.Umask(umask))
|
|
|
|
file := filepath.Join(dir, "testWrite")
|
|
err = WriteFile(file, []byte("go-build"), mode)
|
|
if err != nil {
|
|
t.Fatalf("Failed to write file: %v", err)
|
|
}
|
|
|
|
fi, err := os.Stat(file)
|
|
if err != nil {
|
|
t.Fatalf("Stat %q (looking for mode %#o): %s", file, mode, err)
|
|
}
|
|
|
|
if fi.Mode()&os.ModePerm != 0640 {
|
|
t.Errorf("Stat %q: mode %#o want %#o", file, fi.Mode()&os.ModePerm, 0640)
|
|
}
|
|
}
|