forked from WebAssembly/wasi-testsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: added prettierrc and fixed prettier command
- Loading branch information
1 parent
9b97bfb
commit 70fc310
Showing
14 changed files
with
88 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"tabWidth": 4, | ||
"printWidth": 120 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,73 @@ | ||
import * as process from "process"; | ||
import { cpus } from "os"; | ||
import { | ||
doesFileHaveExtension, | ||
execAsPromise, | ||
getFileModifiedTimestamp, | ||
getPathsInDirectory, | ||
mapFileExtension, | ||
doesFileHaveExtension, | ||
execAsPromise, | ||
getFileModifiedTimestamp, | ||
getPathsInDirectory, | ||
mapFileExtension, | ||
} from "./utility"; | ||
import Bottleneck from "bottleneck"; | ||
|
||
async function compileWithAsc(inputFilePath: string, outputFilePath: string) { | ||
console.log(`Compiling ${inputFilePath}`); | ||
return execAsPromise( | ||
`npm run asc --silent -- "${inputFilePath}" -o "${outputFilePath}"` | ||
); | ||
console.log(`Compiling ${inputFilePath}`); | ||
return execAsPromise(`npm run asc --silent -- "${inputFilePath}" -o "${outputFilePath}"`); | ||
} | ||
|
||
function isBinaryOutdated(srcPath: string, wasmPath: string): boolean { | ||
const sourceTs = getFileModifiedTimestamp(srcPath); | ||
if (!sourceTs) { | ||
throw new Error(`Source file ${srcPath} doesn't exist`); | ||
} | ||
const wasmTs = getFileModifiedTimestamp(wasmPath); | ||
const sourceTs = getFileModifiedTimestamp(srcPath); | ||
if (!sourceTs) { | ||
throw new Error(`Source file ${srcPath} doesn't exist`); | ||
} | ||
const wasmTs = getFileModifiedTimestamp(wasmPath); | ||
|
||
return !wasmTs || sourceTs > wasmTs; | ||
return !wasmTs || sourceTs > wasmTs; | ||
} | ||
|
||
async function compileTests() { | ||
const testSuiteFiles = getPathsInDirectory("testsuite"); | ||
const pendingCompilations = testSuiteFiles | ||
.filter((filePath) => doesFileHaveExtension(filePath, "ts")) | ||
.map((filePath) => ({ | ||
src: filePath, | ||
wasm: mapFileExtension(filePath, "ts", "wasm"), | ||
})) | ||
.filter((files) => isBinaryOutdated(files.src, files.wasm)) | ||
.map((files) => | ||
compileWithAsc(files.src, files.wasm) | ||
.then((_) => undefined) | ||
.catch((error) => ({ source: files.src, error })) | ||
); | ||
const testSuiteFiles = getPathsInDirectory("testsuite"); | ||
const pendingCompilations = testSuiteFiles | ||
.filter((filePath) => doesFileHaveExtension(filePath, "ts")) | ||
.map((filePath) => ({ | ||
src: filePath, | ||
wasm: mapFileExtension(filePath, "ts", "wasm"), | ||
})) | ||
.filter((files) => isBinaryOutdated(files.src, files.wasm)) | ||
.map((files) => | ||
compileWithAsc(files.src, files.wasm) | ||
.then((_) => undefined) | ||
.catch((error) => ({ source: files.src, error })) | ||
); | ||
|
||
const errors = (await Promise.allSettled(pendingCompilations)) | ||
.map((p) => { | ||
if (p.status === "fulfilled" && p.value !== undefined) { | ||
return `Failed to compile ${p.value.source}:\n${p.value.error}`; | ||
} else if (p.status === "rejected") { | ||
return `Execution failed:\n${p.reason}`; | ||
} else { | ||
return undefined; | ||
} | ||
}) | ||
.filter((p) => p !== undefined) as string[]; | ||
const errors = (await Promise.allSettled(pendingCompilations)) | ||
.map((p) => { | ||
if (p.status === "fulfilled" && p.value !== undefined) { | ||
return `Failed to compile ${p.value.source}:\n${p.value.error}`; | ||
} else if (p.status === "rejected") { | ||
return `Execution failed:\n${p.reason}`; | ||
} else { | ||
return undefined; | ||
} | ||
}) | ||
.filter((p) => p !== undefined) as string[]; | ||
|
||
if (errors.length > 0) { | ||
throw new Error(errors.join("\n\n")); | ||
} | ||
if (errors.length > 0) { | ||
throw new Error(errors.join("\n\n")); | ||
} | ||
} | ||
|
||
const limiter = new Bottleneck({ | ||
maxConcurrent: process.env.npm_config_concurrency | ||
? parseInt(process.env.npm_config_concurrency) | ||
: cpus().length, | ||
minTime: process.env.npm_config_mintime | ||
? parseInt(process.env.npm_config_mintime) | ||
: 500, | ||
maxConcurrent: process.env.npm_config_concurrency ? parseInt(process.env.npm_config_concurrency) : cpus().length, | ||
minTime: process.env.npm_config_mintime ? parseInt(process.env.npm_config_mintime) : 500, | ||
}); | ||
|
||
const wrapped = limiter.wrap(compileTests); | ||
wrapped() | ||
.then(() => { | ||
console.log("Tests compiled"); | ||
}) | ||
.catch((e) => { | ||
console.error(`Tests failed to compile:`); | ||
console.error(e); | ||
process.exit(1); | ||
}); | ||
.then(() => { | ||
console.log("Tests compiled"); | ||
}) | ||
.catch((e) => { | ||
console.error(`Tests failed to compile:`); | ||
console.error(e); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
tests/assemblyscript/testsuite/args_sizes_get-multiple-arguments.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
tests/assemblyscript/testsuite/environ_sizes_get-multiple-variables.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
tests/assemblyscript/testsuite/environ_sizes_get-no-variables.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters