github.com/chenfeining/golangci-lint@v1.0.2-0.20230730162517-14c6c67868df/test/testshared/runner_windows.go (about)

     1  //go:build windows
     2  
     3  package testshared
     4  
     5  import (
     6  	"path/filepath"
     7  	"regexp"
     8  	"strings"
     9  	"testing"
    10  )
    11  
    12  // SkipOnWindows skip test on Windows.
    13  func SkipOnWindows(tb testing.TB) {
    14  	tb.Skip("not supported on Windows")
    15  }
    16  
    17  // NormalizeFilePathInJSON find Go file path and replace `/` with `\\\\`.
    18  func NormalizeFilePathInJSON(in string) string {
    19  	exp := regexp.MustCompile(`(?:^|\b)[\w-/.]+\.go`)
    20  
    21  	return exp.ReplaceAllStringFunc(in, func(s string) string {
    22  		return strings.ReplaceAll(s, "/", "\\\\")
    23  	})
    24  }
    25  
    26  // NormalizeFileInString normalizes in quoted string, ie. replace `\\` with `\\\\`.
    27  func NormalizeFileInString(in string) string {
    28  	return strings.ReplaceAll(filepath.FromSlash(in), "\\", "\\\\")
    29  }
    30  
    31  // defaultBinaryName returns the path to the default binary.
    32  func defaultBinaryName() string {
    33  	return filepath.Join("..", "golangci-lint.exe")
    34  }
    35  
    36  // normalizeFilePath find Go file path and replace `/` with `\\`.
    37  func normalizeFilePath(in string) string {
    38  	exp := regexp.MustCompile(`(?:^|\b)[\w-/.]+\.go`)
    39  
    40  	return exp.ReplaceAllStringFunc(in, func(s string) string {
    41  		return strings.ReplaceAll(s, "/", "\\")
    42  	})
    43  }