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

Fix the examples checks, Add svg ref image #5005

Merged
merged 2 commits into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading
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>