Skip to content

[dev] fix broken "the favicon changes" testcase #5581

Open

Description

@softhack007

WLED/tools/cdata-test.js

Lines 185 to 187 in 979c724

it('the favicon changes', async () => {
await testFileModification(path.join(dataPath, 'favicon.ico'), 'html_other.h');
});

WLED/tools/cdata-test.js

Lines 129 to 131 in 979c724

// modify file
fs.appendFileSync(sourceFilePath, ' ');
// delay for 1 second to ensure the modified time is different

Its not clear to me if there is really a problem - like npm run build not detecting a change in wled00/data/favicon.ico - or adding ascii junk to a binary file is not enough anymore to count as a "file change".

https://github.com/wled/WLED/actions/runs/25567284703/job/75053837206#logs

      # Subtest: the favicon changes
        not ok 8 - the favicon changes
          ---
          duration_ms: 4542.527046
          location: '/home/runner/work/WLED/WLED/tools/cdata-test.js:185:5'
          failureType: 'testCodeFailure'
          error: 'wled00/html_other.h was not modified'
          code: 'ERR_ASSERTION'
          name: 'AssertionError'
          expected: true
          actual: false
          operator: '=='
          stack: |-
            checkIfFileWasNewlyCreated (/home/runner/work/WLED/WLED/tools/cdata-test.js:122:5)
            testFileModification (/home/runner/work/WLED/WLED/tools/cdata-test.js:137:11)
            process.processTicksAndRejections (node:internal/process/task_queues:95:5)
            async TestContext.<anonymous> (/home/runner/work/WLED/WLED/tools/cdata-test.js:186:7)
            async Test.run (node:internal/test_runner/test:797:9)
            async Suite.processPendingSubtests (node:internal/test_runner/test:526:7)
          ...

Activity

  1. added this to the 16.1 milestone on May 8, 2026
  2. added theissue type on May 8, 2026
  3. softhack007 commented on May 8, 2026

    @softhack007
    MemberAuthor

    I'll disable the broken CI testcase until we have a solution.

  4. modified the milestones: 16.1, 16.2 on Nov 22, 2026
  5. DedeHai commented on Dec 2, 2026

    @DedeHai
    Collaborator

    my AI just mentioned this. I do not know if it is right but it might be. This is what it sais:
    "In cdata-test.js, testFileModification() previously checked whether the output header was rebuilt by asserting Date.now() - modifiedTime < 850 after the entire node tools/cdata.js command finished.

    Because cdata.js writes small files like wled00/json_ledtypes.h (and html_other.h) early in the build, and then spends ~5 seconds minifying html_ui.h and html_settings.h, json_ledtypes.h is already ~5 seconds old by the time cdata.js exits — causing Date.now() - modifiedTime < 850 to fail even though the file was rebuilt. (This is also why the commented-out favicon.ico → html_other.h test in #5581 was failing.)

    Comparing mtimeMs before vs. after the second cdata.js run (fs.statSync(targetPath).mtimeMs > beforeMtime) directly checks whether the file was actually rewritten, without depending on build order or CPU speed."

    and this is what the suggested fix ought to be:

    diff --git a/tools/cdata-test.js b/tools/cdata-test.js
    --- a/tools/cdata-test.js
    +++ b/tools/cdata-test.js
    @@ -82,6 +82,7 @@ describe('Script', () => {
         process.env.NODE_ENV = 'production';
         // Backup files
         fs.cpSync("wled00/data", "wled00Backup", { recursive: true });
    +    fs.cpSync("wled00/ledtypes.json", "ledtypes.bak.json");
         fs.cpSync("tools/cdata.js", "cdata.bak.js");
         fs.cpSync("package.json", "package.bak.json");
       });
    @@ -89,31 +90,37 @@ describe('Script', () => {
         // Restore backup
         fs.rmSync("wled00/data", { recursive: true });
         fs.renameSync("wled00Backup", "wled00/data");
    +    fs.rmSync("wled00/ledtypes.json");
    +    fs.renameSync("ledtypes.bak.json", "wled00/ledtypes.json");
         fs.rmSync("tools/cdata.js");
         fs.renameSync("cdata.bak.js", "tools/cdata.js");
         fs.rmSync("package.json");
         fs.renameSync("package.bak.json", "package.json");
       });
     
    -  // delete all html_*.h files
    +  // delete all generated html_*.h and json_*.h files
       async function deleteBuiltFiles() {
         const files = await fs.promises.readdir(folderPath);
         await Promise.all(files.map(file => {
    -      if (file.startsWith('html_') && path.extname(file) === '.h') {
    +      if ((file.startsWith('html_') || file.startsWith('json_')) && path.extname(file) === '.h') {
             return fs.promises.unlink(path.join(folderPath, file));
           }
         }));
       }
     
    -  // check if html_*.h files were created
    +  // check if html_*.h and json_*.h files were created
       async function checkIfBuiltFilesExist() {
         const files = await fs.promises.readdir(folderPath);
         const htmlFiles = files.filter(file => file.startsWith('html_') && path.extname(file) === '.h');
    +    const jsonFiles = files.filter(file => file.startsWith('json_') && path.extname(file) === '.h');
         assert(htmlFiles.length > 0, 'html_*.h files were not created');
    +    assert(jsonFiles.length > 0, 'json_*.h files were not created');
       }
     
       async function runAndCheckIfBuiltFilesExist() {
    @@ -123,8 +130,10 @@ describe('Script', () => {
       }
     
       async function testFileModification(sourceFilePath, resultFile) {
    -    // run cdata.js to ensure html_*.h files are created
    +    // run cdata.js to ensure generated header files are created
         await execPromise('node tools/cdata.js');
    +    const targetPath = path.join(folderPath, resultFile);
    +    const beforeMtime = fs.statSync(targetPath).mtimeMs;
     
         // modify file
         fs.appendFileSync(sourceFilePath, ' ');
    @@ -134,7 +143,7 @@ describe('Script', () => {
         // run script cdata.js again and wait for it to finish
         await execPromise('node tools/cdata.js');
     
    -    await checkIfFileWasNewlyCreated(path.join(folderPath, resultFile));
    +    assert(fs.statSync(targetPath).mtimeMs > beforeMtime, targetPath + ' was not modified');
       }
     
       describe('should build if', () => {
    @@ -188,6 +197,10 @@ describe('Script', () => {
         //   await testFileModification(path.join(dataPath, 'favicon.ico'), 'html_other.h');
         // });
     
    +    it('ledtypes.json changes', async () => {
    +      await testFileModification(path.join(folderPath, 'ledtypes.json'), 'json_ledtypes.h');
    +    });
    +
         it('cdata.js changes', async () => {
           await testFileModification('tools/cdata.js', 'html_ui.h');
         });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions