-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools: Initial reftests implementation.
- Loading branch information
1 parent
8716f32
commit 98125f3
Showing
21 changed files
with
208 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ compile_commands.json | |
_local/ | ||
*._local | ||
*.trace | ||
*.iml | ||
*.iml | ||
.cache |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from cutekit import ensure | ||
|
||
ensure((0, 7, 6)) | ||
|
||
from . import reftest, tools # noqa E402, F401: Needed for side effect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from cutekit import shell, vt100, cli, builder, model | ||
from pathlib import Path | ||
import dataclasses as dt | ||
from dataclasses_json import DataClassJsonMixin | ||
import tempfile | ||
|
||
|
||
def buildPaperMuncher(args: model.TargetArgs) -> builder.ProductScope: | ||
scope = builder.TargetScope.use(args) | ||
component = scope.registry.lookup("vaev-tools", model.Component) | ||
if component is None: | ||
raise RuntimeError("paper-muncher not found") | ||
return builder.build(scope, component)[0] | ||
|
||
|
||
@cli.command(None, "reftests", "Manage the reftests") | ||
def _(args: model.TargetArgs): | ||
paperMuncher = buildPaperMuncher(args) | ||
|
||
for file in shell.find("tests", ["*.html", "*.xhtml"]): | ||
print(f"Running reftest {file}...") | ||
path = Path(file) | ||
|
||
refPath = path.parent / ".ref" / (path.name + ".ref") | ||
output = paperMuncher.popen("html2pdf", "-sdlpo", "/dev/null", file) | ||
|
||
if not refPath.exists(): | ||
vt100.warning(f"{refPath} not found, creating reference") | ||
refPath.parent.mkdir(parents=True, exist_ok=True) | ||
with refPath.open("x") as ref: | ||
ref.write(output) | ||
continue | ||
|
||
with refPath.open() as ref: | ||
refContent = ref.read() | ||
|
||
if refContent == output: | ||
print(f"{vt100.GREEN}Passed{vt100.RESET}") | ||
else: | ||
print(f"{vt100.RED}Failed{vt100.RESET}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
git+https://github.com/cute-engineering/[email protected].5 | ||
git+https://github.com/cute-engineering/[email protected].6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
--- START OF DOM --- | ||
(DOCUMENT | ||
(DOCUMENT_TYPE name="html" publicId="" systemId="") | ||
(ELEMENT tagName=html | ||
(ATTRIBUTE localName=HTML:lang value="en") | ||
(TEXT data="\n\n") | ||
(ELEMENT tagName=body | ||
(TEXT data="\n ") | ||
(ELEMENT tagName=div) | ||
(TEXT data="\n") | ||
) | ||
(TEXT data="\n\n") | ||
(ELEMENT tagName=style | ||
(TEXT data="\n div {\n width: 100px;\n height: 100px;\n background-color: red;\n }\n\n div {\n background-color: green;\n }\n\n div {\n background-color: blue;\n }\n") | ||
) | ||
(TEXT data="\n\n") | ||
) | ||
) | ||
|
||
--- END OF DOM --- | ||
|
||
--- START OF STYLE --- | ||
(style-book [(style-sheet text/css . | ||
rules: [ | ||
(style-rule | ||
selector: html | ||
props: [ | ||
(display (display box: CONTENTS)) | ||
] | ||
) | ||
(style-rule | ||
selector: (OR [head, style]) | ||
props: [ | ||
(display (display box: NONE)) | ||
] | ||
) | ||
(style-rule | ||
selector: table | ||
props: [ | ||
(display (display inside: TABLE, outside: BLOCK, item: NO)) | ||
] | ||
) | ||
(style-rule | ||
selector: caption | ||
props: [ | ||
(display (display internal: TABLE_CAPTION)) | ||
] | ||
) | ||
(style-rule | ||
selector: colgroup | ||
props: [ | ||
(display (display internal: TABLE_COLUMN_GROUP)) | ||
] | ||
) | ||
(style-rule | ||
selector: col | ||
props: [ | ||
(display (display internal: TABLE_COLUMN)) | ||
] | ||
) | ||
(style-rule | ||
selector: thead | ||
props: [ | ||
(display (display internal: TABLE_HEADER_GROUP)) | ||
] | ||
) | ||
(style-rule | ||
selector: tbody | ||
props: [ | ||
(display (display internal: TABLE_ROW_GROUP)) | ||
] | ||
) | ||
(style-rule | ||
selector: tfoot | ||
props: [ | ||
(display (display internal: TABLE_FOOTER_GROUP)) | ||
] | ||
) | ||
(style-rule | ||
selector: tr | ||
props: [ | ||
(display (display internal: TABLE_ROW)) | ||
] | ||
) | ||
(style-rule | ||
selector: (OR [td, th]) | ||
props: [ | ||
(display (display internal: TABLE_CELL)) | ||
] | ||
) | ||
] | ||
), (style-sheet text/css . | ||
rules: [ | ||
(style-rule | ||
selector: div | ||
props: [ | ||
(width 100PX) | ||
(height 100PX) | ||
(background-color [#00000000, #ff0000ff]) | ||
] | ||
) | ||
(style-rule | ||
selector: div | ||
props: [ | ||
(background-color [#00000000, #008000ff]) | ||
] | ||
) | ||
(style-rule | ||
selector: div | ||
props: [ | ||
(background-color [#00000000, #0000ffff]) | ||
] | ||
) | ||
] | ||
)]) | ||
--- END OF STYLE --- | ||
|
||
--- START OF LAYOUT --- | ||
(flow (display inside: FLOW, outside: INLINE, item: NO) (rect 0 0 210 100) | ||
(flow (display inside: FLOW, outside: INLINE, item: NO) (rect 0 0 210 100) | ||
(frag (display inside: FLOW, outside: INLINE, item: NO) (rect 0 0 100 100)) | ||
) | ||
) | ||
--- END OF LAYOUT --- | ||
|
||
--- START OF PAINT --- | ||
(stack | ||
(box (rect 0 0 210 100) (radii 0) [(color #00000000)]) | ||
(box (rect 0 0 210 100) (radii 0) [(color #00000000)]) | ||
(box (rect 0 0 100 100) (radii 0) [(color #00000000), (color #0000ffff)]) | ||
) | ||
--- END OF PAINT --- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<body> | ||
<div /> | ||
</body> | ||
|
||
<style> | ||
div { | ||
width: 100px; | ||
height: 100px; | ||
background-color: red; | ||
} | ||
|
||
div { | ||
background-color: green; | ||
} | ||
|
||
div { | ||
background-color: blue; | ||
} | ||
</style> | ||
|
||
</html> |