From 665bb0cafbc454480138831fde3d2ba0f159a2d5 Mon Sep 17 00:00:00 2001 From: k1LoW Date: Wed, 29 Nov 2023 09:56:59 +0900 Subject: [PATCH] mv pkg/* to ./ --- .github/workflows/parallel.yml | 14 +++++++------- {pkg/badge => badge}/NotoSans-Medium.ttf | Bin {pkg/badge => badge}/README.md | 0 {pkg/badge => badge}/badge.go | 0 {pkg/badge => badge}/badge.svg.tmpl | 0 {pkg/badge => badge}/badge_test.go | 0 {pkg/badge => badge}/cmd/badgen/main.go | 2 +- {pkg/badge => badge}/cmd/root.go | 2 +- {pkg/badge => badge}/testdata/a.golden | 0 {pkg/badge => badge}/testdata/add_icon.golden | 0 {pkg/badge => badge}/testdata/b.golden | 0 {pkg/badge => badge}/testdata/c.golden | 0 {pkg/badge => badge}/testdata/icon.svg | 0 central/central.go | 2 +- cmd/badge.go | 2 +- cmd/init.go | 2 +- cmd/root.go | 2 +- cmd/view.go | 2 +- {pkg/coverage => coverage}/clover.go | 0 {pkg/coverage => coverage}/clover_test.go | 0 {pkg/coverage => coverage}/cobertura.go | 0 {pkg/coverage => coverage}/cobertura_test.go | 0 {pkg/coverage => coverage}/coverage.go | 0 {pkg/coverage => coverage}/coverage_test.go | 0 {pkg/coverage => coverage}/diff.go | 0 {pkg/coverage => coverage}/gocover.go | 0 {pkg/coverage => coverage}/gocover_test.go | 0 {pkg/coverage => coverage}/jacoco.go | 0 {pkg/coverage => coverage}/jacoco_test.go | 0 {pkg/coverage => coverage}/lcov.go | 0 {pkg/coverage => coverage}/lcov_test.go | 0 {pkg/coverage => coverage}/merge.go | 0 {pkg/coverage => coverage}/merge_test.go | 0 {pkg/coverage => coverage}/printer.go | 0 {pkg/coverage => coverage}/printer_test.go | 0 {pkg/coverage => coverage}/simplecov.go | 0 {pkg/coverage => coverage}/simplecov_test.go | 0 .../testdata/clover/coverage.xml | 0 .../testdata/clover/coverage_package.xml | 0 .../testdata/cobertura/coverage.xml | 0 .../testdata/gocover/coverage.out | 0 .../testdata/jacoco/jacocoTestReport.xml | 0 .../coverage => coverage}/testdata/lcov/lcov.info | 0 .../testdata/simplecov/.resultset.another.json | 0 .../testdata/simplecov/.resultset.json | 0 .../testdata/simplecov/.resultset.parallel.json | 0 .../testdata/simplecov/.resultset2.json | 0 docs/term.svg | 2 +- {pkg/pplang => pplang}/README.md | 0 {pkg/pplang => pplang}/pplang.go | 0 {pkg/pplang => pplang}/pplang_test.go | 2 +- {pkg/pplang => pplang}/testdata/gitconfig.txtar | 0 {pkg/pplang => pplang}/testdata/go.txtar | 0 {pkg/pplang => pplang}/testdata/none.txtar | 0 {pkg/ratio => ratio}/copy_from_gocloc.go | 0 {pkg/ratio => ratio}/merge.go | 0 {pkg/ratio => ratio}/merge_test.go | 0 {pkg/ratio => ratio}/ratio.go | 0 {pkg/ratio => ratio}/ratio_test.go | 10 +++++----- report/diff_report.go | 4 ++-- report/report.go | 4 ++-- report/report_test.go | 6 +++--- testdata/octocov_parallel_tests.yml | 6 +++--- 63 files changed, 31 insertions(+), 31 deletions(-) rename {pkg/badge => badge}/NotoSans-Medium.ttf (100%) rename {pkg/badge => badge}/README.md (100%) rename {pkg/badge => badge}/badge.go (100%) rename {pkg/badge => badge}/badge.svg.tmpl (100%) rename {pkg/badge => badge}/badge_test.go (100%) rename {pkg/badge => badge}/cmd/badgen/main.go (95%) rename {pkg/badge => badge}/cmd/root.go (98%) rename {pkg/badge => badge}/testdata/a.golden (100%) rename {pkg/badge => badge}/testdata/add_icon.golden (100%) rename {pkg/badge => badge}/testdata/b.golden (100%) rename {pkg/badge => badge}/testdata/c.golden (100%) rename {pkg/badge => badge}/testdata/icon.svg (100%) rename {pkg/coverage => coverage}/clover.go (100%) rename {pkg/coverage => coverage}/clover_test.go (100%) rename {pkg/coverage => coverage}/cobertura.go (100%) rename {pkg/coverage => coverage}/cobertura_test.go (100%) rename {pkg/coverage => coverage}/coverage.go (100%) rename {pkg/coverage => coverage}/coverage_test.go (100%) rename {pkg/coverage => coverage}/diff.go (100%) rename {pkg/coverage => coverage}/gocover.go (100%) rename {pkg/coverage => coverage}/gocover_test.go (100%) rename {pkg/coverage => coverage}/jacoco.go (100%) rename {pkg/coverage => coverage}/jacoco_test.go (100%) rename {pkg/coverage => coverage}/lcov.go (100%) rename {pkg/coverage => coverage}/lcov_test.go (100%) rename {pkg/coverage => coverage}/merge.go (100%) rename {pkg/coverage => coverage}/merge_test.go (100%) rename {pkg/coverage => coverage}/printer.go (100%) rename {pkg/coverage => coverage}/printer_test.go (100%) rename {pkg/coverage => coverage}/simplecov.go (100%) rename {pkg/coverage => coverage}/simplecov_test.go (100%) rename {pkg/coverage => coverage}/testdata/clover/coverage.xml (100%) rename {pkg/coverage => coverage}/testdata/clover/coverage_package.xml (100%) rename {pkg/coverage => coverage}/testdata/cobertura/coverage.xml (100%) rename {pkg/coverage => coverage}/testdata/gocover/coverage.out (100%) rename {pkg/coverage => coverage}/testdata/jacoco/jacocoTestReport.xml (100%) rename {pkg/coverage => coverage}/testdata/lcov/lcov.info (100%) rename {pkg/coverage => coverage}/testdata/simplecov/.resultset.another.json (100%) rename {pkg/coverage => coverage}/testdata/simplecov/.resultset.json (100%) rename {pkg/coverage => coverage}/testdata/simplecov/.resultset.parallel.json (100%) rename {pkg/coverage => coverage}/testdata/simplecov/.resultset2.json (100%) rename {pkg/pplang => pplang}/README.md (100%) rename {pkg/pplang => pplang}/pplang.go (100%) rename {pkg/pplang => pplang}/pplang_test.go (97%) rename {pkg/pplang => pplang}/testdata/gitconfig.txtar (100%) rename {pkg/pplang => pplang}/testdata/go.txtar (100%) rename {pkg/pplang => pplang}/testdata/none.txtar (100%) rename {pkg/ratio => ratio}/copy_from_gocloc.go (100%) rename {pkg/ratio => ratio}/merge.go (100%) rename {pkg/ratio => ratio}/merge_test.go (100%) rename {pkg/ratio => ratio}/ratio.go (100%) rename {pkg/ratio => ratio}/ratio_test.go (90%) diff --git a/.github/workflows/parallel.yml b/.github/workflows/parallel.yml index ce991b08..dbc073e1 100644 --- a/.github/workflows/parallel.yml +++ b/.github/workflows/parallel.yml @@ -22,14 +22,14 @@ jobs: with: go-version-file: go.mod - - name: Run tests pkg/coverage - run: go test ./pkg/coverage/... -coverprofile=coverage_coverage.out -covermode=count + - name: Run tests coverage + run: go test ./coverage/... -coverprofile=coverage_coverage.out -covermode=count - - name: Run tests pkg/ratio - run: go test ./pkg/ratio/... -coverprofile=coverage_ratio.out -covermode=count + - name: Run tests ratio + run: go test ./ratio/... -coverprofile=coverage_ratio.out -covermode=count - - name: Run tests pkg/badge - run: go test ./pkg/badge/... -coverprofile=coverage_badge.out -covermode=count + - name: Run tests badge + run: go test ./badge/... -coverprofile=coverage_badge.out -covermode=count - uses: actions/upload-artifact@v2 with: @@ -54,7 +54,7 @@ jobs: go-version-file: go.mod - name: Run tests other - run: go test $(go list ./... | grep -v pkg) -coverprofile=coverage_other.out -covermode=count + run: go test $(go list ./... | grep -v coverage | grep -v ratio | grep -v badge) -coverprofile=coverage_other.out -covermode=count - uses: actions/upload-artifact@v2 with: diff --git a/pkg/badge/NotoSans-Medium.ttf b/badge/NotoSans-Medium.ttf similarity index 100% rename from pkg/badge/NotoSans-Medium.ttf rename to badge/NotoSans-Medium.ttf diff --git a/pkg/badge/README.md b/badge/README.md similarity index 100% rename from pkg/badge/README.md rename to badge/README.md diff --git a/pkg/badge/badge.go b/badge/badge.go similarity index 100% rename from pkg/badge/badge.go rename to badge/badge.go diff --git a/pkg/badge/badge.svg.tmpl b/badge/badge.svg.tmpl similarity index 100% rename from pkg/badge/badge.svg.tmpl rename to badge/badge.svg.tmpl diff --git a/pkg/badge/badge_test.go b/badge/badge_test.go similarity index 100% rename from pkg/badge/badge_test.go rename to badge/badge_test.go diff --git a/pkg/badge/cmd/badgen/main.go b/badge/cmd/badgen/main.go similarity index 95% rename from pkg/badge/cmd/badgen/main.go rename to badge/cmd/badgen/main.go index e2765a9b..18b9903d 100644 --- a/pkg/badge/cmd/badgen/main.go +++ b/badge/cmd/badgen/main.go @@ -21,7 +21,7 @@ THE SOFTWARE. */ package main -import "github.com/k1LoW/octocov/pkg/badge/cmd" +import "github.com/k1LoW/octocov/badge/cmd" func main() { cmd.Execute() diff --git a/pkg/badge/cmd/root.go b/badge/cmd/root.go similarity index 98% rename from pkg/badge/cmd/root.go rename to badge/cmd/root.go index 5f0c2eb2..eb8138ab 100644 --- a/pkg/badge/cmd/root.go +++ b/badge/cmd/root.go @@ -24,7 +24,7 @@ package cmd import ( "os" - "github.com/k1LoW/octocov/pkg/badge" + "github.com/k1LoW/octocov/badge" "github.com/spf13/cobra" ) diff --git a/pkg/badge/testdata/a.golden b/badge/testdata/a.golden similarity index 100% rename from pkg/badge/testdata/a.golden rename to badge/testdata/a.golden diff --git a/pkg/badge/testdata/add_icon.golden b/badge/testdata/add_icon.golden similarity index 100% rename from pkg/badge/testdata/add_icon.golden rename to badge/testdata/add_icon.golden diff --git a/pkg/badge/testdata/b.golden b/badge/testdata/b.golden similarity index 100% rename from pkg/badge/testdata/b.golden rename to badge/testdata/b.golden diff --git a/pkg/badge/testdata/c.golden b/badge/testdata/c.golden similarity index 100% rename from pkg/badge/testdata/c.golden rename to badge/testdata/c.golden diff --git a/pkg/badge/testdata/icon.svg b/badge/testdata/icon.svg similarity index 100% rename from pkg/badge/testdata/icon.svg rename to badge/testdata/icon.svg diff --git a/central/central.go b/central/central.go index bfcbe0bd..f3f3e249 100644 --- a/central/central.go +++ b/central/central.go @@ -19,7 +19,7 @@ import ( "github.com/k1LoW/octocov/datastore/local" "github.com/k1LoW/octocov/gh" "github.com/k1LoW/octocov/internal" - "github.com/k1LoW/octocov/pkg/badge" + "github.com/k1LoW/octocov/badge" "github.com/k1LoW/octocov/report" ) diff --git a/cmd/badge.go b/cmd/badge.go index b4da970b..6a2604bc 100644 --- a/cmd/badge.go +++ b/cmd/badge.go @@ -31,7 +31,7 @@ import ( "github.com/k1LoW/octocov/config" "github.com/k1LoW/octocov/internal" - "github.com/k1LoW/octocov/pkg/badge" + "github.com/k1LoW/octocov/badge" "github.com/k1LoW/octocov/report" "github.com/spf13/cobra" ) diff --git a/cmd/init.go b/cmd/init.go index a4cbad7c..7a47e788 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -29,7 +29,7 @@ import ( "path/filepath" "github.com/k1LoW/octocov/config" - "github.com/k1LoW/octocov/pkg/pplang" + "github.com/k1LoW/octocov/pplang" "github.com/spf13/cobra" ) diff --git a/cmd/root.go b/cmd/root.go index b18bcfce..bb6c3992 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -38,7 +38,7 @@ import ( "github.com/k1LoW/octocov/datastore" "github.com/k1LoW/octocov/gh" "github.com/k1LoW/octocov/internal" - "github.com/k1LoW/octocov/pkg/badge" + "github.com/k1LoW/octocov/badge" "github.com/k1LoW/octocov/report" "github.com/k1LoW/octocov/version" "github.com/spf13/cobra" diff --git a/cmd/view.go b/cmd/view.go index 2ed539ca..2cd98177 100644 --- a/cmd/view.go +++ b/cmd/view.go @@ -27,7 +27,7 @@ import ( "path/filepath" "github.com/k1LoW/octocov/config" - "github.com/k1LoW/octocov/pkg/coverage" + "github.com/k1LoW/octocov/coverage" "github.com/k1LoW/octocov/report" "github.com/spf13/cobra" ) diff --git a/pkg/coverage/clover.go b/coverage/clover.go similarity index 100% rename from pkg/coverage/clover.go rename to coverage/clover.go diff --git a/pkg/coverage/clover_test.go b/coverage/clover_test.go similarity index 100% rename from pkg/coverage/clover_test.go rename to coverage/clover_test.go diff --git a/pkg/coverage/cobertura.go b/coverage/cobertura.go similarity index 100% rename from pkg/coverage/cobertura.go rename to coverage/cobertura.go diff --git a/pkg/coverage/cobertura_test.go b/coverage/cobertura_test.go similarity index 100% rename from pkg/coverage/cobertura_test.go rename to coverage/cobertura_test.go diff --git a/pkg/coverage/coverage.go b/coverage/coverage.go similarity index 100% rename from pkg/coverage/coverage.go rename to coverage/coverage.go diff --git a/pkg/coverage/coverage_test.go b/coverage/coverage_test.go similarity index 100% rename from pkg/coverage/coverage_test.go rename to coverage/coverage_test.go diff --git a/pkg/coverage/diff.go b/coverage/diff.go similarity index 100% rename from pkg/coverage/diff.go rename to coverage/diff.go diff --git a/pkg/coverage/gocover.go b/coverage/gocover.go similarity index 100% rename from pkg/coverage/gocover.go rename to coverage/gocover.go diff --git a/pkg/coverage/gocover_test.go b/coverage/gocover_test.go similarity index 100% rename from pkg/coverage/gocover_test.go rename to coverage/gocover_test.go diff --git a/pkg/coverage/jacoco.go b/coverage/jacoco.go similarity index 100% rename from pkg/coverage/jacoco.go rename to coverage/jacoco.go diff --git a/pkg/coverage/jacoco_test.go b/coverage/jacoco_test.go similarity index 100% rename from pkg/coverage/jacoco_test.go rename to coverage/jacoco_test.go diff --git a/pkg/coverage/lcov.go b/coverage/lcov.go similarity index 100% rename from pkg/coverage/lcov.go rename to coverage/lcov.go diff --git a/pkg/coverage/lcov_test.go b/coverage/lcov_test.go similarity index 100% rename from pkg/coverage/lcov_test.go rename to coverage/lcov_test.go diff --git a/pkg/coverage/merge.go b/coverage/merge.go similarity index 100% rename from pkg/coverage/merge.go rename to coverage/merge.go diff --git a/pkg/coverage/merge_test.go b/coverage/merge_test.go similarity index 100% rename from pkg/coverage/merge_test.go rename to coverage/merge_test.go diff --git a/pkg/coverage/printer.go b/coverage/printer.go similarity index 100% rename from pkg/coverage/printer.go rename to coverage/printer.go diff --git a/pkg/coverage/printer_test.go b/coverage/printer_test.go similarity index 100% rename from pkg/coverage/printer_test.go rename to coverage/printer_test.go diff --git a/pkg/coverage/simplecov.go b/coverage/simplecov.go similarity index 100% rename from pkg/coverage/simplecov.go rename to coverage/simplecov.go diff --git a/pkg/coverage/simplecov_test.go b/coverage/simplecov_test.go similarity index 100% rename from pkg/coverage/simplecov_test.go rename to coverage/simplecov_test.go diff --git a/pkg/coverage/testdata/clover/coverage.xml b/coverage/testdata/clover/coverage.xml similarity index 100% rename from pkg/coverage/testdata/clover/coverage.xml rename to coverage/testdata/clover/coverage.xml diff --git a/pkg/coverage/testdata/clover/coverage_package.xml b/coverage/testdata/clover/coverage_package.xml similarity index 100% rename from pkg/coverage/testdata/clover/coverage_package.xml rename to coverage/testdata/clover/coverage_package.xml diff --git a/pkg/coverage/testdata/cobertura/coverage.xml b/coverage/testdata/cobertura/coverage.xml similarity index 100% rename from pkg/coverage/testdata/cobertura/coverage.xml rename to coverage/testdata/cobertura/coverage.xml diff --git a/pkg/coverage/testdata/gocover/coverage.out b/coverage/testdata/gocover/coverage.out similarity index 100% rename from pkg/coverage/testdata/gocover/coverage.out rename to coverage/testdata/gocover/coverage.out diff --git a/pkg/coverage/testdata/jacoco/jacocoTestReport.xml b/coverage/testdata/jacoco/jacocoTestReport.xml similarity index 100% rename from pkg/coverage/testdata/jacoco/jacocoTestReport.xml rename to coverage/testdata/jacoco/jacocoTestReport.xml diff --git a/pkg/coverage/testdata/lcov/lcov.info b/coverage/testdata/lcov/lcov.info similarity index 100% rename from pkg/coverage/testdata/lcov/lcov.info rename to coverage/testdata/lcov/lcov.info diff --git a/pkg/coverage/testdata/simplecov/.resultset.another.json b/coverage/testdata/simplecov/.resultset.another.json similarity index 100% rename from pkg/coverage/testdata/simplecov/.resultset.another.json rename to coverage/testdata/simplecov/.resultset.another.json diff --git a/pkg/coverage/testdata/simplecov/.resultset.json b/coverage/testdata/simplecov/.resultset.json similarity index 100% rename from pkg/coverage/testdata/simplecov/.resultset.json rename to coverage/testdata/simplecov/.resultset.json diff --git a/pkg/coverage/testdata/simplecov/.resultset.parallel.json b/coverage/testdata/simplecov/.resultset.parallel.json similarity index 100% rename from pkg/coverage/testdata/simplecov/.resultset.parallel.json rename to coverage/testdata/simplecov/.resultset.parallel.json diff --git a/pkg/coverage/testdata/simplecov/.resultset2.json b/coverage/testdata/simplecov/.resultset2.json similarity index 100% rename from pkg/coverage/testdata/simplecov/.resultset2.json rename to coverage/testdata/simplecov/.resultset2.json diff --git a/docs/term.svg b/docs/term.svg index 6220924e..d607fe4b 100644 --- a/docs/term.svg +++ b/docs/term.svg @@ -1 +1 @@ ->>o>oc>oct>octo>octoc>octocov>octocovls-files71.1%[91/128]central/central.go57.7%[15/26]config/build.go42.7%[35/82]config/config.go22.7%[20/88]config/ready.go46.6%[41/88]datastore/datastore.go76.5%[13/17]internal/path.go90.0%[36/40]pkg/coverage/clover.go91.7%[44/48]pkg/coverage/cobertura.go82.7%[67/81]pkg/coverage/coverage.go90.9%[40/44]pkg/coverage/gocover.go89.4%[59/66]pkg/coverage/lcov.go94.0%[78/83]pkg/coverage/printer.go87.2%[34/39]pkg/coverage/simplecov.go59.6%[31/52]pkg/ratio/copy_from_gocloc.go90.5%[76/84]pkg/ratio/ratio.go69.1%[130/188]report/diff_report.go47.5%[112/236]report/report.go>octocovview>octocovviewpkg/coverage/lcov.go|>octocovviewpkg/coverage/lcov.go|less>octocovviewpkg/coverage/lcov.go|less-R1packagecoverage23import(4"bufio"5"errors"6"fmt"7"os"8"path/filepath"9"strconv"10"strings"11)1213var_Processor=(*Lcov)(nil)1415varLcovDefaultPath=[]string{"coverage","lcov.info"}1617typeLcovstruct{}18196funcNewLcov()*Lcov{206return&Lcov{}216}22236func(l*Lcov)Name()string{246return"LCOV":256}26276func(l*Lcov)ParseReport(pathstring)(*Coverage,string,error){286rp,err:=l.detectReportPath(path)296iferr!=nil{30returnnil,"",err31}326r,err:=os.Open(filepath.Clean(rp))336iferr!=nil{34returnnil,"",err35}366deferfunc(){376_=r.Close()386}()396scanner:=bufio.NewScanner(r)406var(416fileNamestring426total,coveredint436)446cov:=New()456cov.Type=TypeLOC466cov.Format=l.Name()476parsed:=false486blocks:=BlockCoverages{}4943258forscanner.Scan(){5043258l:=scanner.Text()5143258ifl=="end_of_record"{5242fcov,err:=cov.Files.FindByFile(fileName)5342iferr!=nil{5442fcov=NewFileCoverage(fileName)5542}5642fcov.Total+=total5742fcov.Covered+=covered5842fcov.Blocks=blocks5942cov.Total+=total6042cov.Covered+=covered6142cov.Files=append(cov.Files,fcov)6242total=06342covered=06442parsed=true6542blocks=BlockCoverages{}6642continue67}6843216splitted:=strings.Split(l,":")6943216iflen(splitted)!=2{7038386continue71}724830switchsplitted[0]{7342case"SF":7442fileName=splitted[1]752404case"DA":762404total+=1772404nums:=strings.Split(splitted[1],",")782404iflen(nums)!=2{79returnnil,"",fmt.Errorf("cannotparse:%s",l)80}812404line,err:=strconv.Atoi(nums[0])822404iferr!=nil{83returnnil,"",err84}852404count,err:=strconv.Atoi(nums[1])862404iferr!=nil{87returnnil,"",err88}892404ifcount>0{902294covered+=1912294}922404blocks=append(blocks,&BlockCoverage{932404Type:TypeLOC,942404StartLine:&line,952404EndLine:&line,962404Count:&count,972404})982384default:99//notimplemented100}101}1026if!parsed{1034returnnil,"",errors.New("cannotparse")1044}1052returncov,rp,nil106}1071086func(s*Lcov)detectReportPath(pathstring)(string,error){1096p,err:=os.Stat(path)1106iferr!=nil{111return"",err112}1136ifp.IsDir(){1141//path/to/coverage/lcov.info1151np:=filepath.Join(path,LcovDefaultPath[0],LcovDefaultPath[1])1161if_,err:=os.Stat(np);err!=nil{1171//path/to/lcov.info1181np=filepath.Join(path,LcovDefaultPath[1])1191if_,err:=os.Stat(np);err!=nil{>octocovl>octocovls>octocovls->octocovls-f>octocovls-fi>octocovls-fil>octocovls-file>octocovv>octocovvi>octocovvie>octocovviewp>octocovviewpk>octocovviewpkg>octocovviewpkg/>octocovviewpkg/c>octocovviewpkg/co>octocovviewpkg/cov>octocovviewpkg/coverage/>octocovviewpkg/coverage/l>octocovviewpkg/coverage/lc>octocovviewpkg/coverage/lcov>octocovviewpkg/coverage/lcov.>octocovviewpkg/coverage/lcov.go>octocovviewpkg/coverage/lcov.go|l>octocovviewpkg/coverage/lcov.go|le>octocovviewpkg/coverage/lcov.go|les>octocovviewpkg/coverage/lcov.go|less-8989240120return"",err121}122}1231path=np124}1256returnpath,nil126}(END) \ No newline at end of file +>>o>oc>oct>octo>octoc>octocov>octocovls-files71.1%[91/128]central/central.go57.7%[15/26]config/build.go42.7%[35/82]config/config.go22.7%[20/88]config/ready.go46.6%[41/88]datastore/datastore.go76.5%[13/17]internal/path.go90.0%[36/40]coverage/clover.go91.7%[44/48]coverage/cobertura.go82.7%[67/81]coverage/coverage.go90.9%[40/44]coverage/gocover.go89.4%[59/66]coverage/lcov.go94.0%[78/83]coverage/printer.go87.2%[34/39]coverage/simplecov.go59.6%[31/52]ratio/copy_from_gocloc.go90.5%[76/84]ratio/ratio.go69.1%[130/188]report/diff_report.go47.5%[112/236]report/report.go>octocovview>octocovviewcoverage/lcov.go|>octocovviewcoverage/lcov.go|less>octocovviewcoverage/lcov.go|less-R1packagecoverage23import(4"bufio"5"errors"6"fmt"7"os"8"path/filepath"9"strconv"10"strings"11)1213var_Processor=(*Lcov)(nil)1415varLcovDefaultPath=[]string{"coverage","lcov.info"}1617typeLcovstruct{}18196funcNewLcov()*Lcov{206return&Lcov{}216}22236func(l*Lcov)Name()string{246return"LCOV":256}26276func(l*Lcov)ParseReport(pathstring)(*Coverage,string,error){286rp,err:=l.detectReportPath(path)296iferr!=nil{30returnnil,"",err31}326r,err:=os.Open(filepath.Clean(rp))336iferr!=nil{34returnnil,"",err35}366deferfunc(){376_=r.Close()386}()396scanner:=bufio.NewScanner(r)406var(416fileNamestring426total,coveredint436)446cov:=New()456cov.Type=TypeLOC466cov.Format=l.Name()476parsed:=false486blocks:=BlockCoverages{}4943258forscanner.Scan(){5043258l:=scanner.Text()5143258ifl=="end_of_record"{5242fcov,err:=cov.Files.FindByFile(fileName)5342iferr!=nil{5442fcov=NewFileCoverage(fileName)5542}5642fcov.Total+=total5742fcov.Covered+=covered5842fcov.Blocks=blocks5942cov.Total+=total6042cov.Covered+=covered6142cov.Files=append(cov.Files,fcov)6242total=06342covered=06442parsed=true6542blocks=BlockCoverages{}6642continue67}6843216splitted:=strings.Split(l,":")6943216iflen(splitted)!=2{7038386continue71}724830switchsplitted[0]{7342case"SF":7442fileName=splitted[1]752404case"DA":762404total+=1772404nums:=strings.Split(splitted[1],",")782404iflen(nums)!=2{79returnnil,"",fmt.Errorf("cannotparse:%s",l)80}812404line,err:=strconv.Atoi(nums[0])822404iferr!=nil{83returnnil,"",err84}852404count,err:=strconv.Atoi(nums[1])862404iferr!=nil{87returnnil,"",err88}892404ifcount>0{902294covered+=1912294}922404blocks=append(blocks,&BlockCoverage{932404Type:TypeLOC,942404StartLine:&line,952404EndLine:&line,962404Count:&count,972404})982384default:99//notimplemented100}101}1026if!parsed{1034returnnil,"",errors.New("cannotparse")1044}1052returncov,rp,nil106}1071086func(s*Lcov)detectReportPath(pathstring)(string,error){1096p,err:=os.Stat(path)1106iferr!=nil{111return"",err112}1136ifp.IsDir(){1141//path/to/coverage/lcov.info1151np:=filepath.Join(path,LcovDefaultPath[0],LcovDefaultPath[1])1161if_,err:=os.Stat(np);err!=nil{1171//path/to/lcov.info1181np=filepath.Join(path,LcovDefaultPath[1])1191if_,err:=os.Stat(np);err!=nil{>octocovl>octocovls>octocovls->octocovls-f>octocovls-fi>octocovls-fil>octocovls-file>octocovv>octocovvi>octocovvie>octocovviewp>octocovviewpk>octocovviewpkg>octocovviewpkg/>octocovviewpkg/c>octocovviewpkg/co>octocovviewpkg/cov>octocovviewcoverage/>octocovviewcoverage/l>octocovviewcoverage/lc>octocovviewcoverage/lcov>octocovviewcoverage/lcov.>octocovviewcoverage/lcov.go>octocovviewcoverage/lcov.go|l>octocovviewcoverage/lcov.go|le>octocovviewcoverage/lcov.go|les>octocovviewcoverage/lcov.go|less-8989240120return"",err121}122}1231path=np124}1256returnpath,nil126}(END) \ No newline at end of file diff --git a/pkg/pplang/README.md b/pplang/README.md similarity index 100% rename from pkg/pplang/README.md rename to pplang/README.md diff --git a/pkg/pplang/pplang.go b/pplang/pplang.go similarity index 100% rename from pkg/pplang/pplang.go rename to pplang/pplang.go diff --git a/pkg/pplang/pplang_test.go b/pplang/pplang_test.go similarity index 97% rename from pkg/pplang/pplang_test.go rename to pplang/pplang_test.go index 6f7f456b..47d6d966 100644 --- a/pkg/pplang/pplang_test.go +++ b/pplang/pplang_test.go @@ -18,7 +18,7 @@ func TestDetect(t *testing.T) { if err != nil { t.Fatal(err) } - dir, err := filepath.Abs(filepath.Dir(filepath.Dir(wd))) + dir, err := filepath.Abs(filepath.Dir(wd)) if err != nil { t.Fatal(err) } diff --git a/pkg/pplang/testdata/gitconfig.txtar b/pplang/testdata/gitconfig.txtar similarity index 100% rename from pkg/pplang/testdata/gitconfig.txtar rename to pplang/testdata/gitconfig.txtar diff --git a/pkg/pplang/testdata/go.txtar b/pplang/testdata/go.txtar similarity index 100% rename from pkg/pplang/testdata/go.txtar rename to pplang/testdata/go.txtar diff --git a/pkg/pplang/testdata/none.txtar b/pplang/testdata/none.txtar similarity index 100% rename from pkg/pplang/testdata/none.txtar rename to pplang/testdata/none.txtar diff --git a/pkg/ratio/copy_from_gocloc.go b/ratio/copy_from_gocloc.go similarity index 100% rename from pkg/ratio/copy_from_gocloc.go rename to ratio/copy_from_gocloc.go diff --git a/pkg/ratio/merge.go b/ratio/merge.go similarity index 100% rename from pkg/ratio/merge.go rename to ratio/merge.go diff --git a/pkg/ratio/merge_test.go b/ratio/merge_test.go similarity index 100% rename from pkg/ratio/merge_test.go rename to ratio/merge_test.go diff --git a/pkg/ratio/ratio.go b/ratio/ratio.go similarity index 100% rename from pkg/ratio/ratio.go rename to ratio/ratio.go diff --git a/pkg/ratio/ratio_test.go b/ratio/ratio_test.go similarity index 90% rename from pkg/ratio/ratio_test.go rename to ratio/ratio_test.go index b4455c9c..be275996 100644 --- a/pkg/ratio/ratio_test.go +++ b/ratio/ratio_test.go @@ -103,7 +103,7 @@ func TestPathMatch(t *testing.T) { if err != nil { t.Fatal(err) } - want := "pkg/ratio/ratio_test.go" + want := "ratio/ratio_test.go" ok := false for _, f := range got.CodeFiles { if f.Path == want { @@ -111,7 +111,7 @@ func TestPathMatch(t *testing.T) { } } if ok { - t.Error("pkg/ratio/ratio_test.go should not be contained") + t.Error("ratio/ratio_test.go should not be contained") } } @@ -124,7 +124,7 @@ func TestPathMatch(t *testing.T) { if err != nil { t.Fatal(err) } - want := "pkg/ratio/ratio_test.go" + want := "ratio/ratio_test.go" ok := false for _, f := range got.CodeFiles { if f.Path == want { @@ -132,7 +132,7 @@ func TestPathMatch(t *testing.T) { } } if !ok { - t.Error("pkg/ratio/ratio_test.go should be contained") + t.Error("ratio/ratio_test.go should be contained") } } } @@ -162,7 +162,7 @@ func testdataDir(t *testing.T) string { if err != nil { t.Fatal(err) } - dir, err := filepath.Abs(filepath.Join(filepath.Dir(filepath.Dir(wd)), "testdata")) + dir, err := filepath.Abs(filepath.Join(filepath.Dir(wd), "testdata")) if err != nil { t.Fatal(err) } diff --git a/report/diff_report.go b/report/diff_report.go index 165d6f45..8e93d9ee 100644 --- a/report/diff_report.go +++ b/report/diff_report.go @@ -9,8 +9,8 @@ import ( "time" "github.com/k1LoW/octocov/gh" - "github.com/k1LoW/octocov/pkg/coverage" - "github.com/k1LoW/octocov/pkg/ratio" + "github.com/k1LoW/octocov/coverage" + "github.com/k1LoW/octocov/ratio" "github.com/olekukonko/tablewriter" ) diff --git a/report/report.go b/report/report.go index 7e2b2501..123c627a 100644 --- a/report/report.go +++ b/report/report.go @@ -17,8 +17,8 @@ import ( "github.com/goccy/go-json" "github.com/hashicorp/go-multierror" "github.com/k1LoW/octocov/gh" - "github.com/k1LoW/octocov/pkg/coverage" - "github.com/k1LoW/octocov/pkg/ratio" + "github.com/k1LoW/octocov/coverage" + "github.com/k1LoW/octocov/ratio" "github.com/olekukonko/tablewriter" "github.com/samber/lo" ) diff --git a/report/report_test.go b/report/report_test.go index 3e705728..df3e1a44 100644 --- a/report/report_test.go +++ b/report/report_test.go @@ -13,9 +13,9 @@ import ( "github.com/goccy/go-json" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/k1LoW/octocov/coverage" "github.com/k1LoW/octocov/gh" - "github.com/k1LoW/octocov/pkg/coverage" - "github.com/k1LoW/octocov/pkg/ratio" + "github.com/k1LoW/octocov/ratio" ) func TestNew(t *testing.T) { @@ -530,7 +530,7 @@ func coverageTestdataDir(t *testing.T) string { if err != nil { t.Fatal(err) } - dir, err := filepath.Abs(filepath.Join(filepath.Dir(wd), "pkg", "coverage", "testdata")) + dir, err := filepath.Abs(filepath.Join(filepath.Dir(wd), "coverage", "testdata")) if err != nil { t.Fatal(err) } diff --git a/testdata/octocov_parallel_tests.yml b/testdata/octocov_parallel_tests.yml index 02a1f1fe..7a7053eb 100644 --- a/testdata/octocov_parallel_tests.yml +++ b/testdata/octocov_parallel_tests.yml @@ -8,9 +8,9 @@ coverage: - ../coverage_other.out testExecutionTime: steps: - - Run tests pkg/coverage - - Run tests pkg/ratio - - Run tests pkg/badge + - Run tests coverage + - Run tests ratio + - Run tests badge - Run tests other comment: if: false