Skip to content

Commit

Permalink
test-self: run and fix output test on windows (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
serkonda7 authored Dec 10, 2023
1 parent 26feae5 commit 4687d00
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ All notable changes will be documented in this file.
## 0.0.6
_unreleased_

### Breaking
- Remove tool `test-lib`
- All standard library tests can be run with `bait test lib`
- Compiler tests can be run with `bait test-self`

### Generics
- Check that concrete types for each generic type match
- Generate concrete functions on both backends
Expand Down Expand Up @@ -41,7 +46,9 @@ _unreleased_
- Many BuildRunner improvements
- New field `oks` to check number of successful runs
- Add capbility to use `build_all_in_root` for directories
- InOutRunner: Handle skips for lib tests
- InOutRunner
- Output tests work on windows now (internal path and line break normalization)
- Handle skips for lib tests

### Standard Library
- builtin:
Expand All @@ -60,6 +67,7 @@ _unreleased_
- Imports: Look for imports next to the respective file first
- Interop: Support for declaring JS structs, methods, enums and type aliases
- parser: Fix prefix expr precedence
- Move compiler tests from `lib/bait/tests/` into `tests/`
- Various refactorings
- Documentation improvements

Expand Down
10 changes: 0 additions & 10 deletions cli/tools/test-self.bt
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,12 @@ package main

import os

const WIN_SKIP := [
'tests\\inout_runner_test.bt'
]

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

if os.platform() == 'win32' {
test_files = test_files.filter(fun (f string) bool {
return not WIN_SKIP.contains(f)
}) as []string
}

for file in test_files {
fails += os.system('node ${$BAITEXE} test ${file}')
}
Expand Down
16 changes: 11 additions & 5 deletions lib/bait/util/testing/inout.bt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fun (runner InOutRunner) test_dir(dir string) {
return
}

expected := read_out_file('${abs_dir}/expected.out').replace('\r\n', '\n')
expected := read_out_file('${abs_dir}/expected.out')
runner.compare_expected(res, expected)
}

Expand All @@ -43,9 +43,11 @@ pub fun (runner InOutRunner) test_all_in_root() {

fun (runner InOutRunner) compare_expected(res os.Result, expected string) {
if runner.check_stdout {
assert expected == res.stdout
text := normalize(res.stdout)
assert text == expected
} else {
assert expected == res.stderr
text := normalize(res.stderr)
assert text == expected
}
}

Expand All @@ -59,7 +61,7 @@ pub fun in_out_runner(runner InOutRunner) {
continue
}

if runner.skips.contains(file) {
if runner.skips.contains(normalize(file)) {
eprintln('skipping ${file}')
continue
}
Expand Down Expand Up @@ -88,5 +90,9 @@ fun read_out_file(in_file_path string) string {
return ''
}

return os.read_file(out_file)
return normalize(os.read_file(out_file))
}

fun normalize(s string) string {
return s.replace('\\', '/').replace('\r\n', '\n')
}
File renamed without changes.

0 comments on commit 4687d00

Please sign in to comment.