Skip to content

Commit

Permalink
test: log debug messages on console on CICD
Browse files Browse the repository at this point in the history
  • Loading branch information
KoltesDigital committed Oct 4, 2022
1 parent 76b88cb commit 27eb02e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ branches:
- master

environment:
DOKAN_CONSOLE_DEBUG_LOG: 1
RUST_BACKTRACE: 1
AccessTokenDokanDoc:
secure: Z5/daTZ6OJaDbslmhxSxxB6leKaqHTnTbISy153Y4cdJm/oTAbDHaofb9TqvKXV1
Expand Down
22 changes: 16 additions & 6 deletions dokan/src/usage_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,20 @@ impl<'a> TestDriveContext<'a> {
}
}

// Errors might happen on CICD only. To facilitate debugging, output debug messages on console.
pub fn test_flags() -> MountFlags {
let mut flags =
MountFlags::CURRENT_SESSION | MountFlags::FILELOCK_USER_MODE | MountFlags::ALT_STREAM;

let enable_console_debug_log =
std::env::var_os("DOKAN_CONSOLE_DEBUG_LOG").map_or(false, |x| &x != "0");
if enable_console_debug_log {
flags = flags | MountFlags::DEBUG | MountFlags::STDERR;
}

flags
}

#[allow(unused_must_use)]
pub fn with_test_drive<Scope: FnOnce(TestDriveContext)>(scope: Scope) {
let _guard = TEST_DRIVE_LOCK.lock();
Expand All @@ -885,9 +899,7 @@ pub fn with_test_drive<Scope: FnOnce(TestDriveContext)>(scope: Scope) {
let mount_point = convert_str("Z:\\");
let handler = TestHandler::new(tx_signal);
let options = MountOptions {
flags: MountFlags::CURRENT_SESSION
| MountFlags::FILELOCK_USER_MODE
| MountFlags::ALT_STREAM,
flags: test_flags(),
timeout: Duration::from_secs(15),
allocation_unit_size: 1024,
sector_size: 1024,
Expand Down Expand Up @@ -1484,9 +1496,7 @@ fn can_get_operation_info() {
no_cache: false,
write_to_eof: false,
single_thread: false,
mount_flags: MountFlags::CURRENT_SESSION
| MountFlags::FILELOCK_USER_MODE
| MountFlags::ALT_STREAM,
mount_flags: test_flags(),
mount_point: Some(convert_str("Z:\\")),
unc_name: None,
timeout: Duration::from_secs(15),
Expand Down

0 comments on commit 27eb02e

Please sign in to comment.