Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build process non-deterministically produces invalid HTML files #910

Closed
jugglinmike opened this issue Mar 22, 2023 · 2 comments · Fixed by #912
Closed

Build process non-deterministically produces invalid HTML files #910

jugglinmike opened this issue Mar 22, 2023 · 2 comments · Fixed by #912

Comments

@jugglinmike
Copy link
Contributor

On my system (GNU/Linux, Ubuntu 18.04, Node.js 16.17.0), the npm build command occasionally outputs invalid HTML files.

$ git show --oneline --no-patch
b5fe3efd (HEAD -> master, upstream/master) Create tests for APG design pattern example: Horizontal Multi-Thumb Slider (#511)
$ git status
On branch master
Your branch is ahead of 'bocoup/master' by 174 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Steps to reproduce:

  1. Build the HTML files five times, saving the output each time:

    $ for x in $(seq 5); do npm run build && mv build build-$x; done
    
  2. Search the five build directories for files with multiple closing HTML tags:

    $ grep -Ro '</html' build-* | uniq -c | sort -n | grep -E '^\s*[2-9]'
    

Expected behavior: the search returns zero results

Actual behavior: the search returns one or more results

For my trial, the search returned:

2 build-2/tests/command-button/reference/2022-4-8_124112/button.html:</html
2 build-3/tests/tabs-manual-activation/reference/2021-2-15_124757/tabs.html:</html
2 build-5/tests/form/reference/2021-10-24_152221/form.html:</html
2 build-5/tests/modal-dialog/reference/2022-4-7_15544/dialog.html:</html

The symptom is more severe than duplicated closing tags; that just happens to be a straightforward way to detect the problem.

Here's a comparison highlighting the invalidity in one of those files
$ git diff -w --no-index build-1/tests/command-button/reference/2022-4-8_124112/button.html build-2/tests/command-button/reference/2022-4-8_124112/button.html
diff --git a/build-1/tests/command-button/reference/2022-4-8_124112/button.html b/build-2/tests/command-button/reference/2022-4-8_124112/button.html
index d17cbeb1..8d7a8451 100644
--- a/build-1/tests/command-button/reference/2022-4-8_124112/button.html
+++ b/build-2/tests/command-button/reference/2022-4-8_124112/button.html
@@ -7,23 +7,7 @@
   <!-- CSS and JS for this example. -->
   <link rel="stylesheet" href="css/button.css">
   <script src="js/button.js"></script>
-
-<!-- Generated by create-example-tests.js -->
-<script>
-  (function() {
-    function setupScript(testPageDocument) {
-      //
-
-    };
-    document.addEventListener('click', function(event) {
-      if (event.target.classList.contains('button-run-test-setup')) {
-        event.target.disabled = true;
-        setupScript(document);
-      }
-    });
-  })();
-</script>
-<!-- End of generated output --></head>
+</head>^M
 <body>
   <main>
     <h1>Command Button Example</h1>
@@ -48,6 +32,18 @@
         <a id="afterlink" href="#afterlink">Navigate backwards from here</a>
       </div>
 
+      <div role="separator" id="ex_end_sep" aria-labelledby="ex_end_sep ex_label" aria-label="End of"></div>^M
+    </section>^M
+  </main>^M
+</body>^M
+</html>^M
+s from here</a>
+        <div>
+          <div tabindex="0" role="button" id="action">Print Page</div>
+        </div>
+        <a id="afterlink" href="#afterlink">Navigate backwards from here</a>
+      </div>
+
       <div role="separator" id="ex_end_sep" aria-labelledby="ex_end_sep ex_label" aria-label="End of"></div>
     </section>

I've scraped all of the test HTML which is currently published on the production deployment of ARIA-AT App, and the good news is that it appears to be valid.

That may mean that the most recent build was lucky (notice how in my trial, the first and fourth build didn't include any duplicated closing HTML tags), or it may mean that this problem is specific to my machine. I'm wondering if anyone else can reproduce the behavior reported here.

@mzgoddard
Copy link
Contributor

I can confirm this bug on my system.

shell output
$ grep -Ro '</html' build-* | uniq -c | sort -n | grep -E '^\s*[2-9]'
   2 build-1/tests/checkbox-tri-state/reference/2022-9-9_104148/checkbox-mixed.html:</html
   2 build-1/tests/combobox-select-only/reference/combobox-select-only.html:</html
   2 build-1/tests/datepicker-spin-button/reference/2021-10-15_93728/datepicker-spinbuttons.html:</html
   2 build-1/tests/menubar-editor/reference/2020-11-23_175528/menubar-editor.html:</html
   2 build-1/tests/minimal-data-grid/reference/2021-3-8_151542/dataGrids.html:</html
   2 build-1/tests/modal-dialog/reference/2022-4-7_15544/dialog.html:</html
   2 build-2/tests/checkbox/reference/2020-11-23_175030/checkbox-1/checkbox-1.html:</html
   2 build-2/tests/combobox-select-only/reference/combobox-select-only.html:</html
   2 build-2/tests/horizontal-slider/reference/2022-4-11_11511/slider-color-viewer.html:</html
   2 build-2/tests/menu-button-actions-active-descendant/reference/2021-1-14_171136/menu-button-actions-active-descendant.html:</html
   2 build-2/tests/modal-dialog/reference/2022-4-7_15544/dialog.html:</html
   2 build-3/tests/checkbox-tri-state/reference/2022-9-9_104148/checkbox-mixed.html:</html
   2 build-3/tests/checkbox/reference/2020-11-23_175030/checkbox-1/checkbox-1.html:</html
   2 build-3/tests/command-button/reference/2022-4-8_124112/button.html:</html
   2 build-3/tests/link-span-text/reference/2022-4-6_14258/link.html:</html
   2 build-3/tests/radiogroup-aria-activedescendant/reference/2022-4-7_113015/radio-activedescendant.html:</html
   2 build-3/tests/radiogroup-roving-tabindex/reference/2021-3-15_144141/radio.html:</html
   2 build-4/tests/checkbox/reference/2020-11-23_175030/checkbox-1/checkbox-1.html:</html
   2 build-4/tests/radiogroup-roving-tabindex/reference/2021-3-15_144141/radio.html:</html
   2 build-4/tests/tabs-manual-activation/reference/2021-2-15_124757/tabs.html:</html
   2 build-5/tests/checkbox/reference/2020-11-23_175030/checkbox-1/checkbox-1.html:</html
   2 build-5/tests/link-span-text/reference/2022-4-6_14258/link.html:</html
   2 build-5/tests/menu-button-actions/reference/2021-1-14_12348/menu-button-actions.html:</html
   2 build-5/tests/menu-button-navigation/reference/2022-4-12_14147/menu-button-links.html:</html
   2 build-5/tests/minimal-data-grid/reference/2021-3-8_151542/dataGrids.html:</html
   2 build-5/tests/radiogroup-roving-tabindex/reference/2021-3-15_144141/radio.html:</html
   2 build-5/tests/seek-slider/reference/2021-9-21_14461/slider-seek.html:</html
   2 build-5/tests/tabs-manual-activation/reference/2021-2-15_124757/tabs.html:</html

@mzgoddard
Copy link
Contributor

Oh, I know what this is.

Two different file content are being written to the same file path. This is happening to each reference html file that has no setup script.

To fix this we need to not add the original reference html file to the build because we create one for the same file path with generated code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants