Skip to content

Учтена среда запуска тестов.#1677

Open
dmpas wants to merge 2 commits intoEvilBeaver:developfrom
dmpas:feature/config-test-cleanup
Open

Учтена среда запуска тестов.#1677
dmpas wants to merge 2 commits intoEvilBeaver:developfrom
dmpas:feature/config-test-cleanup

Conversation

@dmpas
Copy link
Copy Markdown
Collaborator

@dmpas dmpas commented May 9, 2026

Тесты могут запускаться

  1. без файла oscript.cfg - тогда тест не имеет смысла и его падение должно быть желтым, а не красным
  2. с уже установленной переменной OSCRIPT_CONFIG - тогда переменную изначально надо очистить по завершении вернуть в исходное состояние.

Summary by CodeRabbit

  • Tests
    • Improved environment restoration in configuration tests to reliably save and restore environment variables during success and error paths, preventing leftover state after test runs.
    • Enhanced test runner error detection to recognize additional English error message formats for "method not found" conditions.

Review Change Stack

Тесты могут запускаться
1. без файла oscript.cfg - тогда тест не имеет смысла и его падение должно быть желтым, а не красным
2. с уже установленной переменной OSCRIPT_CONFIG - тогда переменную изначально надо очистить  по завершении вернуть в исходное состояние.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b5306fca-32cb-4968-8f52-ccb8b9c16623

📥 Commits

Reviewing files that changed from the base of the PR and between 5e4eb92 and 3113d1f.

📒 Files selected for processing (1)
  • tests/config.os
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/config.os

📝 Walkthrough

Walkthrough

Two test improvements: (1) Test procedures in tests/config.os now preserve and restore the original OSCRIPT_CONFIG environment variable on exception and completion instead of clearing it; (2) Error detection helper in tests/testrunner.os recognizes an additional English error message variant for method-not-found conditions.

Changes

Test Infrastructure Improvements

Layer / File(s) Summary
Environment State Restoration
tests/config.os
Test procedures save original OSCRIPT_CONFIG before modification and restore it in exception handlers and after test completion instead of clearing to empty string. Applied to ТестДолженПроверитьПорядокПрименения_ПеременнаяОкруженияИмеетВысшийПриоритет and ТестДолженПроверитьПереопределениеНесколькихПараметровОдновременно.
Error Detection Enhancement
tests/testrunner.os
ЕстьОшибка_МетодОбъектаНеОбнаружен now recognizes the English variant "Method not found (" alongside existing "Object method not found (" and Russian fragment checks, before verifying the method name is present.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • EvilBeaver

Poem

🐰 A rabbit hops through tests with care,

saving keys and putting them back there.
When errors speak in English tone,
the helper knows them as its own.
Hooray for restore — the suite is fair!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: tests now account for the runtime environment by properly handling the OSCRIPT_CONFIG environment variable and managing test execution state.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/config.os (1)

51-62: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Восстановление OSCRIPT_CONFIG не гарантировано при падении проверки после очистки.

Если проверка на Line 57-58 падает, код на Line 61-62 не выполняется, и тест оставляет окружение загрязненным (OSCRIPT_CONFIG="").

Предлагаемая правка
 	// Очищаем переменную окружения
 	УстановитьПеременнуюСреды("OSCRIPT_CONFIG", "");
 	ОбновитьНастройкиСистемы();
-	
-	// Проверяем, что значение вернулось к исходному
-	ВосстановленноеЗначение = ПолучитьЗначениеСистемнойНастройки("SystemLanguage");
-	юТест.ПроверитьРавенство(ИсходноеЗначениеЯзыка, ВосстановленноеЗначение,
-		"После очистки переменной окружения значение должно вернуться к исходному");
+
+	Попытка
+		// Проверяем, что значение вернулось к исходному
+		ВосстановленноеЗначение = ПолучитьЗначениеСистемнойНастройки("SystemLanguage");
+		юТест.ПроверитьРавенство(ИсходноеЗначениеЯзыка, ВосстановленноеЗначение,
+			"После очистки переменной окружения значение должно вернуться к исходному");
+	Исключение
+		УстановитьПеременнуюСреды("OSCRIPT_CONFIG", ИсходноеЗначениеПеременной);
+		ОбновитьНастройкиСистемы();
+		ВызватьИсключение;
+	КонецПопытки;
 	
 	// Возвращаем переменную окружения в исходное состояние
 	УстановитьПеременнуюСреды("OSCRIPT_CONFIG", ИсходноеЗначениеПеременной);
 	ОбновитьНастройкиСистемы();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/config.os` around lines 51 - 62, The test clears OSCRIPT_CONFIG then
asserts restored value but does not guarantee restoration on failure; wrap the
operations that clear and check the setting (the calls to
УстановитьПеременнуюСреды("OSCRIPT_CONFIG", ""), ОбновитьНастройкиСистемы() and
юТест.ПроверитьРавенство(...)) in a try/finally (or equivalent ensure) so that
the final restoration calls УстановитьПеременнуюСреды("OSCRIPT_CONFIG",
ИсходноеЗначениеПеременной) and ОбновитьНастройкиСистемы() always run; keep the
assertion using юТест.ПроверитьРавенство and only perform cleanup in the finally
block to avoid leaving OSCRIPT_CONFIG="" on test failure.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/config.os`:
- Around line 46-48: В блоках обработки исключения, где сейчас восстанавливается
переменная окружения через УстановитьПеременнуюСреды("OSCRIPT_CONFIG",
ИсходноеЗначениеПеременной) и затем вызывается ВызватьИсключение, добавьте вызов
ОбновитьНастройкиСистемы() после восстановления переменной, чтобы процесс
перечитал системные настройки перед пробросом исключения; проделайте то же самое
в аналогичной ветке на участках, связанных с Lines 120-123 (где также
восстанавливается переменная и вызывается исключение).

---

Outside diff comments:
In `@tests/config.os`:
- Around line 51-62: The test clears OSCRIPT_CONFIG then asserts restored value
but does not guarantee restoration on failure; wrap the operations that clear
and check the setting (the calls to УстановитьПеременнуюСреды("OSCRIPT_CONFIG",
""), ОбновитьНастройкиСистемы() and юТест.ПроверитьРавенство(...)) in a
try/finally (or equivalent ensure) so that the final restoration calls
УстановитьПеременнуюСреды("OSCRIPT_CONFIG", ИсходноеЗначениеПеременной) and
ОбновитьНастройкиСистемы() always run; keep the assertion using
юТест.ПроверитьРавенство and only perform cleanup in the finally block to avoid
leaving OSCRIPT_CONFIG="" on test failure.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ab3abb8d-408e-42b3-8837-9a4963acbba3

📥 Commits

Reviewing files that changed from the base of the PR and between c455964 and 5e4eb92.

📒 Files selected for processing (2)
  • tests/config.os
  • tests/testrunner.os

Comment thread tests/config.os
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.

1 participant