Skip to content

Commit

Permalink
chore: fix logging & test
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Feb 19, 2024
1 parent f990b86 commit 0b97617
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ export class AppContainer {
_.isEmpty(messageData) ? undefined : messageData
)
} catch (err) {
this.logger.error(err)
this.logger.error(stringifyError(err))
// Fallback:
defaultLog(`${appId} stdout: ${message}`)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ export class EvaluationRunner {
.withConcurrency(this.tracker.constants.PARALLEL_CONCURRENCY)
.handleError(async (error, trackedExp) => {
// Log the error
this.logger.error(error.name + error.message)
this.logger.error(stringifyError(error))
if (trackedExp.session) {
// Mark the expectation so that it won't be evaluated again this round:
trackedExp.session.hadError = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,14 +436,14 @@ export abstract class GenericFileAccessorHandle<Metadata> extends GenericAccesso
{
retryCount: LOCK_ATTEMPTS_COUNT,
retryTimeout: RETRY_TIMEOUT,
logError: (error) => this.worker.logger.error(error),
logError: (error) => this.worker.logger.error(stringifyError(error)),
logWarning: (message) => this.worker.logger.warn(message),
}
)
} catch (e) {
// Not much we can do about it..
// Log and continue:
this.worker.logger.error(e)
this.worker.logger.error(stringifyError(e))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export const FileCopy: ExpectationWindowsHandler = {
const lookupTarget = await lookupCopyTargets(worker, exp)
if (!lookupTarget.ready) throw new Error(`Can't start working due to target: ${lookupTarget.reason.tech}`)

worker.logger
const workInProgress = await doFileCopyExpectation(exp, lookupSource, lookupTarget)
if (workInProgress === null) {
throw new Error(
Expand Down
15 changes: 15 additions & 0 deletions tests/internal-tests/src/__mocks__/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import wndMock0 from 'windows-network-drive' // Note: this is a mocked module
import { EventEmitter } from 'events' // Note: this is a mocked module
import { Readable, Writable } from 'stream'
import { promisify } from 'util'
// import * as Path from 'path'

import type { WNDMockType } from './windows-network-drive'
Expand Down Expand Up @@ -617,4 +618,18 @@ interface FileAccess {
accessWrite: boolean
}

fs.promises = {
stat: promisify(stat),
access: promisify(access),
unlink: promisify(unlink),
mkdir: promisify(mkdir),
readdir: promisify(readdir),
lstat: promisify(lstat),
writeFile: promisify(writeFile),
readFile: promisify(readFile),
open: promisify(open),
copyFile: promisify(copyFile),
rename: promisify(rename),
}

module.exports = fs

0 comments on commit 0b97617

Please sign in to comment.