namespace Harness { export type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "test262" | "user" | "dt" | "docker" ; export type CompilerTestKind = "conformance" | "compiler" ; export type FourslashTestKind = "fourslash" | "fourslash-shims" | "fourslash-shims-pp" | "fourslash-server" ; export let shards = 1 ; export let shardId = 1 ; export function setShards ( count ) { shards = count ; } export function setShardId ( id ) { shardId = id ; } export abstract class RunnerBase { public tests : ( string | FileBasedTest ) [ ] = [ ] ; /** Add a source file to the runner's list of tests that need to be initialized with initializeTests */ public addTest ( fileName ) { this . tests . push ( fileName ) ; } public enumerateFiles ( folder , regex ? , options ? ) { return ts . map ( IO . listFiles ( userSpecifiedRoot + folder , regex , { recursive : ( options ? options . recursive : false ) } ) , ts . normalizeSlashes ) ; } abstract kind ( ) ; abstract enumerateTestFiles ( ) ; getTestFiles ( ) { const all = this . enumerateTestFiles ( ) ; if ( shards === 1 ) { return all as ReturnType < this [ "enumerateTestFiles" ] > ; } return all . filter ( ( _val , idx ) => idx % shards === ( shardId - 1 ) ) as ReturnType < this [ "enumerateTestFiles" ] > ; } /** The working directory where tests are found. Needed for batch testing where the input path will differ from the output path inside baselines */ public workingDirectory = "" ; /** Setup the runner's tests so that they are ready to be executed by the harness
         *  The first test should be a describe/it block that sets up the harness's compiler instance appropriately
         */ public abstract initializeTests ( ) ; /** Replaces instances of full paths with fileNames only */ static removeFullPaths ( path ) { let fixedPath = /^(\w:|\/)/ . test ( path ) ? ts . getBaseFileName ( path ) : path ; const localHost = /http:\/localhost:\d+/g ; fixedPath = fixedPath . replace ( localHost , "" ) ; return fixedPath ; } } }