Skip to content

Conversation

yutaro-sakamoto
Copy link
Contributor

@yutaro-sakamoto yutaro-sakamoto commented Jul 10, 2025

このPRの主目的は、無効なフォーマットのINDEXEDファイルを開いたときにファイルステータスを30番に設定することである。
以前までのバージョンでは、無効なフォーマットのINDXEDファイルを開いてもファイルステータスは00番であった。

この改修に付随していくつか別の修正も実施した。

CobolFille.java

定数ENOENTやEBADFに設定される値を、COB_STATUS_*に設定される値と重複しないように変更した。
このPRのために修正する過程で、定数の衝突により不具合が生じることがあったため、ついでにこの変更を実施した。

CobolIndexedFile.java

  • ファイルを開いたときに簡単なSQL文select 1を実行して、有効なSQLiteファイルを開いているかを確認するプロセスを追加。失敗時にファイルステータスを30にする設定を追加。
  • INPUTモードで開いたときに、今までと同様にENOENTを返すように修正した。

load.at

以前のバージョンのテストケースでは、無効なINDEXEDファイルを開く処理があったが、不具合により成功扱いになっていた。
今回の改修により無効なINDEXEDファイルを開くとエラーコードが設定され、FILE STATUSが宣言されていないファイルのためデフォルトのエラーメッセージが表示されるようになった。
FILE STATUSを明示的に宣言することで、デフォルトのエラーメッセージの表示を抑制して、OPENに失敗した場合のエラーハンドリングを適切に設定することで、既存のテストをpassするように変更した。

miscellaneous.at

今回のINDEXEDファイルの修正に対するテスト。

@yutaro-sakamoto yutaro-sakamoto requested a review from Copilot July 10, 2025 08:32
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Improves error handling for indexed file operations by enforcing a permanent error status on invalid formats and resolves constant value collisions.

  • Adds an SQL-based check in CobolIndexedFile to detect invalid-format indexed files, returning status 30 on failure
  • Updates system error constants in CobolFile to prevent overlaps with COB_STATUS_* values
  • Enhances test scripts in load.at and miscellaneous.at to cover the new error handling behavior

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/run.src/miscellaneous.at Added a new AT test for opening an invalid-formatted indexed file and verifying status 30
tests/cobj-idx.src/load.at Declared FILE-STATUS in the COBOL test to suppress default messaging and check new behavior
libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/file/CobolIndexedFile.java Introduced an existence check for INPUT mode and an SQL select 1 validation, mapping failures to status 30
libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/file/CobolFile.java Reordered and redefined error constants (ENOENT, EBADF, etc.) to avoid collisions with COB_STATUS_*
Comments suppressed due to low confidence (1)

tests/run.src/miscellaneous.at:2099

  • [nitpick] The test creates invalid-formatted-file but doesn’t explicitly remove it; consider adding an AT_CLEANUP step to delete this artifact and avoid side effects on subsequent tests.
AT_SETUP([Open an invalid formatted indexed file])

@yutaro-sakamoto yutaro-sakamoto marked this pull request as ready for review July 11, 2025 07:19
@yutaro-sakamoto yutaro-sakamoto requested review from kio-watanabe and tsh-hashimoto and removed request for kio-watanabe July 11, 2025 07:19
@yutaro-sakamoto yutaro-sakamoto merged commit efda7a7 into opensourcecobol:develop Jul 18, 2025
139 checks passed
@yutaro-sakamoto yutaro-sakamoto mentioned this pull request Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants