go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/filelock/main_test.go (about)

     1  /*
     2  
     3  Copyright (c) 2023 - Present. Will Charczuk. All rights reserved.
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository.
     5  
     6  */
     7  
     8  package filelock_test
     9  
    10  import (
    11  	"runtime"
    12  	"testing"
    13  )
    14  
    15  // HasExec reports whether the current system can start new processes
    16  // using os.StartProcess or (more commonly) exec.Command.
    17  func HasExec() bool {
    18  	switch runtime.GOOS {
    19  	case "js", "ios":
    20  		return false
    21  	}
    22  	return true
    23  }
    24  
    25  // MustHaveExec checks that the current system can start new processes
    26  // using os.StartProcess or (more commonly) exec.Command.
    27  // If not, MustHaveExec calls t.Skip with an explanation.
    28  func MustHaveExec(t testing.TB) {
    29  	if !HasExec() {
    30  		t.Skipf("skipping test: cannot exec subprocess on %s/%s", runtime.GOOS, runtime.GOARCH)
    31  	}
    32  }