本文整理汇总了Golang中testing.T.Skip方法的典型用法代码示例。如果您正苦于以下问题:Golang T.Skip方法的具体用法?Golang T.Skip怎么用?Golang T.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testing.T
的用法示例。
在下文中一共展示了T.Skip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestLatencyEWMAFun
func TestLatencyEWMAFun(t *testing.T) {
t.Skip("run it for fun")
m := peer.NewMetrics()
id, err := testutil.RandPeerID()
if err != nil {
t.Fatal(err)
}
mu := 100.0
sig := 10.0
next := func() time.Duration {
mu = (rand.NormFloat64() * sig) + mu
return time.Duration(mu)
}
print := func() {
fmt.Printf("%3.f %3.f --> %d\n", sig, mu, m.LatencyEWMA(id))
}
for {
select {
case <-time.After(200 * time.Millisecond):
m.RecordLatency(id, next())
print()
}
}
}
示例2: TestDirJoin
func TestDirJoin(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("skipping test on windows")
}
wfi, err := os.Stat("/etc/hosts")
if err != nil {
t.Skip("skipping test; no /etc/hosts file")
}
test := func(d http.Dir, name string) {
f, err := d.Open(name)
if err != nil {
t.Fatalf("open of %s: %v", name, err)
}
defer f.Close()
gfi, err := f.Stat()
if err != nil {
t.Fatalf("stat of %s: %v", name, err)
}
if !os.SameFile(gfi, wfi) {
t.Errorf("%s got different file", name)
}
}
test(http.Dir("/etc/"), "/hosts")
test(http.Dir("/etc/"), "hosts")
test(http.Dir("/etc/"), "../../../../hosts")
test(http.Dir("/etc"), "/hosts")
test(http.Dir("/etc"), "hosts")
test(http.Dir("/etc"), "../../../../hosts")
// Not really directories, but since we use this trick in
// ServeFile, test it:
test(http.Dir("/etc/hosts"), "")
test(http.Dir("/etc/hosts"), "/")
test(http.Dir("/etc/hosts"), "../")
}
示例3: numOpenFDS
func numOpenFDS(t *testing.T) (n int, lsof []byte) {
lsof, err := exec.Command("lsof", "-b", "-n", "-p", strconv.Itoa(os.Getpid())).Output()
if err != nil {
t.Skip("skipping test; error finding or running lsof")
}
return bytes.Count(lsof, []byte("\n")), lsof
}
示例4: TestRemoveAllRace
// Test that simultaneous RemoveAll do not report an error.
// As long as it gets removed, we should be happy.
func TestRemoveAllRace(t *testing.T) {
if runtime.GOOS == "windows" {
// Windows has very strict rules about things like
// removing directories while someone else has
// them open. The racing doesn't work out nicely
// like it does on Unix.
t.Skip("skipping on windows")
}
n := runtime.GOMAXPROCS(16)
defer runtime.GOMAXPROCS(n)
root, err := ioutil.TempDir("", "issue")
if err != nil {
t.Fatal(err)
}
mkdirTree(t, root, 1, 6)
hold := make(chan struct{})
var wg sync.WaitGroup
for i := 0; i < 4; i++ {
wg.Add(1)
go func() {
defer wg.Done()
<-hold
err := RemoveAll(root)
if err != nil {
t.Errorf("unexpected error: %T, %q", err, err)
}
}()
}
close(hold) // let workers race to remove root
wg.Wait()
}
示例5: TestIndexesAsync_ClientWaitScenario
func TestIndexesAsync_ClientWaitScenario(t *testing.T) {
testDBWrapper.CreateFreshDB(t)
testBlockchainWrapper := newTestBlockchainWrapper(t)
chain := testBlockchainWrapper.blockchain
if chain.indexer.isSynchronous() {
t.Skip("Skipping because blockchain is configured to index block data synchronously")
}
blocks, _, err := testBlockchainWrapper.populateBlockChainWithSampleData()
if err != nil {
t.Logf("Error populating block chain with sample data: %s", err)
t.Fail()
}
t.Log("Increasing size of blockchain by one artificially so as to make client wait")
chain.size = chain.size + 1
t.Log("Resetting size of blockchain to original and adding one block in a separate go routine so as to wake up the client")
go func() {
time.Sleep(2 * time.Second)
chain.size = chain.size - 1
blk, err := buildTestBlock(t)
if err != nil {
t.Logf("Error building test block: %s", err)
t.Fail()
}
testBlockchainWrapper.addNewBlock(blk, []byte("stateHash"))
}()
t.Log("Executing client query. The client would wait and will be woken up")
blockHash, _ := blocks[0].GetHash()
block := testBlockchainWrapper.getBlockByHash(blockHash)
testutil.AssertEquals(t, block, blocks[0])
}
示例6: TestUntarInvalidFilenames
func TestUntarInvalidFilenames(t *testing.T) {
// TODO Windows: Figure out how to fix this test.
if runtime.GOOS == "windows" {
t.Skip("Passes but hits breakoutError: platform and architecture is not supported")
}
for i, headers := range [][]*tar.Header{
{
{
Name: "../victim/dotdot",
Typeflag: tar.TypeReg,
Mode: 0644,
},
},
{
{
// Note the leading slash
Name: "/../victim/slash-dotdot",
Typeflag: tar.TypeReg,
Mode: 0644,
},
},
} {
if err := testBreakout("untar", "docker-TestUntarInvalidFilenames", headers); err != nil {
t.Fatalf("i=%d. %v", i, err)
}
}
}
示例7: TestSetICMPFilter
func TestSetICMPFilter(t *testing.T) {
switch runtime.GOOS {
case "nacl", "plan9", "solaris", "windows":
t.Skipf("not supported on %s", runtime.GOOS)
}
if !supportsIPv6 {
t.Skip("ipv6 is not supported")
}
if m, ok := nettest.SupportsRawIPSocket(); !ok {
t.Skip(m)
}
c, err := net.ListenPacket("ip6:ipv6-icmp", "::1")
if err != nil {
t.Fatal(err)
}
defer c.Close()
p := ipv6.NewPacketConn(c)
var f ipv6.ICMPFilter
f.SetAll(true)
f.Accept(ipv6.ICMPTypeEchoRequest)
f.Accept(ipv6.ICMPTypeEchoReply)
if err := p.SetICMPFilter(&f); err != nil {
t.Fatal(err)
}
kf, err := p.ICMPFilter()
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(kf, &f) {
t.Fatalf("got %#v; want %#v", kf, f)
}
}
示例8: TestOverThousandBlobs
func TestOverThousandBlobs(t *testing.T) {
if skipS3() != "" {
t.Skip(skipS3())
}
rootDir, err := ioutil.TempDir("", "driver-")
if err != nil {
t.Fatalf("unexpected error creating temporary directory: %v", err)
}
defer os.Remove(rootDir)
standardDriver, err := s3DriverConstructor(rootDir, s3.StorageClassStandard)
if err != nil {
t.Fatalf("unexpected error creating driver with standard storage: %v", err)
}
ctx := context.Background()
for i := 0; i < 1005; i++ {
filename := "/thousandfiletest/file" + strconv.Itoa(i)
contents := []byte("contents")
err = standardDriver.PutContent(ctx, filename, contents)
if err != nil {
t.Fatalf("unexpected error creating content: %v", err)
}
}
// cant actually verify deletion because read-after-delete is inconsistent, but can ensure no errors
err = standardDriver.Delete(ctx, "/thousandfiletest")
if err != nil {
t.Fatalf("unexpected error deleting thousand files: %v", err)
}
}
示例9: TestTypeScriptFile
func TestTypeScriptFile(t *testing.T) {
bin := os.Getenv("STATIX_TEST_TYPESCRIPT_BIN")
if bin == "" {
t.Skip("STATIX_TEST_TYPESCRIPT_BIN is not set")
}
s := resource.NewFile("./testFiles/test-main.ts")
a := NewTypeScript(bin)
r, err := a.Alter(s)
if err != nil {
t.Error("could not alter resource", err.Error())
}
content, err := r.Dump()
if err != nil {
t.Error("could not dump content")
}
expected := `var Test = (function () {
function Test() {
}
return Test;
})();
/// <reference path="./test-ref.ts"/>
`
if !bytes.Equal(content, []byte(expected)) {
t.Error("content dumped is not correct", string(content))
}
}
示例10: TestRawConnUnicastSocketOptions
func TestRawConnUnicastSocketOptions(t *testing.T) {
switch runtime.GOOS {
case "nacl", "plan9":
t.Skipf("not supported on %s", runtime.GOOS)
}
if m, ok := nettest.SupportsRawIPSocket(); !ok {
t.Skip(m)
}
ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback)
if ifi == nil {
t.Skipf("not available on %s", runtime.GOOS)
}
c, err := net.ListenPacket("ip4:icmp", "127.0.0.1")
if err != nil {
t.Fatal(err)
}
defer c.Close()
r, err := ipv4.NewRawConn(c)
if err != nil {
t.Fatal(err)
}
testUnicastSocketOptions(t, r)
}
示例11: TestWindowsPaths
func TestWindowsPaths(t *testing.T) {
if runtime.GOOS != "windows" {
t.Skip("Not useful on non-Windows")
return
}
folder := FolderConfiguration{
RawPath: `e:\`,
}
expected := `\\?\e:\`
actual := folder.Path()
if actual != expected {
t.Errorf("%q != %q", actual, expected)
}
folder.RawPath = `\\192.0.2.22\network\share`
expected = folder.RawPath
actual = folder.Path()
if actual != expected {
t.Errorf("%q != %q", actual, expected)
}
folder.RawPath = `relative\path`
expected = folder.RawPath
actual = folder.Path()
if actual == expected || !strings.HasPrefix(actual, "\\\\?\\") {
t.Errorf("%q == %q, expected absolutification", actual, expected)
}
}
示例12: TestGetppid
func TestGetppid(t *testing.T) {
switch runtime.GOOS {
case "nacl":
t.Skip("skipping on nacl")
return
case "plan9":
// TODO: golang.org/issue/8206
t.Skipf("skipping test on plan9; see issue 8206")
}
if Getenv("GO_WANT_HELPER_PROCESS") == "1" {
fmt.Print(Getppid())
Exit(0)
}
cmd := osexec.Command(Args[0], "-test.run=TestGetppid")
cmd.Env = append(Environ(), "GO_WANT_HELPER_PROCESS=1")
// verify that Getppid() from the forked process reports our process id
output, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("Failed to spawn child process: %v %q", err, string(output))
}
childPpid := string(output)
ourPid := fmt.Sprintf("%d", Getpid())
if childPpid != ourPid {
t.Fatalf("Child process reports parent process id '%v', expected '%v'", childPpid, ourPid)
}
}
示例13: TestDialTimeout
func TestDialTimeout(t *testing.T) {
if testing.Short() {
t.Skip("skipping in short mode")
}
listener := newLocalListener(t)
addr := listener.Addr().String()
defer listener.Close()
complete := make(chan bool)
defer close(complete)
go func() {
conn, err := listener.Accept()
if err != nil {
t.Error(err)
return
}
<-complete
conn.Close()
}()
dialer := &net.Dialer{
Timeout: 10 * time.Millisecond,
}
var err error
if _, err = DialWithDialer(dialer, "tcp", addr, nil); err == nil {
t.Fatal("DialWithTimeout completed successfully")
}
if !isTimeoutError(err) {
t.Errorf("resulting error not a timeout: %v\nType %T: %#v", err, err, err)
}
}
示例14: TestAccVcdSNAT_Basic
func TestAccVcdSNAT_Basic(t *testing.T) {
if v := os.Getenv("VCD_EXTERNAL_IP"); v == "" {
t.Skip("Environment variable VCD_EXTERNAL_IP must be set to run SNAT tests")
return
}
var e govcd.EdgeGateway
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckVcdSNATDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: fmt.Sprintf(testAccCheckVcdSnat_basic, os.Getenv("VCD_EDGE_GATWEWAY"), os.Getenv("VCD_EXTERNAL_IP")),
Check: resource.ComposeTestCheckFunc(
testAccCheckVcdSNATExists("vcd_snat.bar", &e),
resource.TestCheckResourceAttr(
"vcd_snat.bar", "external_ip", os.Getenv("VCD_EXTERNAL_IP")),
resource.TestCheckResourceAttr(
"vcd_snat.bar", "internal_ip", "10.10.102.0/24"),
),
},
},
})
}
示例15: TestRunSedotanReadRecHistory
func TestRunSedotanReadRecHistory(t *testing.T) {
t.Skip("Skip : Comment this line to do test")
arrcmd := make([]string, 0, 0)
result := toolkit.M{}
arrcmd = append(arrcmd, EC_APP_PATH+`\bin\sedotanread.exe`)
arrcmd = append(arrcmd, `-readtype=rechistory`)
arrcmd = append(arrcmd, `-recfile=E:\EACIIT\src\github.com\eaciit\colony-app\data-root\webgrabber\historyrec\irondcecomcn.Iron01-20160316022830.csv`)
if runtime.GOOS == "windows" {
cmd = exec.Command(arrcmd[0], arrcmd[1:]...)
rechistory, err := toolkit.RunCommand(arrcmd[0], arrcmd[1:]...)
err = toolkit.UnjsonFromString(rechistory, &result)
if err != nil {
t.Errorf("Error, %s \n", err)
}
byteoutput, err := cmd.CombinedOutput()
if err != nil {
// Log.AddLog(fmt.Sprintf("[%v] run at %v, found error : %v", eid, sedotan.DateToString(thistime), err.Error()), "ERROR")
}
err = toolkit.UnjsonFromString(string(byteoutput), &result)
} else {
// cmd = exec.Command("sudo", "../daemon/sedotandaemon", `-config="`+tbasepath+`\config-daemon.json"`, `-logpath="`+tbasepath+`\log"`)
}
fmt.Println(result)
}