To include tests.collection (or anything else) in the bundle without referencing it somewhere, you can declare it as a custom resource in game.project, in the “Project” category.
Are you bundling the game every time you make a change to it, maybe because you want to test it without Defold’s profiler and all? Or do you want to test different collections without changing the value in the game.project file because you might forget to change it back?
My approach is to have two collection proxies in main.collection and use a script to determine which collection is played. It would look like this. It follows the “loader” pattern described in the Collection Proxy manual.
go.property('play_debug_collection', false)
function init(self)
if sys.get_engine_info().is_debug and self.play_debug_collection then
msg.post('#tests', 'load')
else
msg.post('#start game', 'load')
end
end
function on_message(self, message_id, message, sender)
if message_id == hash('proxy_loaded') then
msg.post(sender, 'init')
msg.post(sender, 'enable')
end
end
Then the file path and toggle belong to main.collection instead of in game.project, and the debug collection won’t be accidentally loaded in a release build.
Building on the proxy idea, one trick that keeps main.collection untouched is to add a custom key to game.project, something like [bootstrap] start = level_03, and read it at startup with sys.get_config_string(“bootstrap.start”). Your loader script then picks which collection proxy to load from that value. When you bundle from the command line, bob can override the value with a small .ini passed to --settings, so you can make test builds that start on a given level without editing the project. It also means nobody accidentally commits a changed main collection.
If you use a custom key like that, then you could play different levels in the editor by entering the command line argument in the editor preferences window (File → Preferences), making it truly local to your editor.
It’s not quite as slick as testing a random scene in Godot, but I like it.