validator/engine/validator-light_test.js
/**
 * Returns all html files underneath the testdata roots. This looks
 * both for feature_tests/*.html and for tests in extension directories.
 * E.g.: extensions/amp-accordion/0.1/test/*.html,
 *       extensions/amp-sidebar/1.0/test/*.html, and
 *       testdata/feature_tests/amp_accordion.html.
 * @return {!Array<string>}
 */
Returns all html files underneath the testdata roots. This looks
both for feature_tests.html and for tests in extension directories.
Returns all html files underneath the testdata roots . This looks both for feature_tests . html and for tests in extension directories .
function findHtmlFilesRelativeToTestdata() {
  const testSubdirs = [];
  for (const root of process.env['TESTDATA_ROOTS'].split(':')) {
    if (path.basename(root) === 'extensions') {
      for (const extension of readdir(root)) {
        const extensionFolder = path.join(root, extension);
        if (!isdir(extensionFolder)) {
          continue;
        }
        for (const possibleVersion of readdir(extensionFolder)) {
          const testPath = path.join(extension, possibleVersion, 'test');
          if (isdir(path.join(root, testPath))) {
            testSubdirs.push({root: root, subdir: testPath});
          }
        }
      }
    } else {
      for (const subdir of readdir(root)) {
        testSubdirs.push({root: root, subdir: subdir});
      }
    }
  }
  const testFiles = [];
  for (const entry of testSubdirs) {
    for (const candidate of readdir(path.join(entry.root, entry.subdir))) {
      if (candidate.match(/^.*.html/g) &&
          !entry.subdir.match(/amp4ads_feature_tests/g)) {
        testFiles.push(path.join(entry.subdir, candidate));
      }
    }
  }
  return testFiles;
}
function findHtmlFilesRelativeToTestdata ( ) { const testSubdirs = [ ] ; for ( const root of process . env [ 'TESTDATA_ROOTS' ] . split ( ':' ) ) { if ( path . basename ( root ) === 'extensions' ) { for ( const extension of readdir ( root ) ) { const extensionFolder = path . join ( root , extension ) ; if ( ! isdir ( extensionFolder ) ) { continue ; } for ( const possibleVersion of readdir ( extensionFolder ) ) { const testPath = path . join ( extension , possibleVersion , 'test' ) ; if ( isdir ( path . join ( root , testPath ) ) ) { testSubdirs . push ( { root : root , subdir : testPath } ) ; } } } } else { for ( const subdir of readdir ( root ) ) { testSubdirs . push ( { root : root , subdir : subdir } ) ; } } } const testFiles = [ ] ; for ( const entry of testSubdirs ) { for ( const candidate of readdir ( path . join ( entry . root , entry . subdir ) ) ) { if ( candidate . match ( / ^.*.html / g ) && ! entry . subdir . match ( / amp4ads_feature_tests / g ) ) { testFiles . push ( path . join ( entry . subdir , candidate ) ) ; } } } return testFiles ; }
Returns all html files underneath the testdata roots.
Returns all html files underneath the testdata roots .
// Skip if not a folder // Get all versions // TODO(gregable): Remove this hack once the js validator knows how // to validate A4A documents.