diff --git a/.github/workflows/flutter_ci.yaml b/.github/workflows/flutter_ci.yaml index 4ce3e73dc..5ae6fca84 100644 --- a/.github/workflows/flutter_ci.yaml +++ b/.github/workflows/flutter_ci.yaml @@ -56,16 +56,20 @@ jobs: - os: windows runner_machine: windows-latest setup_for_flutter_desktop_script: .github/scripts/windows/install_additional_requirements_for_flutter.sh + # workaround for https://github.com/sensuikan1973/pedax/pull/1746#issuecomment-1975666851 + widget_test_command: flutter test --verbose --coverage --coverage-path=./coverage/lcov.widget_test.info --concurrency 1 integration_test_command: flutter test integration_test --device-id windows --verbose --coverage --coverage-path=./coverage/lcov.integration_test.info - os: macos # Why isn't this macos-latest ? -> workaround for https://github.com/sensuikan1973/pedax/pull/1443 # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners runner_machine: macos-13 setup_for_flutter_desktop_script: .github/scripts/macos/install_additional_requirements_for_flutter.sh + widget_test_command: flutter test --verbose --coverage --coverage-path=./coverage/lcov.widget_test.info --concurrency 1 integration_test_command: flutter test integration_test --device-id macos --verbose --coverage --coverage-path=./coverage/lcov.integration_test.info - os: ubuntu runner_machine: ubuntu-latest setup_for_flutter_desktop_script: .github/scripts/linux/install_additional_requirements_for_flutter.sh + widget_test_command: flutter test --verbose --coverage --coverage-path=./coverage/lcov.widget_test.info --concurrency 1 integration_test_command: | touch ./coverage/lcov.integration_test.info timeout 240 xvfb-run -a \ @@ -89,7 +93,7 @@ jobs: # https://docs.flutter.dev/testing#widget-tests - name: widget test - run: flutter test --verbose --coverage --coverage-path=./coverage/lcov.widget_test.info --concurrency 1 + run: ${{ matrix.widget_test_command }} # https://docs.codecov.com/docs/merging-reports#multiple-languages - uses: codecov/codecov-action@v3 with: # ref: https://github.com/codecov/codecov-action/blob/v3.1.0/.github/workflows/main.yml diff --git a/lib/engine/api/count_bestpath.dart b/lib/engine/api/count_bestpath.dart index 1123aa285..09a22183e 100644 --- a/lib/engine/api/count_bestpath.dart +++ b/lib/engine/api/count_bestpath.dart @@ -11,13 +11,13 @@ class CountBestpathRequest implements RequestSchema { required this.movesAtRequest, required this.playerLowerLimit, required this.opponentLowerLimit, - required this.logger, + required this.logLevel, }); final String movesAtRequest; final int playerLowerLimit; final int opponentLowerLimit; - final Logger logger; + final Level logLevel; } @immutable @@ -43,10 +43,11 @@ Stream executeCountBestpath( final CountBestpathRequest request, ) async* { final rootBookMoveListWithPosition = edax.edaxGetBookMoveWithPositionByMoves(request.movesAtRequest); + final logger = Logger(level: request.logLevel); for (final move in rootBookMoveListWithPosition.moveList) { final currentMoves = edax.edaxGetMoves(); if (currentMoves != request.movesAtRequest) { - request.logger.d( + logger.d( 'count bestpath process is aborted.\ncurrentMoves "$currentMoves" is not equal to movesAtRequest "${request.movesAtRequest}"', ); edax.edaxBookStopCountBestpath(); diff --git a/lib/engine/api/hint_one_by_one.dart b/lib/engine/api/hint_one_by_one.dart index 4bd30e4d9..02b61e70d 100644 --- a/lib/engine/api/hint_one_by_one.dart +++ b/lib/engine/api/hint_one_by_one.dart @@ -12,13 +12,13 @@ class HintOneByOneRequest implements RequestSchema { required this.level, required this.stepByStep, required this.movesAtRequest, - required this.logger, + required this.logLevel, }); final int level; final bool stepByStep; final String movesAtRequest; - final Logger logger; + final Level logLevel; } @immutable @@ -47,23 +47,24 @@ Stream executeHintOneByOne( ) async* { final levelList = request.stepByStep ? generateLevelList3Steps(request.level) : [request.level]; const levelOption = LevelOption(); + final logger = Logger(level: request.logLevel); for (final level in levelList) { edax.edaxStop(); - request.logger.d('stopped edax search'); + logger.d('stopped edax search'); edax ..edaxSetOption(levelOption.nativeName, level.toString()) ..edaxHintPrepare(); - request.logger.d('prepared getting hint one by one.\nlevel: $level.\nmoves at request: ${request.movesAtRequest}'); + logger.d('prepared getting hint one by one.\nlevel: $level.\nmoves at request: ${request.movesAtRequest}'); while (true) { final currentMoves = edax.edaxGetMoves(); if (currentMoves != request.movesAtRequest) { - request.logger.d( + logger.d( 'hint process is aborted.\ncurrentMoves "$currentMoves" is not equal to movesAtRequest "${request.movesAtRequest}"', ); return; } - request.logger.d('will call edaxHintNextNoMultiPvDepth'); + logger.d('will call edaxHintNextNoMultiPvDepth'); final hint = edax.edaxHintNextNoMultiPvDepth(); if (hint.isNoMove) break; yield HintOneByOneResponse(request: request, hint: hint, level: level, isLastStep: level == levelList.last); diff --git a/lib/engine/api/setboard.dart b/lib/engine/api/setboard.dart index 6765cc8dd..1f7efa325 100644 --- a/lib/engine/api/setboard.dart +++ b/lib/engine/api/setboard.dart @@ -18,12 +18,12 @@ class SetboardRequest implements RequestSchema { const SetboardRequest({ required this.currentColor, required this.replacementTargets, - required this.logger, + required this.logLevel, }); final int currentColor; final List replacementTargets; - final Logger logger; + final Level logLevel; } @immutable @@ -55,7 +55,8 @@ SetboardResponse executeSetboard(final LibEdax edax, final SetboardRequest reque final currentColorChar = request.currentColor == TurnColor.black ? ColorChar.black : ColorChar.white; boardStr = boardStr.replaceFirst(RegExp('.'), currentColorChar, 64); - request.logger.d('setboard $boardStr'); + final logger = Logger(level: request.logLevel); + logger.d('setboard $boardStr'); edax.edaxSetboard(boardStr); return SetboardResponse( diff --git a/lib/engine/edax_server.dart b/lib/engine/edax_server.dart index 4e892fb88..a48be1230 100644 --- a/lib/engine/edax_server.dart +++ b/lib/engine/edax_server.dart @@ -25,26 +25,26 @@ import 'api/undo.dart'; // NOTE: top level function for `isolate.spawn`. @doNotStore Future startEdaxServer(final StartEdaxServerParams params) async { - final server = EdaxServer(dllPath: params.dllPath, logger: params.logger); + final server = EdaxServer(dllPath: params.dllPath, logLevel: params.logLevel); await server.start(params.parentSendPort, params.initLibedaxParameters); } @immutable class StartEdaxServerParams { - const StartEdaxServerParams(this.parentSendPort, this.dllPath, this.initLibedaxParameters, this.logger); + const StartEdaxServerParams(this.parentSendPort, this.dllPath, this.initLibedaxParameters, this.logLevel); final SendPort parentSendPort; final String dllPath; final List initLibedaxParameters; - final Logger logger; + final Level logLevel; } @doNotStore class EdaxServer { EdaxServer({ required final String dllPath, - required final Logger logger, + required final Level logLevel, }) : _dllPath = dllPath, - _logger = logger; + _logger = Logger(level: logLevel); final String _dllPath; final Logger _logger; diff --git a/lib/models/board_notifier.dart b/lib/models/board_notifier.dart index 48b62b245..622c71be9 100644 --- a/lib/models/board_notifier.dart +++ b/lib/models/board_notifier.dart @@ -53,7 +53,7 @@ class BoardNotifier extends ValueNotifier { }) async { await Isolate.spawn( startEdaxServer, - StartEdaxServerParams(_receivePort.sendPort, libedaxPath, initLibedaxParams, _logger), + StartEdaxServerParams(_receivePort.sendPort, libedaxPath, initLibedaxParams, Logger.level), ); _receiveStream = _receivePort.asBroadcastStream(); _edaxServerPort = await _receiveStream.first as SendPort; @@ -95,7 +95,7 @@ class BoardNotifier extends ValueNotifier { SetboardRequest( currentColor: value.arrangeTargetColor, replacementTargets: arrangeTargetChar, - logger: _logger, + logLevel: Logger.level, ), ); } @@ -149,7 +149,7 @@ class BoardNotifier extends ValueNotifier { level: value.level, stepByStep: value.hintStepByStep, movesAtRequest: movesAtRequest, - logger: _logger, + logLevel: Logger.level, ), ); } @@ -169,7 +169,7 @@ class BoardNotifier extends ValueNotifier { movesAtRequest: movesAtRequest, playerLowerLimit: await _bestpathCountPlayerLowerLimitOption.val, opponentLowerLimit: await _bestpathCountOpponentLowerLimitOption.val, - logger: _logger, + logLevel: Logger.level, ), ); }