From 23d2fc4b17e95d3c7693d50ce694ef5e5a289e3e Mon Sep 17 00:00:00 2001 From: Lukas Neubert Date: Mon, 11 Dec 2023 18:05:48 +0100 Subject: [PATCH] fix testing a directory --- .github/workflows/ci.yml | 12 ++++++++---- CHANGELOG.md | 8 +++++--- cli/bait.bt | 2 -- cli/tools/help/topics/other.txt | 1 - cli/tools/test-all.bt | 3 ++- cli/tools/test-self.bt | 20 -------------------- cli/tools/test-tools.bt | 17 ----------------- lib/bait/builder/builder.bt | 1 + 8 files changed, 16 insertions(+), 48 deletions(-) delete mode 100644 cli/tools/test-self.bt delete mode 100644 cli/tools/test-tools.bt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83bff8eb..1ab80157 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,9 +27,11 @@ jobs: bait build-examples -b js bait build-examples -b c - name: Run compiler tests - run: bait test-self + run: bait test tests + - name: Run lib tests + run: bait test lib - name: Run tool tests - run: bait test-tools + run: bait test cli/tools - name: Check markdown code blocks run: | bait check-md docs/docs.md @@ -51,9 +53,11 @@ jobs: - name: Build examples run: bait build-examples - name: Run compiler tests - run: bait test-self + run: bait test tests + - name: Run lib tests + run: bait test lib - name: Run tool tests - run: bait test-tools + run: bait test cli/tools - name: Check markdown code blocks run: | bait check-md docs/docs.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a7e47a2..861a8599 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,10 @@ All notable changes will be documented in this file. _unreleased_ ### Breaking -- Remove tool `test-lib` +- Remove tools `test-lib` and `test-tools` - All standard library tests can be run with `bait test lib` - - Compiler tests can be run with `bait test-self` + - Compiler tests can be run with `bait test tests` + - Tool tests can be run with `bait test cli/tools` ### Generics - Check that concrete types for each generic type match @@ -42,6 +43,7 @@ _unreleased_ - Various fixes related to breaking compiler changes ### Testing +- builder: Fix testing a directory with multiple test files - `bait.util.testing` - Many BuildRunner improvements - New field `oks` to check number of successful runs @@ -289,7 +291,7 @@ _10 May 2023_ - `build` command (it can be omitted) - `run`, `version` and `doctor` commands - move `help`, `self` and `up` into tools -- build-examples`, `build-tools`, `check-md`, `test-self` and `test-all` tools +- `build-examples`, `build-tools`, `check-md`, `test-self` and `test-all` tools - `build`: add `--script` option to enable script mode, where no main function is required - `self`: backup the bait.js file diff --git a/cli/bait.bt b/cli/bait.bt index 5f30c926..f4973cd0 100644 --- a/cli/bait.bt +++ b/cli/bait.bt @@ -18,8 +18,6 @@ const TOOLS := [ 'doctor', 'help', 'test-all', - 'test-self', - 'test-tools', 'build-examples', 'build-tools', 'check-md', diff --git a/cli/tools/help/topics/other.txt b/cli/tools/help/topics/other.txt index 81082132..5891e51e 100644 --- a/cli/tools/help/topics/other.txt +++ b/cli/tools/help/topics/other.txt @@ -3,7 +3,6 @@ Other commands: symlink Create a symbolic link for the wrapper script. test-all Run most checks of the CI pipeline locally. - test-self Run all compiler and lib tests. build-examples Test if all examples can be built. build-tools Test if all tools can be built. check-md Check that Bait code blocks in markdown files can compile. diff --git a/cli/tools/test-all.bt b/cli/tools/test-all.bt index 0b766d75..bb66d0ee 100644 --- a/cli/tools/test-all.bt +++ b/cli/tools/test-all.bt @@ -4,9 +4,10 @@ package main import os -const TOOLS := ['build-examples', 'build-tools', 'test-self', 'test-tools'] +const TOOLS := ['build-examples', 'build-tools'] const TOOLS_WITH_ARGS := map{ + 'test': ['tools', 'lib', 'tests'] 'check-md': ['docs/docs.md', 'README.md'] } diff --git a/cli/tools/test-self.bt b/cli/tools/test-self.bt deleted file mode 100644 index 3e4ad28b..00000000 --- a/cli/tools/test-self.bt +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-FileCopyrightText: 2023-present Lukas Neubert -// SPDX-License-Identifier: MPL-2.0 -package main - -import os - -fun main() { - mut test_files := os.walk_ext('tests', '.bt').filter(fun (f string) bool { - return f.contains('_test.') and not f.contains('.in.') - }) as []string - mut fails := 0 - - for file in test_files { - fails += os.system('node ${$BAITEXE} test ${file}') - } - - if fails > 0 { - exit(1) - } -} diff --git a/cli/tools/test-tools.bt b/cli/tools/test-tools.bt deleted file mode 100644 index 4ba3bef6..00000000 --- a/cli/tools/test-tools.bt +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: 2023-present Lukas Neubert -// SPDX-License-Identifier: MPL-2.0 -package main - -import os - -const DIR := os.dir($FILE) - -fun main() { - mut fails := 0 - - fails += os.system('node ${$BAITEXE} test ${DIR}') - - if fails > 0 { - exit(1) - } -} diff --git a/lib/bait/builder/builder.bt b/lib/bait/builder/builder.bt index 1955489b..7b6396f5 100644 --- a/lib/bait/builder/builder.bt +++ b/lib/bait/builder/builder.bt @@ -65,6 +65,7 @@ pub fun compile(prefs preference.Prefs) i32 { mut paths := b.get_user_files(prefs.command) mut files := []ast.File for p in paths { + b.prefs.expected_pkg = '' files.push(b.parse_source_file(p)) }