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

test: Add upstream html5lib-tests #447

Merged
merged 1 commit into from
Mar 12, 2022
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 .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test/data/html5lib-tests
test/data/html5lib-tests-fork
packages/*/dist/
test/dist/
node_modules
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "html5lib-tests-fork"]
path = test/data/html5lib-tests-fork
url = https://github.com/HTMLParseErrorWG/html5lib-tests
[submodule "html5lib-tests"]
path = test/data/html5lib-tests
url = https://github.com/HTMLParseErrorWG/html5lib-tests
url = https://github.com/html5lib/html5lib-tests.git
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
packages/*/dist/
test/dist/
docs
test/data/html5lib-tests
test/data/html5lib-tests
test/data/html5lib-tests-fork
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"lint:prettier": "npm run prettier -- --check",
"unit-tests": "NODE_OPTIONS=--experimental-vm-modules jest",
"test": "npm run lint && npm run unit-tests",
"generate-feedback-tests": "node --loader ts-node/esm scripts/generate-parser-feedback-test/index.ts test/data/html5lib-tests/tree-construction/*.dat test/data/tree-construction-regression/*.dat",
"generate-feedback-tests": "node --loader ts-node/esm scripts/generate-parser-feedback-test/index.ts test/data/html5lib-tests/tree-construction/*.dat",
"bench-perf": "npm run build && node bench/perf/index.js",
"bench-memory-sax": "npm run build && node bench/memory/sax-parser.js",
"preversion": "npm test",
Expand Down
8 changes: 0 additions & 8 deletions packages/parse5/lib/tokenizer/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as parse5 from 'parse5';
import { Tokenizer } from 'parse5/dist/tokenizer/index.js';
import { generateTokenizationTests } from 'parse5-test-utils/utils/generate-tokenization-tests.js';

Expand All @@ -8,10 +7,3 @@ const tokenizerOpts = {
};

generateTokenizationTests('Tokenizer', dataPath.pathname, (handler) => new Tokenizer(tokenizerOpts, handler));

describe('tokenizer', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test was upstreamed in html5lib/html5lib-tests#145

it('Regression - `<<` in comment parses correctly (GH-325)', () => {
const document = parse5.parse('<!--<<-->');
expect(document.childNodes[0]).toHaveProperty('data', '<<');
});
});
2 changes: 1 addition & 1 deletion test/data/html5lib-tests
Submodule html5lib-tests updated 56 files
+5 −0 encoding/scripted/tests1.dat
+0 −6 encoding/tests1.dat
+6 −0 tokenizer/contentModelFlags.test
+140 −17 tokenizer/domjs.test
+36 −2 tokenizer/entities.test
+99 −1 tokenizer/test1.test
+4 −0 tokenizer/test2.test
+532 −2 tokenizer/test3.test
+1 −1 tokenizer/test4.test
+7 −3 tree-construction/README.md
+0 −34 tree-construction/adoption01.dat
+0 −4 tree-construction/adoption02.dat
+0 −24 tree-construction/blocks.dat
+30 −28 tree-construction/comments01.dat
+6 −49 tree-construction/doctype01.dat
+ tree-construction/domjs-unsafe.dat
+0 −90 tree-construction/entities01.dat
+2 −46 tree-construction/entities02.dat
+109 −15 tree-construction/foreign-fragment.dat
+0 −42 tree-construction/html5test-com.dat
+0 −8 tree-construction/inbody01.dat
+0 −6 tree-construction/isindex.dat
+23 −0 tree-construction/math.dat
+0 −25 tree-construction/menuitem-element.dat
+6 −2 tree-construction/namespace-sensitivity.dat
+18 −62 tree-construction/noscript01.dat
+ tree-construction/pending-spec-changes-plain-text-unsafe.dat
+0 −4 tree-construction/pending-spec-changes.dat
+ tree-construction/plain-text-unsafe.dat
+1 −42 tree-construction/ruby.dat
+0 −52 tree-construction/scriptdata01.dat
+46 −0 tree-construction/search-element.dat
+104 −0 tree-construction/svg.dat
+0 −34 tree-construction/tables01.dat
+24 −229 tree-construction/template.dat
+0 −204 tree-construction/tests1.dat
+0 −48 tree-construction/tests10.dat
+0 −7 tree-construction/tests15.dat
+0 −312 tree-construction/tests16.dat
+53 −37 tree-construction/tests18.dat
+0 −19 tree-construction/tests19.dat
+0 −33 tree-construction/tests2.dat
+261 −32 tree-construction/tests20.dat
+8 −34 tree-construction/tests21.dat
+0 −10 tree-construction/tests22.dat
+0 −10 tree-construction/tests23.dat
+0 −6 tree-construction/tests25.dat
+60 −3 tree-construction/tests26.dat
+0 −24 tree-construction/tests3.dat
+0 −34 tree-construction/tests5.dat
+1 −72 tree-construction/tests6.dat
+0 −17 tree-construction/tests7.dat
+3 −20 tree-construction/tests8.dat
+0 −18 tree-construction/tricky01.dat
+18 −86 tree-construction/webkit01.dat
+33 −35 tree-construction/webkit02.dat
1 change: 1 addition & 0 deletions test/data/html5lib-tests-fork
Submodule html5lib-tests-fork added at 11c321
3 changes: 2 additions & 1 deletion test/utils/generate-parsing-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ function createParsingTest<T extends TreeAdapterTypeMap>(
};
}

const treePath = new URL('../data/html5lib-tests/tree-construction', import.meta.url);
// TODO: Stop using the fork here.
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we have an issue somewhere for this? would be good to mention the number i think

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Opened as #448

const treePath = new URL('../data/html5lib-tests-fork/tree-construction', import.meta.url);
const treeRegressionPath = new URL('../data/tree-construction-regression', import.meta.url);

export function generateParsingTests(
Expand Down