Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: ignore RWLock from Istanbul coverage #32478

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/aws-cdk/lib/api/util/rwlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as path from 'path';
* This class is not 100% race safe, but in practice it should be a lot
* better than the 0 protection we have today.
*/
/* istanbul ignore next: code paths are unpredictable */
export class RWLock {
private readonly pidString: string;
private readonly writerFile: string;
Expand Down Expand Up @@ -158,6 +159,7 @@ export interface IWriterLock extends ILock {
convertToReaderLock(): Promise<ILock>;
}

/* istanbul ignore next: code paths are unpredictable */
async function readFileIfExists(filename: string): Promise<string | undefined> {
try {
return await fs.readFile(filename, { encoding: 'utf-8' });
Expand All @@ -168,13 +170,15 @@ async function readFileIfExists(filename: string): Promise<string | undefined> {
}

let tmpCounter = 0;
/* istanbul ignore next: code paths are unpredictable */
async function writeFileAtomic(filename: string, contents: string): Promise<void> {
await fs.mkdir(path.dirname(filename), { recursive: true });
const tmpFile = `${filename}.${process.pid}_${++tmpCounter}`;
await fs.writeFile(tmpFile, contents, { encoding: 'utf-8' });
await fs.rename(tmpFile, filename);
}

/* istanbul ignore next: code paths are unpredictable */
async function deleteFile(filename: string) {
try {
await fs.unlink(filename);
Expand All @@ -186,6 +190,7 @@ async function deleteFile(filename: string) {
}
}

/* istanbul ignore next: code paths are unpredictable */
function processExists(pid: number) {
try {
process.kill(pid, 0);
Expand Down
Loading