Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only throw on duplicate styles in strict mode #3917

Merged
merged 4 commits into from Jun 27, 2018

Conversation

springmeyer
Copy link
Member

#3770 added a throw on duplicate styles. I hit this in a system which I need back compatibility (can't easily avoid duplicate styles names). So, I think this check should only happen in strict mode.

/cc @talaj - sound good? One question I have is that I would assume this change would make the tests fail that you added in #3770 (unless the tests are put in strict mode). Any idea why they don't fail with this change as is?

@springmeyer springmeyer requested a review from talaj June 24, 2018 17:21
@codecov
Copy link

codecov bot commented Jun 24, 2018

Codecov Report

Merging #3917 into master will increase coverage by <.01%.
The diff coverage is 90%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3917      +/-   ##
==========================================
+ Coverage   68.78%   68.79%   +<.01%     
==========================================
  Files         442      442              
  Lines       23258    23266       +8     
==========================================
+ Hits        15998    16005       +7     
- Misses       7260     7261       +1
Impacted Files Coverage Δ
src/load_map.cpp 87.09% <90%> (+0.11%) ⬆️
include/mapnik/geometry/polygon.hpp 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e9ebc93...d60be13. Read the comment docs.

@lightmare
Copy link
Contributor

You avoid the config_error("duplicate style name") but still throw config_error("failed to insert style to the map"). The test requires a throw, doesn't check the message.

@springmeyer
Copy link
Member Author

Nice catch, thank you @lightmare. Tried to fix it to not throw (now) unless strict mode is on: 434511c. But that appears to still pass, so clearly I'm missing something.

@lightmare
Copy link
Contributor

$ test/standalone/map_xml_test-bin -s | grep -A4 duplicate
  path.native() := test/data/good_maps/duplicate_stylename.xml

test/standalone/map_xml_test.cpp:152: 
PASSED:
  REQUIRE_NOTHROW( load_map(m, path) )
--
  path.native() := test/data/broken_maps/duplicate_stylename.xml

test/standalone/map_xml_test.cpp:169: 
PASSED:
  REQUIRE_THROWS( mapnik::load_map(m, path.native(), true) )

They pass because the broken_maps test explicitly sets strict=true.

@springmeyer
Copy link
Member Author

With the last test fix I think this is ready to merge. Want to give a PR approval @lightmare?

@@ -156,6 +156,20 @@ TEST_CASE("map xml I/O") {
}
} // END SECTION

SECTION("duplicate styles only throw in strict mode") {
std::vector<bfs::path> broken_maps;
add_xml_files("test/data/broken_maps", broken_maps);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:normal dk
(that's vim command to delete this line and the one above ;))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch! thank you. fixed in d60be13

@lightmare
Copy link
Contributor

An aside comment. I haven't yet looked into what are the differences between strict/non-strict, whether it's supposed to persist or is just some temporary back-compatibility measure. But if it's something that affects many different parts of parsing and is long-lived, it might be worth having separate broken_maps_strict that are broken under strict=true but good under strict=false.

@springmeyer
Copy link
Member Author

it might be worth having separate broken_maps_strict that are broken under strict=true but good under strict=false.

That seems like a good idea. I think, if I remember right, that strict/non-strict mostly exists because of how fonts work in the renderer - fallbacks work still if some fonts are not able to be registered at map load. So non strict mode allows rendering to gracefully degrade. And since then we've hooked into it as a back compatibility measure, so all devs to opt-into new stricter checks when they have total . control over their system (like at map creation) and opt-out when they don't have control (existing working maps that should stay working).

@springmeyer springmeyer merged commit 42d3f2d into master Jun 27, 2018
@springmeyer springmeyer deleted the only-throw-on-dupe-style-in-strict-mode branch June 27, 2018 01:20
@lightmare lightmare added this to the v3.1.0 milestone Jul 10, 2018
leedejun pushed a commit to leedejun/mapnik that referenced this pull request Dec 26, 2023
…n-strict-mode

Only throw on duplicate styles in strict mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants