Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Commit

Permalink
Preserve .c and .h files (#31)
Browse files Browse the repository at this point in the history
* Preserve .c and .h files

* Only test sqlite behavior on non-windows platforms

* Use a constant list of preserved file endings

* Bump to version 1.3.4
  • Loading branch information
spenczar authored Aug 1, 2017
1 parent 11b37e4 commit 31601f0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
8 changes: 4 additions & 4 deletions clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ func keepFile(filename string) bool {
if strings.HasSuffix(filename, "_test.go") {
return false
}
if strings.HasSuffix(filename, ".go") {
return true
}
if strings.HasSuffix(filename, ".s") {

switch filepath.Ext(filename) {
case ".go", ".s", ".c", ".h":
return true
}

if isLegalFile(filename) {
return true
}
Expand Down
3 changes: 3 additions & 0 deletions clean_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func TestKeep(t *testing.T) {

testcase("assembly.s", true)
testcase("notassembly.as", false)
testcase("sqlite.c", true)
testcase("spec", false)
testcase("sqlite.h", true)
testcase("picture.gif", false)
testcase("LICENSE.md", true)
}
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/Masterminds/semver"
)

var version = semver.MustParse("v1.3.3")
var version = semver.MustParse("v1.3.4")

func main() {
flag.Parse()
Expand Down
34 changes: 34 additions & 0 deletions retool_nonwindows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@

package main

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
)

// Go builds files on windows with an '.exe' suffix. Everywhere else, there's no
// suffix.
const osBinSuffix = ""

// Test that we correctly preserve .c and .h files by running a test against a
// command that uses go-sqlite3.
//
// This test can only be run on non-windows platforms because go-sqlite3 cannot
// be built on windows.
func TestCSourceFilePreservation(t *testing.T) {
t.Parallel()

retool, err := buildRetool()
if err != nil {
t.Fatal(err)
}
defer func() {
_ = os.RemoveAll(filepath.Dir(retool))
}()

dir, err := ioutil.TempDir("", "")
if err != nil {
t.Fatalf("unable to make temp dir: %s", err)
}
defer func() {
_ = os.RemoveAll(dir)
}()
runRetoolCmd(t, dir, retool, "add", "github.com/spenczar/sqlite_retool_testcmd", "origin/master")
runRetoolCmd(t, dir, retool, "build")
}

0 comments on commit 31601f0

Please sign in to comment.