Skip to content

Fix tests & move languages.json to framework#56

Merged
RomanPudashkin merged 3 commits into
musescore:mainfrom
RomanPudashkin:fix_framework_tests
May 27, 2026
Merged

Fix tests & move languages.json to framework#56
RomanPudashkin merged 3 commits into
musescore:mainfrom
RomanPudashkin:fix_framework_tests

Conversation

@RomanPudashkin
Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds an embedded languages.json resource and registers it via qt_add_resources, updates LanguagesConfiguration to use the resource path (:/languages/resources/languages.json), sets MUSE_LANGUAGES_JSON_PATH for tests and re-enables the Languages_Json correctness test to read that file, updates the CI translation script to read the new languages.json location, and adjusts the Uri_LocalFile unit test to expect an absolute path via io::absoluteFilePath(originPath).

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning No pull request description was provided; the template requires context about the changes, motivation, and verification checklist completion. Add a comprehensive description explaining the motivation for migrating languages.json to Qt resources, how the changes affect the language configuration system, and confirm all checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title accurately captures the main changes: fixing framework tests and relocating languages.json to the framework resources directory.

✏️ 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.

@RomanPudashkin RomanPudashkin changed the title Fix framework tests Fix tests & move languages.json to framework May 27, 2026
Copy link
Copy Markdown

@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

🤖 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 `@buildscripts/ci/translation/s3_packandsend.py`:
- Line 77: Replace the raw open(...) call with a context manager: use "with
open('muse/framework/languages/resources/languages.json', 'r') as
langCode_file:" so the file is automatically closed; update subsequent code that
reads from langCode_file to be inside that with-block and remove the standalone
langCode_file variable (change the mode from "r+" to "r" since the file is only
read).
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: cca69427-0fab-4ec6-9def-1cbf4aef469f

📥 Commits

Reviewing files that changed from the base of the PR and between f8ed90e and d507d3e.

📒 Files selected for processing (6)
  • buildscripts/ci/translation/s3_packandsend.py
  • framework/languages/CMakeLists.txt
  • framework/languages/internal/languagesconfiguration.cpp
  • framework/languages/resources/languages.json
  • framework/languages/tests/CMakeLists.txt
  • framework/languages/tests/languagesjson_tests.cpp


# read languages.json and store language code and name
langCode_file = open("share/locale/languages.json", "r+")
langCode_file = open("muse/framework/languages/resources/languages.json", "r+")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Use a context manager for file handling.

The file is opened without a context manager, which can leave the file handle open if an exception occurs. Python best practice is to use with statements for resource management.

♻️ Proposed fix
-langCode_file = open("muse/framework/languages/resources/languages.json", "r+")
-langCodeNameDict = json.load(langCode_file)  # language code --> props
-langCode_file.close()
+with open("muse/framework/languages/resources/languages.json", "r") as langCode_file:
+    langCodeNameDict = json.load(langCode_file)  # language code --> props

Note: Changed "r+" to "r" since the file is only read, not modified.

🧰 Tools
🪛 Ruff (0.15.14)

[warning] 77-77: Use a context manager for opening files

(SIM115)

🤖 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 `@buildscripts/ci/translation/s3_packandsend.py` at line 77, Replace the raw
open(...) call with a context manager: use "with
open('muse/framework/languages/resources/languages.json', 'r') as
langCode_file:" so the file is automatically closed; update subsequent code that
reads from langCode_file to be inside that with-block and remove the standalone
langCode_file variable (change the mode from "r+" to "r" since the file is only
read).

@RomanPudashkin RomanPudashkin merged commit 5246c26 into musescore:main May 27, 2026
3 checks passed
@RomanPudashkin RomanPudashkin deleted the fix_framework_tests branch May 27, 2026 10:17
@cbjeukendrup
Copy link
Copy Markdown
Contributor

This is slightly disputable, because it forces MuseScore and Audacity to support the same set of languages, while the set of languages supported by MuseScore is far from being a good example (it contains many variants of languages while there are no translators available for those variants, and there may be inconsistencies in the language codes...).
Also, languages.json should actually stay in sync with the files available in share/locale (it is basically metadata for those files) so in that regard it makes sense to have it in the app repo.

@igorkorsukov
Copy link
Copy Markdown
Member

I think it can be interpreted like this:

  • MF provides this list of languages ​​(code and name)
  • If the application wants to change it, we can add a path to this file via the config (we'll modify this)

like
https://github.com/musescore/MuseScore/tree/main/src/app/configs

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.

3 participants