11#!/usr/bin/env python
22
3- # Copyright 1996-2024 Cyberbotics Ltd.
3+ # Copyright 1996-2025 Cyberbotics Ltd.
44#
55# Licensed under the Apache License, Version 2.0 (the "License");
66# you may not use this file except in compliance with the License.
@@ -75,6 +75,7 @@ def setUp(self):
7575 def test_worlds_warnings_and_cache (self ):
7676 """Test all the 'projects' worlds for loading warnings and if they reference un-cached assets."""
7777 problematicWorlds = []
78+ worldWarnings = {}
7879 crashedWorlds = []
7980 worldsWithNonCachedAssets = []
8081 cacheSizeBefore = len (os .listdir (CACHE_DIR ))
@@ -99,8 +100,11 @@ def test_worlds_warnings_and_cache(self):
99100 # First world is empty.wbt, used to trigger the warning about system requirements not being met
100101 if i == 0 :
101102 continue
102- if errors and not all ((any (message in error for message in self .skippedMessages ) for error in errors .splitlines ())):
103- problematicWorlds .append (self .worlds [i ])
103+ if errors :
104+ unwanted = [e for e in errors .splitlines () if not any (message in e for message in self .skippedMessages )]
105+ if unwanted :
106+ problematicWorlds .append (self .worlds [i ])
107+ worldWarnings [self .worlds [i ]] = unwanted
104108 if errors and self .crashError in str (errors ):
105109 crashedWorlds .append (self .worlds [i ])
106110
@@ -118,10 +122,13 @@ def test_worlds_warnings_and_cache(self):
118122
119123 if crashedWorlds :
120124 print ('\n \t ' .join (['Impossible to test the following worlds because they crash when loading:' ] + crashedWorlds ))
121- self .assertTrue (
122- not problematicWorlds ,
123- msg = '\n \t ' .join (['The following worlds have unwanted warnings:' ] + problematicWorlds )
124- )
125+ if problematicWorlds :
126+ details = ['The following worlds have unwanted warnings:' ]
127+ for world in problematicWorlds :
128+ details .append (f'{ world } ({ len (worldWarnings [world ])} warning(s))' )
129+ for warning in worldWarnings [world ]:
130+ details .append (' ' + warning )
131+ self .fail ('\n \t ' .join (details ))
125132
126133 if worldsWithNonCachedAssets :
127134 print ('\n The following worlds reference non-cached assets:' )
0 commit comments