Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 6 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,15 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-version }}
- name: Run unit tests
if: ${{ !startsWith(matrix.os, 'windows') }}
run: cargo x test --no-capture
shell: bash
- name: Run unit tests (Windows)
- name: Adjust snapshots on Windows
if: ${{ startsWith(matrix.os, 'windows') }}
run: |
perl -i -pe 's/\//\\/g if /at exn/' exn/tests/snapshots/*.snap
perl -i -pe 's/(?<!\/)\/(?!\/)/\\/g if /examples\/src/' examples/src/*.rs
shell: bash
- name: Run unit tests
run: cargo x test --no-capture
shell: bash
env:
RUSTFLAGS: --cfg windows_test

required:
name: Required
Expand Down
62 changes: 9 additions & 53 deletions exn/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ impl fmt::Debug for Frame {

fn write_exn(f: &mut Formatter<'_>, frame: &Frame, level: usize, prefix: &str) -> fmt::Result {
write!(f, "{}", frame.error())?;
write_location(f, frame)?;

let location = frame.location();
write!(
f,
", at {}:{}:{}",
location.file(),
location.line(),
location.column()
)?;

let children = frame.children();
let children_len = children.len();
Expand All @@ -54,55 +62,3 @@ fn write_exn(f: &mut Formatter<'_>, frame: &Frame, level: usize, prefix: &str) -

Ok(())
}

#[cfg(not(windows_test))]
fn write_location(f: &mut Formatter<'_>, exn: &Frame) -> fmt::Result {
let location = exn.location();
write!(
f,
", at {}:{}:{}",
location.file(),
location.line(),
location.column()
)
}

#[cfg(windows_test)]
fn write_location(f: &mut Formatter<'_>, exn: &Frame) -> fmt::Result {
let location = exn.location();
use std::os::windows::ffi::OsStrExt;
use std::path::Component;
use std::path::MAIN_SEPARATOR;
use std::path::Path;

let file = location.file();
let path = Path::new(file);

let mut resolved = String::new();

for c in path.components() {
match c {
Component::RootDir => {}
Component::CurDir => resolved.push('.'),
Component::ParentDir => resolved.push_str(".."),
Component::Prefix(prefix) => {
resolved.push_str(&prefix.as_os_str().to_string_lossy());
continue;
}
Component::Normal(s) => resolved.push_str(&s.to_string_lossy()),
}
resolved.push('/');
}

if path.as_os_str().encode_wide().last() != Some(MAIN_SEPARATOR as u16)
&& resolved != "/"
&& resolved.ends_with('/')
{
resolved.pop(); // Pop last '/'
}

let line = location.line();
let column = location.column();

write!(f, ", at {resolved}:{line}:{column}")
}
3 changes: 1 addition & 2 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ struct CommandTest {
impl CommandTest {
fn run(self) {
run_command(make_test_cmd(self.no_capture, true, &[]));
#[cfg(not(windows_test))]
run_example_tests();
}
}
Expand All @@ -88,7 +87,6 @@ impl CommandLint {
}
}

#[cfg(not(windows_test))]
fn run_example_tests() {
let examples_dir = PathBuf::from(env!("CARGO_WORKSPACE_DIR"))
.join("examples")
Expand Down Expand Up @@ -117,6 +115,7 @@ fn run_example_tests() {
let stderr = String::from_utf8_lossy(&output.stderr);

let content = fs::read_to_string(&path).unwrap();
let content = content.lines().collect::<Vec<_>>().join("\n");

let actual = stderr
.lines()
Expand Down