Skip to content

Commit

Permalink
Merge pull request #5005 from camptocamp/svgref
Browse files Browse the repository at this point in the history
Fix the examples checks,  Add svg ref image
  • Loading branch information
sbrunner committed Jul 12, 2019
2 parents f965c66 + a42a40e commit 79e7456
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
/contribs/gmf/build/
/contribs/gmf/examples/https.js
/dist/
/test/check-example/*.html.png
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ script:
# Webpack build of ngeo/gmf examples and gmf apps
- if [ "${TRAVIS_PULL_REQUEST}" = false ]; then export NODE_ENV=production; fi
- make examples-hosted
- buildtools/test_examples.py 1/1
- make check-examples
#- npm run typecheck
# Generate API doc
- "! (npm run typecheck|grep -v '^node_modules/'|grep '^[a-z]')"
Expand Down
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ help:
check: lint spell check-examples-checker check-examples test examples-hosted-apps

.PHONY: check-examples-checker
check-example-checker: $(CHECK_EXAMPLE_CHECKER)
check-examples-checker: $(CHECK_EXAMPLE_CHECKER)

.PHONY: check-examples
check-examples: $(BUILD_EXAMPLES_CHECK_TIMESTAMP_FILES)
Expand Down Expand Up @@ -277,7 +277,6 @@ gh-pages: .build/python-venv.timestamp
touch $@

.build/contribs/gmf/%.check.timestamp: .build/examples-gmf.timestamp \
.build/examples-hosted/contribs/gmf/%.js \
.build/node_modules.timestamp \
.build/httpserver.timestamp
mkdir -p $(dir $@)
Expand All @@ -296,6 +295,12 @@ gh-pages: .build/python-venv.timestamp
tail --lines=1 | sed 's/.* \([0-9\.]\+\) .*/\1/g')" \< 0.005 ]
touch $@

.build/test-check-example/%.check.timestamp: \
.build/httpserver.timestamp test/check-example/%.html
mkdir -p $(dir $@)
( ! node buildtools/check-example.js test/check-example/$*.html)
touch $@

.build/node_modules.timestamp: package.json
npm install
mkdir -p $(dir $@)
Expand Down
21 changes: 14 additions & 7 deletions buildtools/check-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ const screenshot = !arg.startsWith('http');
const screenshotPath = screenshot ? `${arg}.png` : undefined;
const url = screenshot ? `http://localhost:3000/${arg}` : arg;

try {
const OSMImage = fs.readFileSync(path.resolve(__dirname, 'osm.png'));
} catch (e) {
// Ignore
}
const OSMImage = (() => {
try {
return fs.readFileSync(path.resolve(__dirname, 'osm.png'));
} catch (e) {
// Ignore
return undefined;
}
})();

process.on('unhandledRejection', error => {
console.log(`UnhandledRejection: ${error.message}.`);
process.exit(2);
});

const requestsURL = new Set();
const start = new Date();
Expand Down Expand Up @@ -109,8 +117,7 @@ function loaded(page, browser) {
page.on('console', message => {
const type = message.type();
const location = message.location();
if (type !== 'log' && type !== 'debug' && type !== 'info' && type !== 'warning' &&
!location.url.startsWith('http://localhost:3000/.build/examples-hosted/dist/vendor.js') &&
if (!location.url.startsWith('http://localhost:3000/.build/examples-hosted/dist/vendor.js') &&
location.url.startsWith('http://localhost:3000/')
) {
console.log(`Console ${type}`);
Expand Down
43 changes: 0 additions & 43 deletions buildtools/test_examples.py

This file was deleted.

Binary file added examples/svg-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/svg.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ <h5>In an OpenLayers symboles</h5>
<li><code>'data:image/svg+xml;base64,' + btoa(require('./inline.svg?viewbox&width=30px'))</code></li>
<li><code>require('./url.svg?url')</code></li>
</ul>
<script type="text/javascript" src="dist/vendor.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions test/check-example/xhr-download-error.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<body>
<script>
const req = new XMLHttpRequest();
req.open('GET', 'http://www.mozilla.org/');
req.send(null);
req.open('GET', 'http://localhost:3000/wrong');
req.send();
</script>
</body>
</html>

0 comments on commit 79e7456

Please sign in to comment.