diff --git a/.github/workflows/go.yml b/.github/workflows/codecov.yml similarity index 73% rename from .github/workflows/go.yml rename to .github/workflows/codecov.yml index 91c00220..120f6e98 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/codecov.yml @@ -1,10 +1,6 @@ name: Go -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] +on: [push, pull_request] jobs: @@ -16,7 +12,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.22.3 + go-version: 1.19.12 - name: Clang run: | @@ -49,14 +45,13 @@ jobs: - name: Coverage run: | go get -u github.com/wadey/gocovmerge - go get -u github.com/Konstantin8105/cs + go install github.com/ory/go-acc@latest go get -u golang.org/x/sys/unix - go test -run=TestIntegrationScripts/tests/ctype.c -coverprofile=coverage.txt -covermode=atomic - # TRAVIS=true ./scripts/test.sh - + TRAVIS=true ./scripts/test.sh + - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: - token: ${{ secrets.CODECOV_ORG_TOKEN }} - verbose: true # optional (default = false) + token: ${{ secrets.CODECOV_TOKEN }} file: coverage.txt + #verbose: true # optional (default = false) diff --git a/scripts/test.sh b/scripts/test.sh index e3907531..b0605756 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -2,43 +2,38 @@ set -e -echo "" > coverage.txt - +# Initialize mkdir -p ./testdata/ -# Package list -export PKGS=$(go list ./... | grep -v c4go/testdata | grep -v c4go/examples | grep -v c4go/tests | grep -v /vendor/ | tr '\n' ' ') +# github.com/Konstantin8105/c4go +# github.com/Konstantin8105/c4go/ast +# github.com/Konstantin8105/c4go/examples // ignore +# github.com/Konstantin8105/c4go/noarch +# github.com/Konstantin8105/c4go/preprocessor +# github.com/Konstantin8105/c4go/program +# github.com/Konstantin8105/c4go/scripts +# github.com/Konstantin8105/c4go/testdata // ignore +# github.com/Konstantin8105/c4go/tests // ignore +# github.com/Konstantin8105/c4go/transpiler +# github.com/Konstantin8105/c4go/types +# github.com/Konstantin8105/c4go/util +# github.com/Konstantin8105/c4go/version -# Make comma-separated. -export PKGS_DELIM=$(echo "$PKGS" | tr ' ' ',') +# Package list +export PKGS=$(go list -e ./... | grep -v testdata | grep -v examples | grep -v tests | grep -v vendor | tr '\n' ' ') +# export PKGS="github.com/Konstantin8105/c4go github.com/Konstantin8105/c4go/util" +# View echo "PKGS : $PKGS" -echo "PKGS_DELIM : $PKGS_DELIM" - -go test \ - -cover \ - -timeout=30m \ - -coverpkg=$PKGS_DELIM \ - -coverprofile=./testdata/pkg.coverprofile $PKGS - -# Merge coverage profiles. -COVERAGE_FILES=`ls -1 ./testdata/*.coverprofile 2>/dev/null | wc -l` -if [ $COVERAGE_FILES != 0 ]; then - # check program `gocovmerge` is exist - if which gocovmerge >/dev/null 2>&1; then - export FILES=$(ls testdata/*.coverprofile | tr '\n' ' ') - echo "Combine next coverprofiles : $FILES" - gocovmerge $FILES > coverage.txt - fi -fi - -# echo "" > coverage.out -# for d in $(go list ./... | grep -v vendor); do -# go test -v -race -coverprofile=profile.out -covermode=atomic $d -# if [ -f profile.out ]; then -# cat profile.out >> coverage.out -# rm profile.out -# fi -# done +# Initialize +touch ./coverage.tmp + +# Run tests +echo 'mode: atomic' > coverage.txt +# go list -e ./... | grep -v testdata | grep -v examples | grep -v tests | grep -v vendor | grep -v cmd | xargs -n100 -I{} sh -c 'go test -covermode=atomic -coverprofile=coverage.tmp -coverpkg $(go list -e ./... | grep -v testdata | grep -v examples | grep -v tests | grep -v vendor | grep -v cmd | tr "\n" ",") {} && tail -n +2 coverage.tmp >> coverage.txt || exit 255' && rm coverage.tmp + +echo "$PKGS" | xargs -n100 -I{} sh -c 'go test -covermode=atomic -coverprofile=coverage.tmp -coverpkg $(echo "$PKGS" | tr " " ",") {} && tail -n +2 coverage.tmp >> coverage.txt || exit 255' && rm coverage.tmp + +# Finilize echo "End of coverage" diff --git a/util/util.go b/util/util.go index e4dd5eaf..09e7f434 100644 --- a/util/util.go +++ b/util/util.go @@ -87,10 +87,10 @@ func IsLastArray(s string) bool { // ParseFunction - parsing elements of C function func ParseFunction(s string) (prefix string, funcname string, f []string, r []string, err error) { defer func() { - if len(f) == 1 && f[0] == "void" { - f = nil - } - + // fix bug in tests: + // if len(f) == 1 && f[0] == "void" { + // f = nil + // } if err != nil { err = fmt.Errorf("cannot parse function '%s' : %v", s, err) } else { diff --git a/util/util_test.go b/util/util_test.go index c1c5cb83..edc1b8c3 100644 --- a/util/util_test.go +++ b/util/util_test.go @@ -275,19 +275,19 @@ func TestResolveFunction(t *testing.T) { if len(actualField) != len(tc.fields) { a, _ := json.Marshal(actualField) f, _ := json.Marshal(tc.fields) - t.Errorf("Size of field is not same.\nActual : %s\nExpected: %s\n", - string(a), - string(f)) - return - } - if len(actualField) != len(tc.fields) { - a, _ := json.Marshal(actualField) - f, _ := json.Marshal(tc.fields) - t.Errorf("Size of field is not same.\nActual : %s\nExpected: %s\n", + t.Errorf("Size of field is not same.\nActual : `%s`\nExpected: `%s`\n", string(a), string(f)) return } + // if len(actualField) != len(tc.fields) { + // a, _ := json.Marshal(actualField) + // f, _ := json.Marshal(tc.fields) + // t.Errorf("Size of field is not same.\nActual : `%s`\nExpected: `%s`\n", + // string(a), + // string(f)) + // return + // } for i := range actualField { actualField[i] = strings.Replace(actualField[i], " ", "", -1) tc.fields[i] = strings.Replace(tc.fields[i], " ", "", -1)