update ci

This commit is contained in:
nav-28
2023-04-07 21:59:13 -06:00
parent dc625beef8
commit 10ca894966
3 changed files with 28 additions and 30 deletions
+3 -3
View File
@@ -2,9 +2,9 @@ name: Dart
on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]
jobs:
test:
@@ -29,4 +29,4 @@ jobs:
run: dart analyze
- name: Run tests
run: dart test
run: dart test -x perft
+22 -23
View File
@@ -5,10 +5,9 @@ import 'package:dartchess/dartchess.dart';
import 'perft_parser.dart';
void main() async {
var tests =
Parser().parse(File('test/resources/3check.perft').readAsStringSync());
group('Three Check', () {
final tests =
Parser().parse(File('test/resources/3check.perft').readAsStringSync());
for (final perftTest in tests) {
final position = ThreeCheck.fromSetup(Setup.parseFen(perftTest.fen));
for (final testCase in perftTest.cases) {
@@ -20,10 +19,10 @@ void main() async {
}
}
});
tests = Parser()
.parse(await File('test/resources/antichess.perft').readAsString());
group('Antichess', () {
final tests = Parser()
.parse(File('test/resources/antichess.perft').readAsStringSync());
for (final perftTest in tests) {
final position = Antichess.fromSetup(Setup.parseFen(perftTest.fen));
for (final testCase in perftTest.cases) {
@@ -35,14 +34,14 @@ void main() async {
}
}
});
tests =
Parser().parse(await File('test/resources/atomic.perft').readAsString());
group('Atomic', () {
final tests =
Parser().parse(File('test/resources/atomic.perft').readAsStringSync());
for (final perftTest in tests) {
final position = Atomic.fromSetup(Setup.parseFen(perftTest.fen));
for (final testCase in perftTest.cases) {
test('Atomic ${perftTest.id} ${perftTest.fen} ${testCase.depth}', () {
test('${perftTest.id} ${perftTest.fen} ${testCase.depth}', () {
expect(perft(position, testCase.depth), testCase.nodes,
reason:
'id: ${perftTest.id}\nfen: ${perftTest.fen} \ndepth: ${testCase.depth} \nnodes: ${testCase.nodes}');
@@ -50,10 +49,10 @@ void main() async {
}
}
});
tests = Parser()
.parse(await File('test/resources/crazyhouse.perft').readAsString());
group('Crazyhouse', () {
final tests = Parser()
.parse(File('test/resources/crazyhouse.perft').readAsStringSync());
for (final perftTest in tests) {
final position = Crazyhouse.fromSetup(Setup.parseFen(perftTest.fen));
for (final testCase in perftTest.cases) {
@@ -65,10 +64,10 @@ void main() async {
}
}
});
tests =
Parser().parse(await File('test/resources/horde.perft').readAsString());
group('Horde', () {
final tests =
Parser().parse(File('test/resources/horde.perft').readAsStringSync());
for (final perftTest in tests) {
final position = Horde.fromSetup(Setup.parseFen(perftTest.fen));
for (final testCase in perftTest.cases) {
@@ -80,10 +79,10 @@ void main() async {
}
}
});
tests = Parser()
.parse(await File('test/resources/racingkings.perft').readAsString());
group('Racing Kings', () {
final tests = Parser()
.parse(File('test/resources/racingkings.perft').readAsStringSync());
for (final perftTest in tests) {
final position = RacingKings.fromSetup(Setup.parseFen(perftTest.fen));
for (final testCase in perftTest.cases) {
@@ -95,10 +94,10 @@ void main() async {
}
}
});
tests =
Parser().parse(await File('test/resources/tricky.perft').readAsString());
group('Chess Tricky', () {
final tests =
Parser().parse(File('test/resources/tricky.perft').readAsStringSync());
for (final perftTest in tests) {
for (final testCase in perftTest.cases) {
test('${perftTest.id} ${perftTest.fen} ${testCase.depth}', () {
@@ -112,11 +111,12 @@ void main() async {
}
}
});
tests =
Parser().parse(await File('test/resources/random.perft').readAsString());
group('Random', () {
for (final perftTest in tests) {
final tests =
Parser().parse(File('test/resources/random.perft').readAsStringSync());
// only test 25 position in random. Test file has around 6000 positions
for (final perftTest in tests.take(25)) {
final position = Chess.fromSetup(Setup.parseFen(perftTest.fen));
for (final testCase in perftTest.cases) {
test('${perftTest.id} ${perftTest.fen} ${testCase.depth}', () {
@@ -128,14 +128,13 @@ void main() async {
}
});
tests = Parser()
.parse(await File('test/resources/chess960.perft').readAsString());
group('Chess 960', () {
final tests = Parser()
.parse(File('test/resources/chess960.perft').readAsStringSync());
for (final perftTest in tests) {
final position = Chess.fromSetup(Setup.parseFen(perftTest.fen));
for (final testCase in perftTest.cases) {
test('Chess 960 ${perftTest.id} ${perftTest.fen} ${testCase.depth}',
() {
test('${perftTest.id} ${perftTest.fen} ${testCase.depth}', () {
expect(perft(position, testCase.depth), testCase.nodes,
reason:
'id: ${perftTest.id}\nfen: ${perftTest.fen} \ndepth: ${testCase.depth} \nnodes: ${testCase.nodes}');
+3 -4
View File
@@ -1,4 +1,3 @@
@Tags(['perft'])
import 'package:test/test.dart';
import 'dart:io';
import 'package:dartchess/dartchess.dart';
@@ -123,8 +122,8 @@ void main() async {
group('Random', () {
final tests =
Parser().parse(File('test/resources/random.perft').readAsStringSync());
// only test 25 position in random. Test file has around 6000 positions
for (final perftTest in tests.take(25)) {
// only test 10 position in random. Test file has around 6000 positions
for (final perftTest in tests.take(50)) {
final position = Chess.fromSetup(Setup.parseFen(perftTest.fen));
for (final testCase in perftTest.cases
.takeWhile((testCase) => testCase.nodes < nodeLimit)) {
@@ -140,7 +139,7 @@ void main() async {
group('Chess 960', () {
final tests = Parser()
.parse(File('test/resources/chess960.perft').readAsStringSync());
for (final perftTest in tests) {
for (final perftTest in tests.take(50)) {
final position = Chess.fromSetup(Setup.parseFen(perftTest.fen));
for (final testCase in perftTest.cases
.takeWhile((testCase) => testCase.nodes < nodeLimit)) {