Page MenuHomeWildfire Games

D13 collateral 5: automated test-map for pathfinder and UnitMotion behavior
AbandonedPublic

Authored by wraitii on May 7 2017, 10:31 AM.

Details

Reviewers
FeXoR
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Summary

This is a map I've created for D13. It uses trigger script to try and test some edge cases in the pathfinder.

As you can see from running it, our current implementation does not pass.

Should/Could be integrated in the unit tests at some points I suppose.

Test Plan

Start the map. Report that it works as expected.

Event Timeline

wraitii created this revision.May 7 2017, 10:31 AM
Owners added a subscriber: Restricted Owners Package.May 7 2017, 10:31 AM
Stan added a subscriber: Stan.May 7 2017, 1:26 PM
Stan added inline comments.
binaries/data/mods/public/maps/scenarios/Pathfinding_integrated_testmap.js
10 ↗(On Diff #1703)

Space before comment.

51 ↗(On Diff #1703)

Comments start with a cap.

76 ↗(On Diff #1703)

Caps at the beginning of a comment.

89 ↗(On Diff #1703)

Caps at the beginning of a comment.

Vulcan added a subscriber: Vulcan.May 7 2017, 1:46 PM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/1047/ for more details.

wraitii added a subscriber: elexis.Nov 26 2017, 9:44 AM

@elexis: do you mind if I commit this as-is? Code isn't super clean, but it's a debug map and it doesn't use rmgen or that kind of thing.

Alternatively I could wait for the modifiers manager to remove the XXXtreme hack.

FeXoR requested changes to this revision.Dec 10 2017, 2:50 PM
FeXoR added a subscriber: FeXoR.

The map doesn't load properly:

ERROR: Failed to load entity template 'gaia/fauna_chicken'
ERROR: Failed to load entity template 'units/maur_infantry_archer_b'
ERROR: Failed to load entity template 'structures/maur_civil_centre'
ERROR: Failed to load entity template 'structures/maur_house'
ERROR: Failed to load entity template 'structures/maur_house'
ERROR: Failed to load entity template 'units/maur_infantry_archer_b'
ERROR: Failed to load entity template 'other/obelisk'
ERROR: Failed to load entity template 'units/maur_infantry_archer_b'
...

I downloaded the raw diff and the pmp file (not included in the diff).
I tested on r20633 so it likely just needs to be rebased to match the template changes.

This revision now requires changes to proceed.Dec 10 2017, 2:50 PM

As you can see from running it, our current implementation does not pass.

What is the purpose of adding a test if it's not ensuring that our current implementation works?

Adding a testmap sounds good.

But it shouldn't be part of the public mod, should it? We do have special test mods: _test.sim, also some in source/.
So perhaps we could even attach a commands.txt and have that run in the test to confirm.
Et voila, an integration test.
The map would have a tiny memory footprint and should pass as quickly as possible (since we don't want to wait long for the tests to finish).
If keeping it short is too hard to achieve, we could make that an extended test and pass that as a flag.

binaries/data/mods/public/maps/scenarios/Pathfinding_integrated_testmap.js
1 ↗(On Diff #1703)

Filename: Pathfinding_integrated_testmap_trigger.js for consistency with the other trigger scripts.

1 ↗(On Diff #1703)

warnings only to actually warn, otherwise we had log which doesn't even make it to stdout. Not sure if we had another one for your use case. print? See ScriptInterface.cpp

10 ↗(On Diff #1703)

XXXtreme hack is part of the words I don't like to see in code ;-)

A special filter might also work: templateName = "no_range|archer.xml", but in both cases we might not be happy about having these in our general folder.

I had the idea once to create simulation template subfolders in the map directory, but that also sounds like increasing not reducing mess.

16 ↗(On Diff #1703)

Please put a scope { } around everything and only use local variables or prototype variables. Not that we need to be serialization-safe here, but we shouldn't leave a bad example that is copied in maps that should be serialization safe.

199 ↗(On Diff #1703)

could use ternary

What is the purpose of adding a test if it's not ensuring that our current implementation works?

Well the purpose of this map was to show that SVN fails and D13 passes, of course. So if we commit as is, SVN still fails. That's kind of the whole point. Our pathfindre/UnitMotion implementation is a failure.

binaries/data/mods/public/maps/scenarios/Pathfinding_integrated_testmap.js
10 ↗(On Diff #1703)

My idea to reduce this mess is D274

wraitii updated this revision to Diff 4703.Dec 10 2017, 4:10 PM

Upload PmP, fix the map.

It doesn't actually work that well since I can't properly detect when units stop moving without D13, so that's annoying. Test 211 also succeeds when it should fail, and some tests don't fail explicitly because of the moving thing.

But you can still notice a unit manages to get inside an impassable forest and another can't manager to get around a wall of unit.

Executing section Default...
Executing section Source...
Executing section JS...

binaries/data/mods/public/maps/scenarios/Pathfinding_integrated_testmap_triggers.js
| 105| »   }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/maps/scenarios/Pathfinding_integrated_testmap_triggers.js
| 197| »   }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/maps/scenarios/Pathfinding_integrated_testmap_triggers.js
| 198| }·(Trigger))
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

Successful build - Chance fights ever on the side of the prudent.

Updating workspaces...
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (308 tests)....................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (308 tests)....................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

I did apply the patch and added the raw pmp file from this ticket. Or where should I get the pmp file from?

Tested the 2nd patch with the the proper base revision r20628 and it still throws with similar errors:
ERROR: RelaxNGValidator: Validation error: units/maur_infantry_archer_b:1: Did not expect element RangeOverlayRenderer there

ERROR: RelaxNGValidator: Validation error: units/maur_infantry_archer_b:1: Element Entity has extra content: RangeOverlayRenderer

ERROR: RelaxNGValidator: Validation failed for '(null)'

ERROR: Failed to validate entity template 'units/maur_infantry_archer_b'

ERROR: Failed to load entity template 'units/maur_infantry_archer_b'

ERROR: RelaxNGValidator: Validation error: structures/maur_house:1: Did not expect element RangeOverlayRenderer there

ERROR: RelaxNGValidator: Validation error: structures/maur_house:1: Element Entity has extra content: RangeOverlayRenderer

ERROR: RelaxNGValidator: Validation failed for '(null)'

ERROR: Failed to validate entity template 'structures/maur_house'

ERROR: Failed to load entity template 'structures/maur_house'

FeXoR requested changes to this revision.Dec 11 2017, 12:09 PM
This revision now requires changes to proceed.Dec 11 2017, 12:09 PM
FeXoR added a comment.EditedDec 11 2017, 3:25 PM

My fault, didn't compile, sry.

Test 393 fails while the other 19 succeed.
However, '"type" : "hunt", "becomes":440' is not really telling to me what exactly failed.

Requested changes:

  • There should be a message when all tests gave a result like "All tests done".
  • Also add something like "let t = tests[test];" for this is used quite a lot.
  • In case of failure (or also success) a telling explanation what exactly failed (or succeeded).

I wonder about the seemingly arbitrary test numbers. Is it the unit ID?
(I'd picked log in case of success but as is - with warnings - it's easier to find in the logs.)

In general I find such a map useful to detect flaws in future pathfinding related patches.

wraitii abandoned this revision.May 25 2019, 4:40 PM

Committed a better version of this.