diff --git a/css/css-writing-modes/tools/generators/README.md b/css/css-writing-modes/tools/generators/README.md deleted file mode 100644 index 9bf89de07a89719..000000000000000 --- a/css/css-writing-modes/tools/generators/README.md +++ /dev/null @@ -1,24 +0,0 @@ -Generators -========== - -Following test files are generated by the programs in this directory: -* orthogonal-parent-shrink-to-fit-001 - -## Setup - -1. Install node.js. -2. Change the current directory to this directory. -3. Type the following commands: -``` -npm install -``` -4. (optional) Install gulp globally so it'll be on your path: -``` -sudo npm install -g gulp -``` - -## Generate Test Files - -``` -gulp -``` diff --git a/css/css-writing-modes/tools/generators/generate.py b/css/css-writing-modes/tools/generators/generate.py new file mode 100755 index 000000000000000..6d54eebc0506dd1 --- /dev/null +++ b/css/css-writing-modes/tools/generators/generate.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 +import os +import string + +from typing import List, Tuple + +test_template = """

{number}: {title}

+
+ {html} +
""" + + +def generate_test_list() -> List[Tuple[str, str]]: + test_list = []; + outers = [ + ["inline-block", '
', '
ZZ'], + ["float", '
', '
ZZ'], + ["table-cell", '
', 'ZZ
']]; + middles = [ + None, + ["inline-block", '
', '
']]; + targets = [ + ["block", '
HH
'], + ["inline", 'HH'], + ["block with borders", '
HHH
'], + ["inline with borders", 'HHH']]; + for outer in outers: + for middle in middles: + for target in targets: + title = target[0]; + html = target[1]; + if middle is not None: + title += " in " + middle[0]; + html = middle[1] + html + middle[2]; + title = "Shrink-to-fit " + outer[0] + " with a child of orthogonal " + title; + html = outer[1] + html + outer[2]; + test_list.append((title, html)); + return test_list + + +def read_template() -> str: + with open("template.html") as f: + return f.read() + + +def main(): + template = read_template() + test_list = generate_test_list() + + dest_dir = os.path.abspath( + os.path.join(os.path.dirname(os.path.abspath(__file__)), + os.path.pardir, + os.path.pardir)) + + for index in range(-1, len(test_list)): + if index == -1: + offset = 0 + suffix = "" + tests = test_list + title = "Shrink-to-fit with orthogonal children" + flags = " combo" + else: + offset = index + suffix = string.ascii_letters[index] + tests = [test_list[index]] + title = tests[0][0] + flags = "" + + filename = f"orthogonal-parent-shrink-to-fit-001{suffix}.html" + + tests_data = [] + for idx, (test_title, html) in enumerate(tests): + number = offset + idx + 1 + tests_data.append(test_template.format(number=number, + title=test_title, + html=html)) + + output = template.replace("{{title}}", title) + output = output.replace("{{flags}}", flags) + output = output.replace("{{tests}}", "\n".join(tests_data)) + with open(os.path.join(dest_dir, filename), "w") as f: + f.write(output) + + +if __name__ == "__main__": + main() diff --git a/css/css-writing-modes/tools/generators/gulpfile.js b/css/css-writing-modes/tools/generators/gulpfile.js deleted file mode 100644 index f364024084dc0c2..000000000000000 --- a/css/css-writing-modes/tools/generators/gulpfile.js +++ /dev/null @@ -1,79 +0,0 @@ -'use strict'; - -var browserSync = null; -var gulp = require("gulp"); -var ejs = require("gulp-ejs"); -var rename = require("gulp-rename"); -var minimist = require('minimist'); -var argv = minimist(process.argv.slice(2)); - -gulp.task("default", [ - "orthogonal-parent-shrink-to-fit", -]); - -gulp.task("test", ["browser-sync", "watch"]); - -gulp.task("watch", function () { - gulp.watch("orthogonal-parent-shrink-to-fit.ejs", ["orthogonal-parent-shrink-to-fit"]); -}); - -gulp.task("browser-sync", function () { - if (!browserSync) - browserSync = require("browser-sync"); - browserSync({ - server: { - baseDir: "../../..", - directory: true, - }, - startPath: "css-writing-modes-3/", - }); -}); - -function reload() { - if (browserSync) - browserSync.reload(); -} - -gulp.task("server", function () { - var connect = require("connect"); - var serveIndex = require("serve-index"); - var serveStatic = require("serve-static"); - var directory = "../../.."; - var port = 8000; - connect() - .use(serveIndex(directory)) - .use(serveStatic(directory)) - .listen(port); - console.log("Listening on port " + port); -}) - -gulpTaskFromTemplateWithAffixes("orthogonal-parent-shrink-to-fit", "-001", -1, 24); - -gulp.task("update", function () { - const unicodeData = require('./unicode-data.js'); - unicodeData.copyToLocal(); -}); - -function gulpTaskFromTemplateWithAffixes(name, suffix, min, lim) { - if (argv.nocombo && min < 0) - min = 0; - if (argv.nochild && lim > 0) - lim = 0; - gulp.task(name, function () { - for (var i = min; i < lim; ++i) { - gulp.src(name + ".ejs") - .pipe(ejs({ index: i })) - .pipe(rename(name + suffix + affixFromIndex(i) + ".html")) - .pipe(gulp.dest("../..")); - } - reload(); - }); -} - -function affixFromIndex(index) { - if (index < 0) - return ""; - if (index >= 26) - throw new Error("Affix index too large (" + index + ")"); - return String.fromCharCode("a".charCodeAt(0) + index); -} diff --git a/css/css-writing-modes/tools/generators/package.json b/css/css-writing-modes/tools/generators/package.json deleted file mode 100644 index 8046cf4240aa37e..000000000000000 --- a/css/css-writing-modes/tools/generators/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "generators", - "version": "1.0.0", - "description": "", - "main": "gulpfile.js", - "dependencies": {}, - "devDependencies": { - "browser-sync": "^2.10.1", - "connect": "^3.4.0", - "ejs": "^2.3.1", - "gulp": "^3.8.11", - "gulp-ejs": "^1.1.0", - "gulp-rename": "^1.2.2", - "minimist": "^1.1.1", - "serve-index": "^1.7.2", - "serve-static": "^1.10.0" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC" -} diff --git a/css/css-writing-modes/tools/generators/orthogonal-parent-shrink-to-fit.ejs b/css/css-writing-modes/tools/generators/template.html similarity index 59% rename from css/css-writing-modes/tools/generators/orthogonal-parent-shrink-to-fit.ejs rename to css/css-writing-modes/tools/generators/template.html index 043cbaf747a7931..74fc1852320b3a9 100644 --- a/css/css-writing-modes/tools/generators/orthogonal-parent-shrink-to-fit.ejs +++ b/css/css-writing-modes/tools/generators/template.html @@ -1,48 +1,9 @@ -<% -var testlist = []; -var outers = [ - ["inline-block", '
', '
ZZ'], - ["float", '
', '
ZZ'], - ["table-cell", '
', 'ZZ
']]; -var middles = [ - null, - ["inline-block", '
', '
']]; -var targets = [ - ["block", '
HH
'], - ["inline", 'HH'], - ["block with borders", '
HHH
'], - ["inline with borders", 'HHH']]; -for (var outer of outers) { - for (var middle of middles) { - for (var target of targets) { - var title = target[0]; - var html = target[1]; - if (middle) { - title += " in " + middle[0]; - html = middle[1] + html + middle[2]; - } - title = "Shrink-to-fit " + outer[0] + " with a child of orthogonal " + title; - html = outer[1] + html + outer[2]; - testlist.push([title, html]); - } - } -} -var min, limit, title; -if (index < 0) { - min = 0; - limit = testlist.length; - title = "Shrink-to-fit with orthogonal children" -} else { - min = index; - limit = index + 1; - title = testlist[index][0]; -} -%>CSS Writing Modes Test: <%= title %> +CSS Writing Modes Test: {{title}} - - + + @@ -88,13 +49,8 @@

Test passes if the X-position of the left edge of the orange box and the right edge of the blue box are the same.

If script is enabled, there should be one or more PASS and no FAIL. -<% for (var i = min; i < limit; ++i) { - var test = testlist[i]; -%>

<%= (i + 1) + ": " + test[0] %>

-
- <%- test[1] %> +{{tests}}
-<% } %>