Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/mod/hwdetect/test.js
// Run in a standalone JS shell like | // Run in a standalone JS shell like: | ||||
// js -e 'var global={}' -f hwdetect.js -f test_data.js -f test.js > output.html | // js -e 'var global={}' -f hwdetect.js -f test.js | ||||
// where test_data.js is a giant file that's probably not publicly available yet | |||||
// (ask Philip if you want a copy), then look at output.html and make sure it's | |||||
// applying the hwdetected settings in the appropriate cases | |||||
print("<!DOCTYPE html>"); | // Add settings to test below. | ||||
print("<meta charset=utf-8>"); | let testSettings = [ | ||||
print("<style>body { font: 8pt sans-serif; }</style>"); | {os_linux: 1, os_macosx: 0, os_win: 0, GL_RENDERER: "Intel", GL_VERSION: "4.5"}, | ||||
print("<table>"); | {os_linux: 1, os_macosx: 0, os_win: 0, GL_RENDERER: "Intel", GL_VERSION: "3.3"}, | ||||
print("<tr>"); | {os_linux: 1, os_macosx: 0, os_win: 0, GL_RENDERER: "Intel", GL_VERSION: "2.1"}, | ||||
print("<th>OS"); | {os_linux: 1, os_macosx: 0, os_win: 0, GL_RENDERER: "", GL_VERSION: "4.5"}, | ||||
print("<th>GL_RENDERER"); | {os_linux: 1, os_macosx: 0, os_win: 0, GL_RENDERER: "", GL_VERSION: "3.3"}, | ||||
print("<th>Output"); | {os_linux: 0, os_macosx: 1, os_win: 0, GL_RENDERER: "Intel", GL_VERSION: "2.1"}, | ||||
print("<th>Warnings"); | {os_linux: 0, os_macosx: 1, os_win: 0, GL_RENDERER: "Intel", GL_VERSION: "1.4"}, | ||||
{os_linux: 0, os_macosx: 0, os_win: 1, GL_RENDERER: "Intel", GL_VERSION: "4.5"}, | |||||
{os_linux: 0, os_macosx: 0, os_win: 1, GL_RENDERER: "Intel", GL_VERSION: "2.0"}, | |||||
]; | |||||
hwdetectTestData.sort(function(a, b) { | for (let settings of testSettings) | ||||
if (a.GL_RENDERER < b.GL_RENDERER) | |||||
return -1; | |||||
if (b.GL_RENDERER < a.GL_RENDERER) | |||||
return +1; | |||||
return 0; | |||||
}); | |||||
for (var settings of hwdetectTestData) | |||||
{ | { | ||||
var output = RunDetection(settings); | print("OS: " + (settings.os_linux ? "os_linux" : settings.os_macosx ? "os_macosx" : settings.os_win ? "os_win" : "unknown os") + | ||||
", GL_RENDERER: " + settings.GL_RENDERER + ", GL_VERSION: " + settings.GL_VERSION); | |||||
var os = (settings.os_linux ? "linux" : settings.os_macosx ? "macosx" : settings.os_win ? "win" : "???"); | |||||
var disabled = []; | let output = RunDetection(settings); | ||||
for (var d of ["disable_audio", "disable_s3tc", "disable_shadows", "disable_shadowpcf", "disable_allwater", "disable_fancywater", "override_renderpath"]) | |||||
if (output[d] !== undefined) | |||||
disabled.push(d+"="+output[d]) | |||||
print("<tr>"); | for (let option in output) | ||||
print("<td>" + os); | print(option + ": " + output[option]); | ||||
print("<td>" + settings.GL_RENDERER); | |||||
print("<td>" + disabled.join(" ")); | |||||
print("<td>" + output.warnings.concat(output.dialog_warnings).join("\n")); | |||||
} | } | ||||
print("</table>"); |
Wildfire Games · Phabricator