Debian Codegraph @

fileutil/file_test.go

raw symbols SCIP
1 // Copyright (c) 2025, Ville Skyttä <[email protected]>
2 // See LICENSE for licensing information
3
4 package fileutilscip-go gomod mvdan.cc/sh/v3 . `mvdan.cc/sh/v3/fileutil`/
5
6 import (
7 "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/"
8 "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/"
9 )
10
11 func TestShebangscip-go gomod mvdan.cc/sh/v3 . `mvdan.cc/sh/v3/fileutil`/TestShebang().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
12 t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().()
13 tests := []struct {
14 in []byte
15 want string
16 }{
17 {
18 in: []byte("#!/usr/bin/env bash"),
19 want: "bash",
20 },
21 {
22 in: []byte("#!/bin/bash"),
23 want: "bash",
24 },
25 {
26 in: []byte("#!foo bar"),
27 want: "",
28 },
29 {
30 in: []byte("#!/bin/zsh"),
31 want: "zsh",
32 },
33 {
34 in: []byte("#! /bin/zsh true"),
35 want: "zsh",
36 },
37 {
38 in: []byte("#! /bin/zsh"),
39 want: "zsh",
40 },
41 {
42 in: []byte("#!\t/bin/zsh"),
43 want: "zsh",
44 },
45 {
46 in: []byte("#!\f/bin/zsh"),
47 want: "",
48 },
49 }
50
51 for _, test := range tests {
52 name := stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.25.0 strings/ReplaceAll().(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.25.0 strings/ReplaceAll().(string(test.in), "\f", "\\f"), "\t", "\\t")
53 t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(name, func(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
54 if got := Shebangscip-go gomod mvdan.cc/sh/v3 . `mvdan.cc/sh/v3/fileutil`/Shebang().(test.in); got != test.want {
55 t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("want %q, got %q", test.want, got)
56 }
57 })
58 }
59 }