Streamline test generation more
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Fri, 23 Sep 2011 13:45:25 -0600
changeset 627 f6a356eb9f31
parent 626 963926c4a021
child 628 20505f74e222
Streamline test generation more
conformancetest/fixdata
conformancetest/gentest.html
conformancetest/submit.php
--- a/conformancetest/fixdata	Fri Sep 23 12:17:35 2011 -0600
+++ b/conformancetest/fixdata	Fri Sep 23 13:45:25 2011 -0600
@@ -23,4 +23,3 @@
 # of WebKit's.
 cp webkit-data data.js
 patch data.js patch
-echo >> data.js
--- a/conformancetest/gentest.html	Fri Sep 23 12:17:35 2011 -0600
+++ b/conformancetest/gentest.html	Fri Sep 23 13:45:25 2011 -0600
@@ -5,21 +5,22 @@
 <p>See the <a href=editing.html#tests>Tests</a> section of the specification
 for documentation.
 
-<p><button onclick="generateTests(); this.parentNode.removeChild(this)">Generate all tests</button>
+<p><button onclick="generateTests(); this.parentNode.removeChild(this)">Generate and submit tests</button>
 
 <p id=timing></p>
 
-<div id=errors></div>
+<ul id=errors></ul>
 
 <form action=submit.php method=post>
-<p><input type=submit disabled>
+<input type=hidden name=elapsed>
+<input type=hidden name=output>
+<input type=hidden name=errors>
 <p><label><input type=radio name=ua value=gecko> Gecko</label>
    <label><input type=radio name=ua value=webkit> WebKit</label>
 <!-- Username is ignored, it's just so browsers offer to remember the password.
 -->
 <p><label>Username: <input value=dummyuser name=username></label>
 <p><label>Password: <input type=password name=password></label>
-<p><textarea name=data id=output readonly style=width:100%;height:20em></textarea>
 </form>
 
 <div id=test-container></div>
@@ -56,11 +57,11 @@
 					generateTest(normalizeTest(command, test, true));
 				}
 			} catch(e) {
-				var errorP = document.createElement("p");
-				errorP.textContent = "Exception, "
+				var errorItem = document.createElement("li");
+				errorItem.textContent = "Exception, "
 					+ command + " " + JSON.stringify(test) + ": "
 					+ formatException(e);
-				document.getElementById("errors").appendChild(errorP);
+				document.getElementById("errors").appendChild(errorItem);
 			}
 		});
 	}
@@ -69,17 +70,16 @@
 	// like that, then add a closing bracket.
 	testOutput = testOutput.substr(0, testOutput.lastIndexOf(","))
 		+ testOutput.substr(1 + testOutput.lastIndexOf(","))
-		+ "]";
-	document.getElementById("output").value = testOutput;
+		+ "]\n";
+	document.querySelector("input[name=output]").value = testOutput;
+	document.querySelector("input[name=elapsed]").value =
+		Math.round(Date.now() - startTime);
+	document.querySelector("input[name=errors]").value =
+		document.querySelector("#errors").innerHTML;
 
 	document.getElementById("test-container").parentNode
 		.removeChild(document.getElementById("test-container"));
-	var elapsed = Math.round(Date.now() - startTime)/1000;
-	document.getElementById("timing").textContent =
-		"Time elapsed: " + Math.floor(elapsed/60) + ":"
-		+ ((elapsed % 60) < 10 ? "0" : "")
-		+ (elapsed % 60).toFixed(3) + " min.";
-	document.querySelector("[type=submit]").disabled = false;
+	document.querySelector("form").submit();
 }
 
 // Helper function for generateTest()
@@ -133,7 +133,7 @@
  * null for any of the last six entries means an INVALID_ACCESS_ERR must be
  * raised.
  *
- * The converted test value is then added to the pre with id=output.
+ * The converted test value is then added to the testOutput variable.
  */
 function generateTest(test) {
 	var testDiv = document.querySelector("div[contenteditable]");
--- a/conformancetest/submit.php	Fri Sep 23 12:17:35 2011 -0600
+++ b/conformancetest/submit.php	Fri Sep 23 13:45:25 2011 -0600
@@ -1,21 +1,26 @@
 <?php
 # I hate PHP, but it's what I know, so this is fastest . . .
+echo '<!doctype html>';
+
 if (empty($_POST)) {
-	die('<!doctype html><title>Error</title><p>Not POSTed');
+	die('<title>Error</title><p>Not POSTed');
 }
 
 if (sha1($_POST['password']) !== 'd962ad564032fa99ca43e8f0f6875c8efb9e2905') {
 	# I love how hash functions let me leave the source code open with no
 	# database or secret files, without disclosing the password.
-	die('<!doctype html><title>Error</title><p>Incorrect password');
+	die('<title>Error</title><p>Incorrect password');
 }
 
 if ($_POST['ua'] !== 'webkit' && $_POST['ua'] !== 'gecko') {
-	die('<!doctype html><title>Error</title><p>No UA provided: must be either "webkit" or "gecko"');
+	die('<title>Error</title><p>No UA provided: must be either "webkit" or "gecko"');
 }
 
-if (file_put_contents($_POST['ua'] . '-data', $_POST['data']) === false) {
-	die('<!doctype html><title>Error</title><p>Write failed!');
+if (file_put_contents($_POST['ua'] . '-data', $_POST['output']) === false) {
+	die('<title>Error</title><p>Write failed!');
 }
 
-echo '<!doctype html><title>Success</title><p>Successfully wrote ' . $_POST['ua'] . '-data';
+echo '<title>Success</title><p>Successfully wrote ' . $_POST['ua'] . '-data.';
+echo '<p>Time taken for test generation: ' . intval($_POST['elapsed']/60000)
+	. ':' . sprintf('%06.3F', ($_POST['elapsed'] % 60000)/1000) . ' min.';
+echo '<ul>' . $_POST['errors'] . '</ul>';