[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to force build to use LANG=C.UTF-8?



On 2025-04-11, at 09:56:28 +0800, Bo YU wrote:
On Fri, Apr 11, 2025 at 7:52 AM Soren Stoutner wrote:
> The Redmine package includes a test run at build time that checks for
> a list of particular response values.  The problem is that these
> values are translated.  Running the build in a different language
> causes the test to fail.
>
> Failure:
> ProjectAdminQueryTest#test_project_statuses_values_should_return_all_statuses
> [test/unit/project_admin_query_test.rb:99]:
> --- expected
> +++ actual
> @@ -1 +1 @@
> -[["active", "1"], ["closed", "5"], ["archived", "9"], ["scheduled for
> deletion", "10"]]
> +[["actif", "1"], ["fermé", "5"], ["archivé", "9"], ["planifié pour
> suppression", “10”]]
>
> https://tests.reproducible-builds.org/debian/rb-pkg/trixie/arm64/redmine.html
>
> Setting "export LANG=C.UTF-8” does not prevent this test from running
> in a foreign language.
>
> https://salsa.debian.org/ruby-team/redmine/-/jobs/7360518#L3871

I remember there was a fix[0] for this problem. In other words, this
variable needs to be passed when calling test. Hope this helps.

[0]: https://salsa.debian.org/debian-mate-team/onboard/-/blob/master/debian/rules?ref_type=heads#L45

I've did something similar for magit:

  https://salsa.debian.org/emacsen-team/magit/-/commit/2371b4f9cd51742c196400d14b95aebc75859791

However, I don't _think_ the solution here is to set "LANG" (or
"LC_ALL").  I would expect exporting "LANG=C.UTF-8" to work, if it were.
I just tried to reproduce the test failure by explicitly setting
"LC_ALL=it_IT.UTF-8" and was unable to do so.

I am not familiar with Ruby and how it does i18n, but based on a quick
bit of research, I _suspect_ that there may be a concurrency bug in the
test-suite.  The tests are run in a non-deterministic order and some of
them change the locale.  Therefore, I think what is happening is that a
test runs before the failing one which changes the locale (to "pt" or
"fr", for example) causing the test to fail.  The failing test is:

  def test_project_statuses_values_should_return_all_statuses
    q = ProjectAdminQuery.new
    assert_equal [
      ["active", "1"],
      ["closed", "5"],
      ["archived", "9"],
      ["scheduled for deletion", "10"]
    ], q.project_statuses_values
  end

Compare this to a similar test in the same file:

  def test_project_statuses_filter_should_return_project_statuses
    set_language_if_valid 'en'
    query = ProjectAdminQuery.new(:name => '_')
    query.filters = {'status' => {:operator => '=', :values => []}}
    values = query.available_filters['status'][:values]
    assert_equal ['active', 'closed', 'archived', 'scheduled for deletion'], values.map(&:first)
    assert_equal ['1', '5', '9', '10'], values.map(&:second)
  end

In the latter test, the locale is explicitly set to "en".  I think this
should be done in the former test too.

J.

Attachment: signature.asc
Description: PGP signature


Reply to: