Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Oct 11, 2023
1 parent cbaac53 commit 4f9f1fa
Show file tree
Hide file tree
Showing 6 changed files with 416 additions and 453 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/code_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ concurrency:
cancel-in-progress: true

jobs:
linux:
uses: ./.github/workflows/linux_ci.yml
linux-tcc:
uses: ./.github/workflows/linux_tcc_ci.yml

linux-gcc:
uses: ./.github/workflows/linux_gcc_ci.yml

linux-clang:
uses: ./.github/workflows/linux_clang_ci.yml

macos:
uses: ./.github/workflows/macos_ci.yml
Expand Down
163 changes: 99 additions & 64 deletions .github/workflows/linux_clang_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ name: CI Linux (Clang)
on:
workflow_call:

env:
VFLAGS: -cc clang
CC: clang

jobs:
setup:
build:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc clang
steps:
- uses: actions/checkout@v3
- name: Install dependencies
Expand All @@ -19,7 +20,7 @@ jobs:
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install --quiet -y clang
- name: Build V
run: make -j4 && ./v -cc clang -cg -cstrict -o v cmd/v
run: make -j4 && ./v -cc ${{ env.CC }} -cg -cstrict -o v cmd/v
- name: Valgrind
run: valgrind --error-exitcode=1 ./v -o v.c cmd/v
- name: Run sanitizers
Expand All @@ -42,100 +43,79 @@ jobs:
./v2 -o v3 -usecache cmd/v
./v3 version
./v3 -o tetris -usecache examples/tetris/tetris.v
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: ./v test-cleancode
- name: Test pure V math module
run: ./v -exclude @vlib/math/*.c.v test vlib/math/
- name: Cache
uses: actions/cache/save@v3
with:
path: ./
key: ${{ runner.os }}-clang-${{ github.sha }}

# TODO: matrix for self tests
self-test:
needs: setup
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc clang
steps:
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: ./
key: ${{ runner.os }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Self tests
run: ./v test-self
# - name: Self tests (vprod)
# run: |
# ./v -o vprod -prod cmd/v
# ./vprod test-self
# - name: Self tests (-cstrict)
# run: VTEST_JUST_ESSENTIAL=1 V_CI_CSTRICT=1 ./vprod -cstrict test-self
key: ${{ runner.os }}-${{ env.CC }}-${{ github.sha }}

test-prod:
needs: setup
verify:
needs: build
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc clang
steps:
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: ./
key: ${{ runner.os }}-${{ github.sha }}
key: ${{ runner.os }}-${{ env.CC }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Self tests (vprod)
- name: Verify `v test` works
run: |
./v -o vprod -prod cmd/v
./vprod test-self
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: ./v test-cleancode
- name: Test pure V math module
run: ./v -exclude @vlib/math/*.c.v test vlib/math/

test-strict:
needs: setup
test:
needs: verify
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc clang
timeout-minutes: 90
strategy:
matrix:
optimization: ['', '-prod', '-cstrict']
include:
- optimization: '-cstrict'
env: 'VTEST_JUST_ESSENTIAL=1 V_CI_CSTRICT=1'
fail-fast: false
steps:
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: ./
key: ${{ runner.os }}-${{ github.sha }}
key: ${{ runner.os }}-${{ env.CC }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Self tests (-cstrict)
run: VTEST_JUST_ESSENTIAL=1 V_CI_CSTRICT=1 ./vprod -cstrict test-self
- name: Self Test
run: |
if [ "${{ matrix.optimization }}" == "-prod" ]; then
./v -o vprod -prod cmd/v
./vprod test-self
else
# TODO: remove echos
echo $VFLAGS
echo ${{ matrix.env }}
${{ matrix.env }} ./v ${{ matrix.optimization }} test-self
fi
examples-modules:
needs: setup
build-modules-examples:
needs: verify
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc clang
steps:
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: ./
key: ${{ runner.os }}-${{ github.sha }}
key: ${{ runner.os }}-${{ env.CC }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Build examples
run: ./v build-examples
- name: Build examples with -autofree
run: |
./v -autofree -experimental -o tetris examples/tetris/tetris.v
run: ./v -autofree -experimental -o tetris examples/tetris/tetris.v
- name: Build modules
run: |
./v build-module vlib/os
Expand All @@ -162,4 +142,59 @@ jobs:
echo "Building it..."
../../vprod -backend native -o 1m 1m.v
echo "Running it..."
# ./1m
ls
test-sanitized:
needs: verify
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 120
strategy:
matrix:
sanitizer: ['undefined', 'memory', 'address']
fail-fast: false
env:
VJOBS: 1
VTEST_SHOW_START: 1
steps:
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: ./
key: ${{ runner.os }}-${{ env.CC }}-${{ github.sha }}
fail-on-cache-miss: true
# TODO: compare with current if maybe building V again is neccesayr
- name: Build V # Use a V binary that was compiled with a sanitizer to run self tests.
run: ./v -cflags -fsanitize=${{ matrix.sanitizer }} -o v2 cmd/v
- name: Self Test
run: |
if [ "${{ matrix.sanitizer }}" == "address" ]; then
ASAN_OPTIONS=detect_leaks=0 ./v2 -cc tcc test-self -asan-compiler
elif [ "${{ matrix.sanitizer }}" == "memory" ]; then
./v2 -cc tcc test-self -msan-compiler
else
./v2 -cflags -fsanitize=${{ matrix.sanitizer }} test-self
fi
build-examples-sanitized:
needs: verify
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
strategy:
matrix:
sanitizer: ['undefined', 'memory', 'address']
include:
- optimization: 'address'
env: 'ASAN_OPTIONS=detect_leaks=0'
steps:
- name: Restore Cache
uses: actions/cache/restore@v3
with:
path: ./
key: ${{ runner.os }}-${{ env.CC }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Build V # Use a V binary that was compiled with a sanitizer to build examples.
run: ./v -cflags -fsanitize=${{ matrix.sanitizer }} -o v cmd/v
- name: Build Examples
run: ${{ matrix.env }} ./v build-examples
Loading

0 comments on commit 4f9f1fa

Please sign in to comment.