Skip to content

Commit

Permalink
tests: add v test-all, move v test-fixed to v test-compiler-full
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Jan 17, 2021
1 parent e4850cd commit 460f32b
Show file tree
Hide file tree
Showing 14 changed files with 227 additions and 167 deletions.
8 changes: 1 addition & 7 deletions .github/PULL_REQUEST_TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ fn test_foo() {

If you are fixing a bug, please add a test that covers it.

Before submitting a PR, please:
A) run the tests with `v test-compiler` .
B) make sure, that V can still compile itself:
```shell
./v -o v cmd/v
./v -o v cmd/v
```
Before submitting a PR, please run `v test-all` .
See also `TESTS.md`.

I try to process PRs as soon as possible. They should be handled within 24 hours.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/alpine.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ du -s .

ls -lat

##./v test-compiler
##./v test-all

## try running the known failing tests first to get faster feedback
./v test vlib/builtin/string_test.v vlib/strings/builder_test.v

./v test-fixed
./v test-compiler-full

./v build-vbinaries

Expand Down
46 changes: 23 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
run: |
thirdparty/tcc/tcc.exe -version
./v -cg -o v cmd/v # Make sure vtcc can build itself twice
# ./v -silent test-compiler
# ./v -silent test-all
- name: v self compilation
run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v && ./v3 -o v4 cmd/v
- name: v doctor
Expand All @@ -105,7 +105,7 @@ jobs:
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: Fixed tests
run: ./v -silent test-fixed
run: ./v -silent test-compiler-full
- name: Test time functions in a timezone UTC-12
run: TZ=Etc/GMT+12 ./v test vlib/time/
- name: Test time functions in a timezone UTC-3
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:
env
- name: Test V fixed tests
run: |
./v -silent test-fixed
./v -silent test-compiler-full
macos:
runs-on: macOS-latest
Expand Down Expand Up @@ -195,7 +195,7 @@ jobs:
# psql -d postgres -c 'create database customerdb;'
# psql -d customerdb -f examples/database/pg/mydb.sql
# - name: Test v->c
# run: ./v -silent test-compiler
# run: ./v -silent test-all
# - name: Test v binaries
# run: ./v build-vbinaries
## - name: Test v->js
Expand All @@ -205,7 +205,7 @@ jobs:
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: Fixed tests
run: VJOBS=1 ./v -silent test-fixed
run: VJOBS=1 ./v -silent test-compiler-full
- name: Build examples
run: ./v build-examples
- name: Build examples with -autofree
Expand Down Expand Up @@ -264,7 +264,7 @@ jobs:
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v3 -o v.c cmd/v
# - name: Test V
# run: ./v -silent test-compiler
# run: ./v -silent test-all
# - name: Test v binaries
# run: ./v build-vbinaries
## - name: Test v->js
Expand All @@ -287,9 +287,9 @@ jobs:
./cmd/tools/test_if_v_test_system_works
- name: Fixed tests
run: |
./v -silent test-fixed
./v -silent test-compiler-full
- name: Fixed tests (-prod)
run: ./v -o vprod -prod cmd/v && ./vprod -silent test-fixed
run: ./v -o vprod -prod cmd/v && ./vprod -silent test-compiler-full
- name: Build examples
run: ./v build-examples
- name: Build examples with -autofree
Expand Down Expand Up @@ -372,9 +372,9 @@ jobs:
./cmd/tools/test_if_v_test_system_works
- name: Fixed tests
run: |
./v -silent test-fixed
./v -silent test-compiler-full
- name: Fixed tests (-prod)
run: ./v -o vprod -prod cmd/v && ./vprod -silent test-fixed
run: ./v -o vprod -prod cmd/v && ./vprod -silent test-compiler-full
- name: Build examples
run: ./v build-examples
- name: Build examples with -autofree
Expand Down Expand Up @@ -429,7 +429,7 @@ jobs:
- name: Build V
run: make -j4 && ./v -cc clang -cg -cflags -Werror -o v cmd/v
- name: Fixed tests (-fsanitize=undefined)
run: ./v -cc clang -cflags "-fsanitize=undefined" -o v2 cmd/v && ./v2 -cflags -fsanitize=undefined test-fixed
run: ./v -cc clang -cflags "-fsanitize=undefined" -o v2 cmd/v && ./v2 -cflags -fsanitize=undefined test-compiler-full

tests-sanitize-address:
runs-on: ubuntu-20.04
Expand All @@ -452,7 +452,7 @@ jobs:
- name: Build V
run: make -j4 && ./v -cc clang -cg -cflags -Werror -o v cmd/v
- name: Fixed tests (-fsanitize=address)
run: ASAN_OPTIONS=detect_leaks=0 ./v -cflags -fsanitize=address test-fixed
run: ASAN_OPTIONS=detect_leaks=0 ./v -cflags -fsanitize=address test-compiler-full

tests-sanitize-memory:
runs-on: ubuntu-20.04
Expand All @@ -475,7 +475,7 @@ jobs:
- name: Build V
run: make -j4 && ./v -cc clang -cg -cflags -Werror -o v cmd/v
- name: Fixed tests (-fsanitize=memory)
run: ./v -cflags -fsanitize=memory test-fixed
run: ./v -cflags -fsanitize=memory test-compiler-full

# ubuntu-autofree-selfcompile:
# runs-on: ubuntu-20.04
Expand Down Expand Up @@ -516,7 +516,7 @@ jobs:
./cmd/tools/test_if_v_test_system_works
- name: Test V fixed tests
run: |
./v -silent test-fixed
./v -silent test-compiler-full
# ubuntu-musl:
# runs-on: ubuntu-20.04
Expand Down Expand Up @@ -544,7 +544,7 @@ jobs:
# - name: quick debug
# run: ./v -stats vlib/strconv/format_test.v
# - name: Fixed tests
# run: ./v -silent test-fixed
# run: ./v -silent test-compiler-full

ubuntu-llvm-mingw:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -581,10 +581,10 @@ jobs:
./cmd/tools/test_if_v_test_system_works
- name: Fixed tests
run: |
.\v.exe -silent test-fixed
.\v.exe -silent test-compiler-full
# - name: Test
# run: |
# .\v.exe -silent test-compiler
# .\v.exe -silent test-all
## v.js dosent work on windows
#.\v.exe -o hi.js examples/hello_v_js.v
#node hi.js
Expand Down Expand Up @@ -623,13 +623,13 @@ jobs:
./cmd/tools/test_if_v_test_system_works
- name: Fixed tests
run: |
./v -cg cmd\tools\vtest-fixed.v
./v -silent test-fixed
./v -cg cmd\tools\vtest-compiler-full.v
./v -silent test-compiler-full
- name: Build examples
run: ./v build-examples
# - name: Test
# run: |
# .\v.exe -silent test-compiler
# .\v.exe -silent test-all
# ## v.js dosent work on windows
#.\v.exe -o hi.js examples/hello_v_js.v
#node hi.js
Expand Down Expand Up @@ -659,10 +659,10 @@ jobs:
.\cmd\tools\test_if_v_test_system_works.exe
- name: Fixed tests
run: |
.\v.exe -silent test-fixed
.\v.exe -silent test-compiler-full
# - name: Test
# run: |
# .\v.exe -silent test-compiler
# .\v.exe -silent test-all
## v.js dosent work on windows
#.\v.exe -o hi.js examples/hello_v_js.v
#node hi.js
Expand Down Expand Up @@ -728,7 +728,7 @@ jobs:
- name: V self compilation with g++
run: ./v -cc g++-9 -o v2 cmd/v && ./v2 -cc g++-9 -o v3 cmd/v
## - name: Running tests with g++
## run: ./v -cc g++-9 -silent test-fixed
## run: ./v -cc g++-9 -silent test-compiler-full

install-modules:
runs-on: ubuntu-20.04
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/periodic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Symlink V
run: sudo ./v symlink
- name: Run network tests
run: ./v -d network -silent test-fixed
run: ./v -d network -silent test-compiler-full


network-tests-macos:
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Ensure thirdparty/cJSON/cJSON.o is compiled, before running tests.
run: ./v examples/json.v
- name: Run network tests
run: ./v -d network -silent test-fixed
run: ./v -d network -silent test-compiler-full


network-windows-msvc:
Expand All @@ -55,4 +55,4 @@ jobs:
echo $VFLAGS
.\make.bat -msvc
- name: Run network tests
run: .\v.exe -d network -silent test-fixed
run: .\v.exe -d network -silent test-compiler-full
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ feature/bugfix* that you make.

### Testing your commits locally:
You can test locally whether your changes have not broken something by
running: `v test-compiler`. See `TESTS.md` for more details.
running: `v test-all`. See `TESTS.md` for more details.

### Publishing your commits to GitHub:

Expand Down
79 changes: 48 additions & 31 deletions TESTS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Automated tests

TLDR: run `v test-all` locally, after making your changes,
and before submitting PRs.

## Notes
In the `v` repo there are several different tests. The main types are:

* `_test.v` tests - check that `test_` functions succeed. These can be
Expand All @@ -10,61 +14,74 @@ particularly useful for checking that errors are printed.

Tip: use `v -cc tcc` when compiling tests for speed.


## `v test-compiler`

This builds and tests:

* `vc` repo
* `_test.v` files
* examples
* `v install` a module

Some of these can be invoked separately.

## `vlib/v/compiler_errors_test.v`

This runs tests for:
* `checker/tests/*.vv`
* `parser/tests/*.vv`

## `vlib/v/tests`

General runnable program tests.
General runnable tests for different features of the V compiler.

## Actual code
## Test building of actual V programs (examples, tools, V itself)

* `v build-examples`
* `v build-tools`

## `v test-fixed`

Test `vlib`.
* `v build-examples`
* `v build-vbinaries`

## vfmt tests

In `vlib/v/fmt/` there's:
In `vlib/v/fmt/` there are::

* `fmt_test.v`
* `v vlib/v/fmt/fmt_test.v`

This checks `.out` tests.

* `fmt_keep_test.v`
* `v vlib/v/fmt/fmt_keep_test.v`

This verifies that `_keep.v` files would be unchanged by `vfmt -w`.

* `fmt_vlib_test.v`
* `v vlib/v/fmt/fmt_vlib_test.v`

This checks all source files are formatted and prints a summary. This
is not required.
This checks all source files are formatted and prints a summary.
This is not required.

## Other
* `v test-fmt`

Test all files in the current directory are formatted.

* `v run cmd/tools/check-md.v -hide-warnings -all`

Ensure that all .md files in the project are formatted properly,
and that the V code block examples in them can be compiled/formatted too.

## `.github/workflows/ci.yml`

This runs various CI tests, e.g.:

* `v vet vlib/v` - style checker
* `v fmt -verify` on certain source files

## `v test-cleancode`

Check that most .v files, are invariant of `v fmt` runs.

## `v test-compiler-full`

Run `vlib` module tests, *including* the compiler tests.

## `v vlib/v/compiler_errors_test.v`

This runs tests for:
* `checker/tests/*.vv`
* `parser/tests/*.vv`

## `v test-all`

Test and build *everything*. Usefull to verify *locally*, that the CI will
most likely pass. Slowest, but most comprehensive.

It works, by running these in succession:
* `v test-cleancode`
* `v test-compiler-full`
* `v test-fmt`
* `v build-tools`
* `v build-examples`
* `v run cmd/tools/check-md.v -hide-warnings -all`
* `v install nedpals.args`
14 changes: 6 additions & 8 deletions cmd/tools/check_os_api_parity.v
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const (
)

struct App {
diff_cmd string
is_verbose bool
modules []string
diff_cmd string
is_verbose bool
modules []string
mut:
api_differences map[string]int
}
Expand All @@ -40,9 +40,7 @@ fn main() {
vroot := os.dir(vexe)
util.set_vroot_folder(vroot)
os.chdir(vroot)
cmd := util.find_working_diff_command() or {
''
}
cmd := util.find_working_diff_command() or { '' }
mut app := App{
diff_cmd: cmd
is_verbose: os.getenv('VERBOSE').len > 0
Expand All @@ -63,7 +61,7 @@ fn main() {
}
howmany := app.api_differences.len
eprintln('NB: please, do run `git clean -xf` after this tool, or at least `find thirdparty/ |grep .o$|xargs rm`')
eprintln('otherwise, `./v test-fixed` may show false positives, due to .o files compiled with a cross compiler.')
eprintln('otherwise, `./v test-compiler-full` may show false positives, due to .o files compiled with a cross compiler.')
if howmany > 0 {
eprintln(term.header('Found $howmany modules with different APIs', '='))
for m in app.api_differences.keys() {
Expand Down Expand Up @@ -105,7 +103,7 @@ fn (app App) gen_api_for_module_in_os(mod_name string, os_name string) string {
for s in f.stmts {
if s is ast.FnDecl {
if s.is_pub {
fn_signature := s.stringify(b.table, mod_name, map[string]string)
fn_signature := s.stringify(b.table, mod_name, map[string]string{})
fn_mod := s.modname()
if fn_mod == mod_name {
fline := '$fn_mod: $fn_signature'
Expand Down
Loading

0 comments on commit 460f32b

Please sign in to comment.