Skip to content

Commit

Permalink
tidy, massively increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
CamJN committed Oct 16, 2023
1 parent 3225eaa commit af406f0
Show file tree
Hide file tree
Showing 18 changed files with 537 additions and 436 deletions.
30 changes: 30 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
BasedOnStyle: LLVM
Language: Cpp
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignConsecutiveMacros: true
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortEnumsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
BinPackArguments: false
BinPackParameters: false
BreakStringLiterals: false
ColumnLimit: 0
ReflowComments: false
CommentPragmas: '(pragma|clang)'
Cpp11BracedListStyle: false
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
KeepEmptyLinesAtTheStartOfBlocks: false
PointerAlignment: Left
SpaceBeforeCpp11BracedList: true
BreakBeforeBinaryOperators: NonAssignment
AttributeMacros:
- inline
- noreturn
- unused
---
7 changes: 7 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Checks: '*,-fuchsia-*,-llvmlibc-*-namespace,-altera-struct-pack-align,-cppcoreguidelines-pro-bounds-pointer-arithmetic'

CheckOptions:
- key: llvmlibc-restrict-system-libc-headers.Includes
value: -*,string,system_error,vector,iterator,algorithm
- key: portability-restrict-system-includes.Includes
value: -*,string,system_error,vector,iterator,algorithm
19 changes: 19 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CompileFlags:
Add:
- '-I'
- /usr/local/include

---
If:
PathMatch: test/src/.*

CompileFlags:
CompilationDatabase: "test"

Diagnostics:
ClangTidy:
Remove:
- cppcoreguidelines-pro-bounds-pointer-arithmetic
- llvmlibc-*-namespace
- altera-struct-pack-align
- fuchsia-*
105 changes: 105 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: C++/make CI

on:
push:
branches: [ master ]
tags: [ '*' ]
pull_request:
branches: [ master ]

jobs:
check:
name: Check code
runs-on: macos-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- name: check
run: make lint

test:
name: Test on ${{ matrix.os }}
timeout-minutes: 10
strategy:
matrix:
os:
- macos-13
- macos-12
- macos-11
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: test
steps:
- uses: actions/checkout@v3
- name: install deps
run: |
brew update
brew install --force-bottle criterion
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: yes
HOMEBREW_NO_ENV_HINTS: yes
HOMEBREW_NO_ANALYTICS: yes
- name: build unit tests
run: |
make unit_tests
make lib_unit_tests
- name: build libtests
run: |
make libtest1
make libtest2
- name: run tests with coverage
if: matrix.os != 'macos-10.15'
run: |
make run_unit_tests_coverage
make run_lib_unit_tests_coverage
timeout-minutes: 5
- name: run tests without coverage
if: matrix.os == 'macos-10.15'
run: |
make run_unit_tests
make run_lib_unit_tests
timeout-minutes: 5

build:
name: Build on ${{ matrix.os }}
timeout-minutes: 5
needs: [ check, test ]
strategy:
matrix:
os:
- macos-13
- macos-12
- macos-11
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: make exe
run: make CPU_FLAGS="" MACOS_VER_MINOR=0 release
- name: make CPU_FLAGS="" MACOS_VER_MINOR=0 library
run: make dylib
- name: make installer
run: make dmg
- name: rename dmg
run: mv pkg/*.dmg pkg/getargv-${{ matrix.os }}.dmg
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}.zip
path: |
pkg/*.pkg
pkg/*.dmg
release:
if: ${{ github.ref_type == 'tag' }}
needs: [ build ]
timeout-minutes: 5
runs-on: macos-latest
steps:
- uses: actions/download-artifact@v3
with:
path: pkg
- name: Release
uses: softprops/action-gh-release@v1
with:
files: pkg/*.zip/*.dmg
name: ${{ github.ref_name }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ compile_commands.json
/test/obj
/test/share
default.profraw
/test/include
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ PREFIX := /usr/local
CXX=clang++
CPPFLAGS += -MMD -MP
CXXFLAGS := --std=c++20 -O3 -Iinclude
# must be c++20 or greater, before that c++ cannot correctly represent the semantics of this library, due to a change in copy/move semantics
# supported: c++11, c++14, c++17, c++20
# future: c++2b
EXTRA_CXXFLAGS := -pedantic-errors -Weverything -Wno-c++98-compat -Wno-pre-c++20-compat-pedantic -Wno-poison-system-directories
LDFLAGS += -Llib -fvisibility=default -fPIC
LDLIBS += -lgetargv
Expand Down
Loading

0 comments on commit af406f0

Please sign in to comment.