From a2df86fc9edb856e01f2f2ae2dd7567d963edc9d Mon Sep 17 00:00:00 2001 From: tcnksm Date: Thu, 8 Oct 2015 20:41:02 +0900 Subject: [PATCH 1/2] Enable to generate gitignore --- skeleton/framework.go | 1 + skeleton/resource/tmpl/common/gitignore.tmpl | 1 + 2 files changed, 2 insertions(+) create mode 100644 skeleton/resource/tmpl/common/gitignore.tmpl diff --git a/skeleton/framework.go b/skeleton/framework.go index 531fa50..839a981 100644 --- a/skeleton/framework.go +++ b/skeleton/framework.go @@ -31,6 +31,7 @@ type Framework struct { var CommonTemplates = []Template{ {"resource/tmpl/common/CHANGELOG.md.tmpl", "CHANGELOG.md"}, {"resource/tmpl/common/README.md.tmpl", "README.md"}, + {"resource/tmpl/common/gitignore.tmpl", ".gitignore"}, } // Frameworks is collection of Framework. diff --git a/skeleton/resource/tmpl/common/gitignore.tmpl b/skeleton/resource/tmpl/common/gitignore.tmpl new file mode 100644 index 0000000..c56069f --- /dev/null +++ b/skeleton/resource/tmpl/common/gitignore.tmpl @@ -0,0 +1 @@ +*.test \ No newline at end of file From 232da79cd281583c03a510034954d974202b5580 Mon Sep 17 00:00:00 2001 From: tcnksm Date: Thu, 8 Oct 2015 20:41:35 +0900 Subject: [PATCH 2/2] Test common files are generated or not --- tests/command_framework_test.go | 12 ++++++++++++ tests/design_flow_test.go | 12 ++++++++++++ tests/flag_framework_test.go | 12 ++++++++++++ tests/helper_test.go | 5 +++++ 4 files changed, 41 insertions(+) diff --git a/tests/command_framework_test.go b/tests/command_framework_test.go index f9557c4..b92ec71 100644 --- a/tests/command_framework_test.go +++ b/tests/command_framework_test.go @@ -5,10 +5,13 @@ import ( "fmt" "os" "os/exec" + "path/filepath" "strconv" "strings" "testing" "time" + + "github.com/tcnksm/gcli/skeleton" ) func TestNew_command_frameworks(t *testing.T) { @@ -63,6 +66,15 @@ func TestNew_command_frameworks(t *testing.T) { t.Fatalf("[%s] expect %q to contain %q", tt.framework, output, expect) } + // Check common files are generated + for _, tmpl := range skeleton.CommonTemplates { + // NOTE: OutputPathTmpl of common template is same as final output name + // and not changed by templating + if _, err := os.Stat(filepath.Join(artifactBin, tmpl.OutputPathTmpl)); os.IsNotExist(err) { + t.Fatalf("file is not exist: %s", tmpl.OutputPathTmpl) + } + } + if err := goTests(artifactBin); err != nil { t.Fatal(err) } diff --git a/tests/design_flow_test.go b/tests/design_flow_test.go index 8b04c66..347e14a 100644 --- a/tests/design_flow_test.go +++ b/tests/design_flow_test.go @@ -3,10 +3,13 @@ package main import ( "fmt" "os" + "path/filepath" "strconv" "strings" "testing" "time" + + "github.com/tcnksm/gcli/skeleton" ) func TestDesignFlow(t *testing.T) { @@ -71,6 +74,15 @@ func TestDesignFlow(t *testing.T) { t.Fatalf("Expect %q to contain %q", output, expect) } + // Check common files are generated + for _, tmpl := range skeleton.CommonTemplates { + // NOTE: OutputPathTmpl of common template is same as final output name + // and not changed by templating + if _, err := os.Stat(filepath.Join(artifactBin, tmpl.OutputPathTmpl)); os.IsNotExist(err) { + t.Fatalf("file is not exist: %s", tmpl.OutputPathTmpl) + } + } + if err := goTests(artifactBin); err != nil { t.Fatalf("Failed to run go tests in %s: %s", artifactBin, err) } diff --git a/tests/flag_framework_test.go b/tests/flag_framework_test.go index d12cb37..d2f8760 100644 --- a/tests/flag_framework_test.go +++ b/tests/flag_framework_test.go @@ -5,10 +5,13 @@ import ( "fmt" "os" "os/exec" + "path/filepath" "strconv" "strings" "testing" "time" + + "github.com/tcnksm/gcli/skeleton" ) func TestNew_flag_frameworks(t *testing.T) { @@ -52,6 +55,15 @@ func TestNew_flag_frameworks(t *testing.T) { t.Fatalf("[%s] expect %q to contain %q", tt.framework, output, expect) } + // Check common files are generated + for _, tmpl := range skeleton.CommonTemplates { + // NOTE: OutputPathTmpl of common template is same as final output name + // and not changed by templating + if _, err := os.Stat(filepath.Join(artifactBin, tmpl.OutputPathTmpl)); os.IsNotExist(err) { + t.Fatalf("file is not exist: %s", tmpl.OutputPathTmpl) + } + } + if err := goTests(artifactBin); err != nil { t.Fatal(err) } diff --git a/tests/helper_test.go b/tests/helper_test.go index e29cd5d..0321c6f 100644 --- a/tests/helper_test.go +++ b/tests/helper_test.go @@ -87,6 +87,11 @@ func runGcli(args []string) (string, error) { } +func checkFile(files []string) error { + + return nil +} + func goTests(output string) error { // Change directory to artifact directory root if err := os.Chdir(output); err != nil {