+78
-3
lines changedFilter options
+78
-3
lines changed Original file line number Diff line number Diff line change
@@ -696,11 +696,16 @@ func relPath(basedir, path string) string {
696
696
}
697
697
698
698
func execPath(prog string) string {
699
-
if binDir != "" && runtime.GOOS == "windows" {
700
-
return filepath.Join(binDir, fmt.Sprintf("%s.exe", prog))
699
+
binFile := prog
700
+
if runtime.GOOS == "windows" {
701
+
binFile = fmt.Sprintf("%s.exe", prog)
701
702
}
702
703
703
-
return prog
704
+
if binDir != "" {
705
+
return filepath.Join(binDir, binFile)
706
+
}
707
+
708
+
return binFile
704
709
}
705
710
706
711
func cleanDBName(dbname string) string {
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
1
+
// pg_back
2
+
//
3
+
// Copyright 2011-2022 Nicolas Thauvin and contributors. All rights reserved.
4
+
//
5
+
// Redistribution and use in source and binary forms, with or without
6
+
// modification, are permitted provided that the following conditions
7
+
// are met:
8
+
//
9
+
// 1. Redistributions of source code must retain the above copyright
10
+
// notice, this list of conditions and the following disclaimer.
11
+
// 2. Redistributions in binary form must reproduce the above copyright
12
+
// notice, this list of conditions and the following disclaimer in the
13
+
// documentation and/or other materials provided with the distribution.
14
+
//
15
+
// THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
16
+
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17
+
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18
+
// IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
19
+
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24
+
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+
26
+
package main
27
+
28
+
import (
29
+
"fmt"
30
+
"runtime"
31
+
"testing"
32
+
)
33
+
34
+
func TestExecPath(t *testing.T) {
35
+
var tests []struct {
36
+
dir string
37
+
prog string
38
+
want string
39
+
}
40
+
41
+
if runtime.GOOS != "windows" {
42
+
tests = []struct {
43
+
dir string
44
+
prog string
45
+
want string
46
+
}{
47
+
{"", "pg_dump", "pg_dump"},
48
+
{"/path/to/bin", "prog", "/path/to/bin/prog"},
49
+
}
50
+
} else {
51
+
tests = []struct {
52
+
dir string
53
+
prog string
54
+
want string
55
+
}{
56
+
{"", "pg_dump", "pg_dump.exe"},
57
+
{"C:\\path\\to\\bin", "prog", "C:\\path\\to\\bin\\prog.exe"},
58
+
}
59
+
}
60
+
61
+
for i, st := range tests {
62
+
t.Run(fmt.Sprintf("%v", i), func(t *testing.T) {
63
+
binDir = st.dir
64
+
got := execPath(st.prog)
65
+
if got != st.want {
66
+
t.Errorf("expected %q, got %q\n", st.want, got)
67
+
}
68
+
})
69
+
}
70
+
}
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4