Skip to content

Commit 54fcab2

Browse files
committed
appveyor, build: fix review requests
1 parent a2bc90d commit 54fcab2

File tree

2 files changed

+31
-25
lines changed

2 files changed

+31
-25
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ after_build:
3636

3737
test_script:
3838
- set CGO_ENABLED=1
39-
- go run build\ci.go test -vet -coverage -misspell
39+
- go run build\ci.go test -vet -coverage

build/ci.go

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Usage: go run ci.go <command> <command flags/arguments>
2424
Available commands are:
2525
2626
install [-arch architecture] [ packages... ] -- builds packages and executables
27-
test [ -coverage ] [ -vet ] [ -misspell] [ packages... ] -- runs the tests
27+
test [ -coverage ] [ -vet ] [ -misspell ] [ packages... ] -- runs the tests
2828
archive [-arch architecture] [ -type zip|tar ] [ -signer key-envvar ] [ -upload dest ] -- archives build artefacts
2929
importkeys -- imports signing keys from env
3030
debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package
@@ -289,29 +289,7 @@ func doTest(cmdline []string) {
289289
build.MustRun(goTool("vet", packages...))
290290
}
291291
if *misspell {
292-
// Ensure the spellchecker is available
293-
build.MustRun(goTool("get", "github.com/client9/misspell/cmd/misspell"))
294-
295-
// Windows (AppVeyor) chokes on long argument lists, check packages individualy
296-
for _, pkg := range packages {
297-
// The spell checker doesn't work on packages, gather all .go files for it
298-
out, err := goTool("list", "-f", "{{.Dir}}{{range .GoFiles}}\n{{.}}{{end}}{{range .CgoFiles}}\n{{.}}{{end}}{{range .TestGoFiles}}\n{{.}}{{end}}", pkg).CombinedOutput()
299-
if err != nil {
300-
log.Fatalf("source file listing failed: %v\n%s", err, string(out))
301-
}
302-
// Retrieve the folder and assemble the source list
303-
lines := strings.Split(string(out), "\n")
304-
root := lines[0]
305-
306-
sources := make([]string, 0, len(lines)-1)
307-
for _, line := range lines[1:] {
308-
if line = strings.TrimSpace(line); line != "" {
309-
sources = append(sources, filepath.Join(root, line))
310-
}
311-
}
312-
// Run the spell checker for this particular package
313-
build.MustRunCommand(filepath.Join(GOBIN, "misspell"), append([]string{"-error"}, sources...)...)
314-
}
292+
spellcheck(packages)
315293
}
316294
// Run the actual tests.
317295
gotest := goTool("test")
@@ -325,6 +303,34 @@ func doTest(cmdline []string) {
325303
build.MustRun(gotest)
326304
}
327305

306+
// spellcheck runs the client9/misspell spellchecker package on all Go, Cgo and
307+
// test files in the requested packages.
308+
func spellcheck(packages []string) {
309+
// Ensure the spellchecker is available
310+
build.MustRun(goTool("get", "github.com/client9/misspell/cmd/misspell"))
311+
312+
// Windows chokes on long argument lists, check packages individualy
313+
for _, pkg := range packages {
314+
// The spell checker doesn't work on packages, gather all .go files for it
315+
out, err := goTool("list", "-f", "{{.Dir}}{{range .GoFiles}}\n{{.}}{{end}}{{range .CgoFiles}}\n{{.}}{{end}}{{range .TestGoFiles}}\n{{.}}{{end}}", pkg).CombinedOutput()
316+
if err != nil {
317+
log.Fatalf("source file listing failed: %v\n%s", err, string(out))
318+
}
319+
// Retrieve the folder and assemble the source list
320+
lines := strings.Split(string(out), "\n")
321+
root := lines[0]
322+
323+
sources := make([]string, 0, len(lines)-1)
324+
for _, line := range lines[1:] {
325+
if line = strings.TrimSpace(line); line != "" {
326+
sources = append(sources, filepath.Join(root, line))
327+
}
328+
}
329+
// Run the spell checker for this particular package
330+
build.MustRunCommand(filepath.Join(GOBIN, "misspell"), append([]string{"-error"}, sources...)...)
331+
}
332+
}
333+
328334
// Release Packaging
329335

330336
func doArchive(cmdline []string) {

0 commit comments

Comments
 (0)