Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ac773d7

Browse files
committedDec 24, 2020
Remove unused function from test helper
Signed-off-by: Krzysztof Wilczyński <[email protected]>
1 parent 8fc1713 commit ac773d7

File tree

3 files changed

+8
-53
lines changed

3 files changed

+8
-53
lines changed
 

‎go.mod

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
module github.com/kwilczynski/go-magic
22

33
go 1.15
4-
5-
require github.com/stretchr/testify v1.6.1

‎helper_test.go

-35
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ package magic
33
import (
44
"bytes"
55
"path"
6-
"reflect"
7-
"runtime"
8-
"testing"
96
)
107

118
var (
@@ -25,41 +22,9 @@ var (
2522
shellMagicFile = path.Clean(path.Join(fixturesDirectory, "shell.magic"))
2623
)
2724

28-
func skip(t *testing.T, message string) {
29-
// XXX(krzysztof): Attempt to circumvent lack of T.Skip() prior to Go version go1.1 ...
30-
f := reflect.ValueOf(t).MethodByName("Skip")
31-
if ok := f.IsValid(); !ok {
32-
f = reflect.ValueOf(t).MethodByName("Log")
33-
}
34-
35-
f.Call([]reflect.Value{reflect.ValueOf(message)})
36-
}
37-
3825
func compareStrings(this, other string) bool {
3926
if this == "" || other == "" {
4027
return false
4128
}
4229
return bytes.Equal([]byte(this), []byte(other))
4330
}
44-
45-
func oldGoVersion() (bool, string) {
46-
// Contains every release of Go prior to
47-
// when the `os.Unsetenv()` function was
48-
// added in the version 1.4.x and newer.
49-
versions := []string{
50-
"go1", "go1.0.1",
51-
"go1.0.2", "go1.0.3",
52-
"go1.1", "go1.1.1", "go1.1.2",
53-
"go1.2", "go1.2.1", "go1.2.2",
54-
"go1.3", "go1.3.1", "go1.3.2", "go1.3.3",
55-
}
56-
57-
version := runtime.Version()
58-
59-
for _, v := range versions {
60-
if v == version {
61-
return true, version
62-
}
63-
}
64-
return false, version
65-
}

‎magic_test.go

+8-16
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func TestMagic_String(t *testing.T) {
161161
}
162162
}
163163

164-
func TestMagic_Path(t *testing.T) {
164+
func TestMagic_Paths(t *testing.T) {
165165
var mgc *Magic
166166
var rv []string
167167

@@ -184,9 +184,9 @@ func TestMagic_Path(t *testing.T) {
184184

185185
mgc.Close()
186186

187-
// XXX(krzysztof): Setting "MAGIC" here breaks tests later as it will
188-
// be persistent between different tests, sadly needed to be disabled
189-
// for the time being.
187+
// Setting "MAGIC" here breaks tests later as it will be persistent
188+
// between different tests, sadly needed to be disabled for the time
189+
// being.
190190
//
191191
// p, err := os.Getwd()
192192
// if err != nil {
@@ -203,9 +203,9 @@ func TestMagic_Path(t *testing.T) {
203203
// t.Errorf("value given %q, want %q", v[0], p)
204204
// }
205205

206-
// TODO(kwilczynski): Test Magic.Load() affecting Magic.Path() as well. But
207-
// that requires working os.Clearenv() which is yet to be implemented as
208-
// per http://golang.org/src/pkg/syscall/env_unix.go?s=1772:1787#L101
206+
// Test Magic.Load() affecting Magic.Path() as well. But that requires
207+
// working os.Clearenv() which is yet to be implemented as per
208+
// http://golang.org/src/pkg/syscall/env_unix.go?s=1772:1787#L101
209209

210210
mgc, _ = open()
211211
defer func() {
@@ -218,11 +218,7 @@ func TestMagic_Path(t *testing.T) {
218218
}
219219
}
220220

221-
func TestMagic_Path_Environment(t *testing.T) {
222-
if ok, v := oldGoVersion(); ok {
223-
skip(t, fmt.Sprintf("this version of the Go Language is too old: %s", v))
224-
return // Should not me reachable on modern Go version.
225-
}
221+
func TestMagic_Paths_Environment(t *testing.T) {
226222
}
227223

228224
func TestMagic_Parameter(t *testing.T) {
@@ -448,10 +444,6 @@ func TestMagic_Load(t *testing.T) {
448444
}
449445

450446
func TestMagic_Load_Environment(t *testing.T) {
451-
if ok, v := oldGoVersion(); ok {
452-
skip(t, fmt.Sprintf("this version of the Go Language is too old: %s", v))
453-
return // Should not me reachable on modern Go version.
454-
}
455447
}
456448

457449
func TestMagic_Compile(t *testing.T) {

0 commit comments

Comments
 (0)