function copyWorkspace(workspacePath) {
  const to = tmp.dirSync({keep: DEBUG, unsafeCleanup: !DEBUG}).name;
  if (RUNFILES_MANIFEST) {
    const start = workspacePath.startsWith('../') ?
        workspacePath.slice(3) :
        `${process.env['TEST_WORKSPACE']}/${workspacePath}/`;
    let copied = 0;
    for (const key of Object.keys(RUNFILES_MANIFEST)) {
      if (key.startsWith(start)) {
        const element = key.slice(start.length);
        const dest = path.posix.join(to, element);
        mkdirp(path.dirname(dest));
        log_verbose(`copying (MANIFEST) ${RUNFILES_MANIFEST[key]} -> ${dest}`);
        fs.copyFileSync(RUNFILES_MANIFEST[key], dest);
        ++copied;
      }
    }
    if (!copied) {
      throw new Error(`no workspace files found under path ${workspacePath}`)
    }
  } else {
    if (!fs.existsSync(workspacePath)) {
      throw new Error(`workspace under test not found at ${workspacePath}`);
    }
    copyFolderSync(workspacePath, to);
  }
  return to;
}
/**
 * Helper function to copy the workspace under test to tmp
 */
Helper function to copy the workspace under test to tmp
Helper function to copy the workspace under test to tmp
function copyWorkspace(workspacePath) {
  const to = tmp.dirSync({keep: DEBUG, unsafeCleanup: !DEBUG}).name;
  if (RUNFILES_MANIFEST) {
    const start = workspacePath.startsWith('../') ?
        workspacePath.slice(3) :
        `${process.env['TEST_WORKSPACE']}/${workspacePath}/`;
    let copied = 0;
    for (const key of Object.keys(RUNFILES_MANIFEST)) {
      if (key.startsWith(start)) {
        const element = key.slice(start.length);
        const dest = path.posix.join(to, element);
        mkdirp(path.dirname(dest));
        log_verbose(`copying (MANIFEST) ${RUNFILES_MANIFEST[key]} -> ${dest}`);
        fs.copyFileSync(RUNFILES_MANIFEST[key], dest);
        ++copied;
      }
    }
    if (!copied) {
      throw new Error(`no workspace files found under path ${workspacePath}`)
    }
  } else {
    if (!fs.existsSync(workspacePath)) {
      throw new Error(`workspace under test not found at ${workspacePath}`);
    }
    copyFolderSync(workspacePath, to);
  }
  return to;
}
function copyWorkspace ( workspacePath ) { const to = tmp . dirSync ( { keep : DEBUG , unsafeCleanup : ! DEBUG } ) . name ; if ( RUNFILES_MANIFEST ) { const start = workspacePath . startsWith ( '../' ) ? workspacePath . slice ( 3 ) : ` ${ process . env [ 'TEST_WORKSPACE' ] } ${ workspacePath } ` ; let copied = 0 ; for ( const key of Object . keys ( RUNFILES_MANIFEST ) ) { if ( key . startsWith ( start ) ) { const element = key . slice ( start . length ) ; const dest = path . posix . join ( to , element ) ; mkdirp ( path . dirname ( dest ) ) ; log_verbose ( ` ${ RUNFILES_MANIFEST [ key ] } ${ dest } ` ) ; fs . copyFileSync ( RUNFILES_MANIFEST [ key ] , dest ) ; ++ copied ; } } if ( ! copied ) { throw new Error ( ` ${ workspacePath } ` ) } } else { if ( ! fs . existsSync ( workspacePath ) ) { throw new Error ( ` ${ workspacePath } ` ) ; } copyFolderSync ( workspacePath , to ) ; } return to ; }
Helper function to copy the workspace under test to tmp
Helper function to copy the workspace under test to tmp