function maybeGenerateHtmlForFile(filename, args) {
  if (!filename.endsWith('_test.js')) {
    return;
  }

  const htmlFilename =
      args.output || filename.replace('_test.js', '_test.html');
  if (!args.overwriteExistingFiles && fs.existsSync(htmlFilename)) {
    console.warn(`"${htmlFilename}" exists - skipping.`);
    return;
  }

  const originalJs = fs.readFileSync(filename, 'utf8');
  const provide = /goog\.(?:provide|module)\('([^']*?)'\);/g.exec(originalJs);

  if (!provide || !provide[1]) {
    console.error(
        `File ${filename} does not provide or module the tests, ` +
        'cannot generate html.');
    return;
  }

  const newJS = `goog.require('${provide[1]}');`;
  const title = `Closure Unit Tests - ${provide[1]}`;

  const baseFileName = filename.replace('_test.js', '');
  const testDomFilename = baseFileName + '_test_dom.html';
  const testDom = fs.existsSync(testDomFilename) ?
      fs.readFileSync(testDomFilename, 'utf8') :
      '';

  const testBootstrapFilename = baseFileName + '_test_bootstrap.js';
  const pathToBootstrap = fs.existsSync(testBootstrapFilename) ?
      path.basename(testBootstrapFilename) :
      '';

  const pathToBase = path.relative(path.dirname(htmlFilename), args.basePath);
  const pathToDeps = args.depsFile ?
      path.relative(path.dirname(htmlFilename), args.depsFile) :
      '';

  const html = createHtml(
      title, pathToBootstrap, pathToDeps, newJS, testDom, pathToBase);
  fs.writeFileSync(htmlFilename, html);
}
Generates a _test.html file for the given file if it is a _test.js file.
@param {string} filename Full path to the file.
@param {!Args} args