]> git.cworth.org Git - apitrace-tests/commitdiff
Add some comments to the recently-added cli tests.
authorCarl Worth <cworth@cworth.org>
Thu, 9 Aug 2012 00:18:32 +0000 (17:18 -0700)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sat, 1 Dec 2012 10:11:31 +0000 (10:11 +0000)
It's easy enough to ignore lines starting with a '#' and that lets us
make these tests more self-documenting.

cli/README.markdown
cli/cli-diff-images-mismatch.script
cli/cli-diff-images.script
cli_driver.py

index 6be80a9790ef8aeaffc7354b54370b7bd7830272..4f49822a768006d33fdec56bd6448c1e681870ce 100644 (file)
@@ -28,6 +28,8 @@ line):
                 interpreted locally. If this fails for any reason
                 other than "file does not exist" the test will fail.
 
+Note: Blank lines and lines beginning with '#' are ignored.
+
 Commands can be prefixed with "EXPECT_FAILURE:" to indicate that a
 command is expected to return a non-zero value. In this case, a return
 value of zero from the command will cause the test to fail.
index 9c97fa3f6f58eb1d72408cd80f94bd2411928628..a325479e7ff1ec30576cbf965bdec05ad3643b28 100644 (file)
@@ -1,4 +1,18 @@
+# The first two steps are just as in cli-diff-images. Dump images from
+# a trace into an empty directory.
+
 rm_and_mkdir ./tri-out
 apitrace dump-images -o ./tri-out/tri tri.trace
+
+# Compare the dumped image with a doctored image to provoke a failure.
+# The EXPECT_FAILURE attribute causes the test driver to look for a
+# non-zero return value from apitrace and fail the test if it is not
+# seen.
+
 EXPECT_FAILURE: apitrace diff-images -v ./tri-ref-mismatch ./tri-out
+
+# In addition to getting the return value indicating an error, let's
+# also require that "apitrace diff-images" gave us the output we
+# expect.
+
 expect "Comparing ./tri-ref-mismatch/tri0000000027.png and ./tri-out/tri0000000027.png ... MISMATCH\n"
index cb4630f3b6e489ee255b1be1675570b2075ba40c..e575f1a6149a6a806336e08f02330c4c842472ca 100644 (file)
@@ -1,4 +1,18 @@
+# Make a directory for the output images
+
 rm_and_mkdir ./tri-out
+
+# Generate images for every frame (only 1) of a trace
+
 apitrace dump-images -o ./tri-out/tri tri.trace
+
+# Compare the result of "apitrace dump-images" with our reference
+
 apitrace diff-images -v ./tri-ref ./tri-out
+
+# Ensure that the "apitrace diff-images" actually did something.  This
+# is important since if it couldn't find images in one directory or
+# the other then it would just silently return 0 and this test would
+# incorrectly pass.
+
 expect "Comparing ./tri-ref/tri0000000027.png and ./tri-out/tri0000000027.png ... MATCH\n"
index a7f4b3d5212a67821e636715140c8bc5e5d0c5f9..53bd100a50dc362809e64f30b7ae0efffdac4b1d 100644 (file)
@@ -83,12 +83,14 @@ class CliDriver(Driver):
 
             line = script.readline()
 
+            # Exit loop on EOF
             if (line == ''):
                 break
 
             cmd = line.split()
 
-            if (len(cmd) == 0):
+            # Ignore blank lines and comments
+            if (len(cmd) == 0 or line[0] == '#'):
                 continue
 
             if (cmd[0] == 'EXPECT_FAILURE:'):