Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/dom/canvas/test/webgl-mochitest/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 3 kB image not shown  

Quelle  mochi-to-testcase.py   Sprache: Python

 
#! /usr/bin/env python3
import pathlib
import re
import sys

assert len(sys.argv) == 2
MOCHI_PATH = pathlib.Path(sys.argv[1])
assert MOCHI_PATH.suffix == ".html"

TEST_PATH = MOCHI_PATH.with_suffix(".solo.html")


def read_local_file(include):
    inc_path = MOCHI_PATH.parent
    file_path = inc_path / include

    try:
        return file_path.read_bytes()
    except IOError:
        return b""


SIMPLETEST_REPLACEMENT = b"""

<script>
// SimpleTest.js replacement

function debug(text) {
  var elem = document.getElementById('mochi-to-testcase-output');
  elem.innerHTML += '\\n
\\n'
 + text;
}

function ok(val, text) {
  var status = val ? 'Test green\\'>passed: '
                   : 'Test red\\' >FAILED: ';
  debug(status + text);
}

function todo(val, text) {
  var status = val ? 'Test orange\\'>UNEXPECTED PASS: '
                   : 'Test blue\\' >todo: ';
  debug(status + text);
}

function addLoadEvent(func) {
  window.addEventListener('load', func);
}

SimpleTest = {
  waitForExplicitFinish: () => {},
  finish: () => {},
  requestFlakyTimeout: () => {},
};

SpecialPowers = {
  pushPrefEnv: async (env, callback = null) => {
    console.log(`SpecialPowers.pushPrefEnv(${JSON.stringify(env)})`);
    await new Promise(res => {
        setTimeout(res, 0);
    });
    if (callback) {
        await callback();
    }
  },
  popPrefEnv: async (callback = null) => {
    console.log('SpecialPowers.popPrefEnv()');
    await new Promise(res => {
        setTimeout(res, 0);
    });
    if (callback) {
        await callback();
    }
  },
};
</script>
<div id='mochi-to-testcase-output'></div>

"""

INCLUDE_PATTERN = re.compile(b"](.*)\\.js['\"]>\\s*")
CSS_PATTERN = re.compile(
    b"]stylesheet['\"]\\s*href=['\"]([^=>]*)['\"]>"
)

with open(TEST_PATH, "wb"as fout:
    with open(MOCHI_PATH, "rb"as fin:
        for line in fin:
            skip_line = False
            for css in CSS_PATTERN.findall(line):
                skip_line = True
                print("Ignoring stylesheet: " + css.decode())

            for inc in INCLUDE_PATTERN.findall(line):
                skip_line = True
                if inc == b"/MochiKit/MochiKit":
                    continue

                if inc == b"/tests/SimpleTest/SimpleTest":
                    print("Injecting SimpleTest replacement")
                    fout.write(SIMPLETEST_REPLACEMENT)
                    continue

                inc_js = inc.decode() + ".js"
                inc_data = read_local_file(inc_js)
                if not inc_data:
                    print("Warning: Unknown JS file ignored: " + inc_js)
                    continue

                print("Injecting include: " + inc_js)
                fout.write(b"\n\n")
                continue

            if skip_line:
                continue

            fout.write(line)
            continue

Messung V0.5
C=94 H=70 G=82

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.