From 396f55fb173f89fed0450cc7a608f958c26ab5d0 Mon Sep 17 00:00:00 2001 From: Neerti Date: Sun, 19 Nov 2017 06:07:41 -0500 Subject: [PATCH] Allows Travis to Validate PoI Maps Tweaks Travis to compile all PoI maps in order to allow the compiler to find certain problems such as missing paths. This is needed because PoIs are loaded at runtime as opposed to being compiled like traditional maps, making them a bit prone to problems. Travis should help find those problems before they reach the live server by failing PRs which add a broken PoI map or break any existing PoI maps. For regular use, the PoIs will not be compiled unless done so manually by the developer. --- .travis.yml | 7 ++++++- code/_map_tests.dm | 10 ++++++++++ code/unit_tests/map_tests.dm | 3 ++- maps/submaps/_readme.dm | 4 ++++ maps/submaps/cave_submaps/cave.dm | 9 +++++++++ maps/submaps/space_submaps/space.dm | 7 +++++++ maps/submaps/surface_submaps/forest.dm | 8 ++++++++ polaris.dme | 1 + 8 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 code/_map_tests.dm diff --git a/.travis.yml b/.travis.yml index b6eb33966b7..edd9984f84c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,9 +36,14 @@ script: - (num=`grep -E '\\\\(red|blue|green|black|b|i[^mc])' **/*.dm | wc -l`; echo "$num escapes (expecting ${MACRO_COUNT} or less)"; [ $num -le ${MACRO_COUNT} ]) - source $HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR}/byond/bin/byondsetup - python tools/TagMatcher/tag-matcher.py ../.. - - echo "#define UNIT_TEST 1" > code/_unit_tests.dm + #First compile is to ensure maps are valid. + - echo "#define MAP_TEST 1" > code/_map_tests.dm - cp config/example/* config/ - DreamMaker polaris.dme + - echo "#define MAP_TEST 0" > code/_map_tests.dm + #Second compile is for the unit tests. Compiling a second time to exclude the validated maps is actually faster than waiting for startup with them compiled. + - echo "#define UNIT_TEST 1" > code/_unit_tests.dm + - DreamMaker polaris.dme - DreamDaemon polaris.dmb -invisible -trusted -core 2>&1 | tee log.txt - grep "All Unit Tests Passed" log.txt diff --git a/code/_map_tests.dm b/code/_map_tests.dm new file mode 100644 index 00000000000..90a4004b792 --- /dev/null +++ b/code/_map_tests.dm @@ -0,0 +1,10 @@ +/* + * + * This file is used by Travis to indicate that additional maps need to be compiled to look for errors such as missing paths. + * Do not add anything but the MAP_TEST definition here as it will be overwritten by Travis when running tests. + * + * + * Should you wish to edit set MAP_TEST to 1 like so: + * #define MAP_TEST 1 + */ +#define MAP_TEST 0 diff --git a/code/unit_tests/map_tests.dm b/code/unit_tests/map_tests.dm index f8f735f8676..cdab40ee7ac 100644 --- a/code/unit_tests/map_tests.dm +++ b/code/unit_tests/map_tests.dm @@ -12,7 +12,8 @@ /area/holodeck, /area/supply/station, /area/mine, - /area/vacant/vacant_shop + /area/vacant/vacant_shop, + /area/submap ) var/list/exempt_from_atmos = typesof(/area/maintenance, diff --git a/maps/submaps/_readme.dm b/maps/submaps/_readme.dm index 1608dfe5b1c..0677d6d8d63 100644 --- a/maps/submaps/_readme.dm +++ b/maps/submaps/_readme.dm @@ -24,4 +24,8 @@ is being loaded (to clear trees, etc). Be sure to not load the map on top of an irreplacable objects or players, as they will all get deleted if annihilate is on. If you load the submap before other objects have a chance to spawn (before random map gen), you shouldn't need to use annihilate. + When adding a new submap which will be loaded at runtime, you should add it to the list of '#include'-s on the top of the +map template file. This forces the submap to be compiled when the code is undergoing a unit test, which will help keep the +submap from suffering errors such as invalid paths due to them being changed elsewhere. + */ \ No newline at end of file diff --git a/maps/submaps/cave_submaps/cave.dm b/maps/submaps/cave_submaps/cave.dm index f5fb874b4a0..87ab786d792 100644 --- a/maps/submaps/cave_submaps/cave.dm +++ b/maps/submaps/cave_submaps/cave.dm @@ -1,3 +1,12 @@ +// This causes PoI maps to get 'checked' and compiled, when undergoing a unit test. +// This is so Travis can validate PoIs, and ensure future changes don't break PoIs, as PoIs are loaded at runtime and the compiler can't catch errors. +// When adding a new PoI, please add it to this list. +#if MAP_TEST +#include "deadBeacon.dmm" +#include "prepper1.dmm" +#include "quarantineshuttle.dmm" +#endif + /datum/map_template/cave name = "Cave Content" desc = "Don't dig too deep!" diff --git a/maps/submaps/space_submaps/space.dm b/maps/submaps/space_submaps/space.dm index cfa45b6965d..a4771861e53 100644 --- a/maps/submaps/space_submaps/space.dm +++ b/maps/submaps/space_submaps/space.dm @@ -1,3 +1,10 @@ +// This causes PoI maps to get 'checked' and compiled, when undergoing a unit test. +// This is so Travis can validate PoIs, and ensure future changes don't break PoIs, as PoIs are loaded at runtime and the compiler can't catch errors. +// When adding a new PoI, please add it to this list. +#if MAP_TEST +// #define "your_map_here.dmm" +#endif + /datum/map_template/space name = "Space Content" desc = "A map template base. In space." diff --git a/maps/submaps/surface_submaps/forest.dm b/maps/submaps/surface_submaps/forest.dm index 40a045a37da..6cd100a497a 100644 --- a/maps/submaps/surface_submaps/forest.dm +++ b/maps/submaps/surface_submaps/forest.dm @@ -1,3 +1,11 @@ +// This causes PoI maps to get 'checked' and compiled, when undergoing a unit test. +// This is so Travis can validate PoIs, and ensure future changes don't break PoIs, as PoIs are loaded at runtime and the compiler can't catch errors. +// When adding a new PoI, please add it to this list. +#if MAP_TEST +#include "farm1.dmm" +#include "spider1.dmm" +#endif + /datum/map_template/surface name = "Surface Content" desc = "Used to make the surface by 17% less boring." diff --git a/polaris.dme b/polaris.dme index 46ed0fab3da..03005e4b2d5 100644 --- a/polaris.dme +++ b/polaris.dme @@ -11,6 +11,7 @@ // END_PREFERENCES // BEGIN_INCLUDE #include "code\_macros.dm" +#include "code\_map_tests.dm" #include "code\_unit_tests.dm" #include "code\global.dm" #include "code\hub.dm"