forked from syncthing/syncthing
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
meta: Move metadata checks into meta directory, make them tests
This moves a few things from script/ to a new directory meta/, and makes them real Go tests. These are the authors, copyright, metalint and gofmt checks. That means that they can now be run by go test -v ./meta and optionally filtered by the usual -run thing to go test. Also -short will cut down on the metalint stuff and exclude the authors check (which is slow because it runs git lots of times). Mainly this makes everything easier on things like build servers where we can now just run tests instead of do a bunch of scripting. GitHub-Pull-Request: syncthing#4252
- Loading branch information
Showing
6 changed files
with
208 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The files in this directory contain metadata tests - that is, tests on the | ||
shape and colour of the code in the rest of the repository. This code is not | ||
compiled into the final product. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (C) 2015 The Syncthing Authors. | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
// Checks for authors that are not mentioned in AUTHORS | ||
package meta | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
var gofmtCheckDirs = []string{".", "../cmd", "../lib", "../test", "../script"} | ||
|
||
func TestCheckGoFmt(t *testing.T) { | ||
for _, dir := range gofmtCheckDirs { | ||
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
if path == ".git" { | ||
return filepath.SkipDir | ||
} | ||
if filepath.Ext(path) != ".go" { | ||
return nil | ||
} | ||
cmd := exec.Command("gofmt", "-s", "-d", path) | ||
bs, err := cmd.CombinedOutput() | ||
if err != nil { | ||
return err | ||
} | ||
if len(bs) != 0 { | ||
t.Errorf("File %s is not formatted correctly:\n\n%s", path, string(bs)) | ||
} | ||
return nil | ||
}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
} |
Oops, something went wrong.