News:

Congratulations!
 You've won the News Item Lottery! Your prize? Reading this news item! :)

Automated Tests r12090

Started by Andarix, July 19, 2026, 08:30:02 AM

Previous topic - Next topic

0 Members and 7 Guests are viewing this topic.

Andarix

Quote2026-07-19T07:35:46.5531304Z 00:00:03 Script: Print:   [91/201] test_halt_make_public_single
2026-07-19T07:35:46.5535363Z 00:00:03 Script: Error:   <error>
2026-07-19T07:35:46.5536313Z 00:00:03 Script: Error:   <st>Error: [Assertion failed, '"Das Feld gehoert
2026-07-19T07:35:46.5536981Z 00:00:03 einem anderen Spieler
2026-07-19T07:35:46.5537425Z 00:00:03 " == null' was not true]</st>
2026-07-19T07:35:46.5537913Z 00:00:03 Script: Error:   CALLSTACK
2026-07-19T07:35:46.5538789Z 00:00:03 Script: Error:   * FUNCTION [ASSERT_EQUAL()]
* addons/pak/scenario/automated-tests//test_helpers.nut
2026-07-19T07:35:46.5539690Z 00:00:03 Script: Error:   * line [27]
2026-07-19T07:35:46.5540156Z 00:00:03 Script: Error:   

2026-07-19T07:35:46.5540615Z 00:00:03 Script: Error:   - - LOCALS
2026-07-19T07:35:46.5541084Z 00:00:03 Script: Error:   - - - [err] INSTANCE
2026-07-19T07:35:46.5541595Z 00:00:03 Script: Error:   - - - [exp] NULL
2026-07-19T07:35:46.5542152Z 00:00:03 Script: Error:   - - - [act] "Das Feld gehoert
2026-07-19T07:35:46.5542682Z 00:00:03 einem anderen Spieler
2026-07-19T07:35:46.5543078Z 00:00:03 "
2026-07-19T07:35:46.5543475Z 00:00:03 Script: Error:   - - - [this] TABLE (395 entries)
2026-07-19T07:35:46.5544547Z 00:00:03 Script: Error:   * FUNCTION [test_halt_make_public_single()]
* addons/pak/scenario/automated-tests//tests/test_halt.nut
2026-07-19T07:35:46.5545653Z 00:00:03 Script: Error:   * line [1123]
2026-07-19T07:35:46.5546564Z 00:00:03 Script: Error:   

2026-07-19T07:35:46.5546931Z 00:00:03 Script: Error:   - - LOCALS
2026-07-19T07:35:46.5547199Z 00:00:03 Script: Error:   - - - [old_maint] 1600
2026-07-19T07:35:46.5547499Z 00:00:03 Script: Error:   - - - [old_cash] 197800
2026-07-19T07:35:46.5547815Z 00:00:03 Script: Error:   - - - [makepublic] INSTANCE
2026-07-19T07:35:46.5548133Z 00:00:03 Script: Error:   - - - [road_desc] INSTANCE
2026-07-19T07:35:46.5548445Z 00:00:03 Script: Error:   - - - [pax_halt] INSTANCE
2026-07-19T07:35:46.5548762Z 00:00:03 Script: Error:   - - - [wayremover] INSTANCE
2026-07-19T07:35:46.5549082Z 00:00:03 Script: Error:   - - - [stationbuilder] INSTANCE
2026-07-19T07:35:46.5549407Z 00:00:03 Script: Error:   - - - [public_pl] INSTANCE
2026-07-19T07:35:46.5549717Z 00:00:03 Script: Error:   - - - [pl] INSTANCE
2026-07-19T07:35:46.5550023Z 00:00:03 Script: Error:   - - - [this] TABLE (395 entries)
2026-07-19T07:35:46.5550681Z 00:00:03 Script: Error:   * FUNCTION [run_all_tests()]
* addons/pak/scenario/automated-tests/scenario.nut
2026-07-19T07:35:46.5551154Z 00:00:03 Script: Error:   * line [43]
2026-07-19T07:35:46.5551401Z 00:00:03 Script: Error:   

2026-07-19T07:35:46.5551632Z 00:00:03 Script: Error:   - - LOCALS
2026-07-19T07:35:46.5551895Z 00:00:03 Script: Error:   - - - [num_tests_done] 90
2026-07-19T07:35:46.5552193Z 00:00:03 Script: Error:   - - - [error_msg] NULL
2026-07-19T07:35:46.5552484Z 00:00:03 Script: Error:   - - - [num_tests] 201
2026-07-19T07:35:46.5552832Z 00:00:03 Script: Error:   - - - [func_name] "test_halt_make_public_single"
2026-07-19T07:35:46.5553199Z 00:00:03 Script: Error:   - - - [test_func] CLOSURE
2026-07-19T07:35:46.5553478Z 00:00:03 Script: Error:   - - - 90
2026-07-19T07:35:46.5553759Z 00:00:03 Script: Error:   - - - [this] TABLE (395 entries)
2026-07-19T07:35:46.5554213Z 00:00:03 Script: Error:   * FUNCTION [start()]
* addons/pak/scenario/automated-tests/scenario.nut
2026-07-19T07:35:46.5554655Z 00:00:03 Script: Error:   * line [95]
2026-07-19T07:35:46.5554910Z 00:00:03 Script: Error:   

2026-07-19T07:35:46.5555178Z 00:00:03 Script: Error:   - - LOCALS
2026-07-19T07:35:46.5555450Z 00:00:03 Script: Error:   - - - [this] TABLE (395 entries)
2026-07-19T07:35:46.5555740Z 00:00:03 Script: Error:   </error>
2026-07-19T07:35:47.2705720Z Killing process (test failed)
2026-07-19T07:35:47.2706720Z ~/work/simutrans/simutrans
2026-07-19T07:35:47.2726996Z ##[error]Process completed with exit code 1.

victor_18993

Hello,

I have been investigating this issue, and the cause is in haltestelle_t::change_owner().

This function was written when a halt could only have a single owner, so it currently converts every tile in the halt to the public player, regardless of who actually owns it. In a shared halt, this also makes buildings and ways belonging to another co-owner public.

This behaviour is incorrect: only the tiles belonging to the player using the "make public" tool should be converted. The exception is when the action is initiated by the public player itself, in which case the previous behaviour is preserved and all tiles are converted.

I also found a second related issue immediately after the loop. The owner mask was assigned directly with:

owners = 1 << player->get_player_nr()
This removes any remaining co-owner from the halt's owner mask. The patch now rebuilds the mask from the actual owners of the tiles, following the same approach already used by add_grund().

Changes included in the patch:

  • change_owner() now also receives the player initiating the action through the old_owner parameter.
  • Buildings and ways are only converted when they belong to old_owner. If the action is initiated by the public player, the conversion remains unconditional in order to preserve the existing behaviour.
  • The tool branch that makes an individual way public already used this same check, so this change makes change_owner() consistent with the surrounding code.
  • The owner mask is recalculated from the remaining tiles after the conversion.
  • The only caller, in tool_make_stop_public_t::work(), now passes the player initiating the action.

I also added a regression test, test_halt_make_public_shared.

The test creates a halt shared by the public player and two companies. One of the companies then uses the tool to make its part of the halt public, and the test verifies that the tile belonging to the other company remains unchanged.

The full test suite passes. The new test fails without the fix and passes with the patch applied.

The patch is attached as a unified diff. It can be applied with patch -p1 or git apply on a recent trunk revision.
En la vida todo son vivencias y cada una de ellas nos hace mas grandes,¿Como de grande eres tu? :)

prissi

I had fixed this already, thank you, less than an hour after the inital submission.

Ideally, the function to make stops public should no longer be needed anymore with the shared stops.