Skip to content

Commit fa62777

Browse files
authored
Introduce GitHub workflow (#7)
* Introduce GitHub workflow * Accommodate CRLF when testing file translation
1 parent 4e83034 commit fa62777

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

.github/workflows/rust.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches: [ master, develop ]
6+
pull_request:
7+
branches: [ master, develop ]
8+
9+
jobs:
10+
build:
11+
12+
strategy:
13+
matrix:
14+
os: [ macos-latest, windows-latest, ubuntu-latest ]
15+
16+
runs-on: ${{ matrix.os }}
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Build
21+
run: cargo build --verbose
22+
- name: Run tests
23+
run: cargo test --verbose

tyrga-bin/src/main.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ fn test_translate_file() -> TerminatingResult {
4343
let mut expected = Vec::new();
4444
File::open(gold)?.read_to_end(&mut expected)?;
4545

46-
assert_eq!(
47-
&std::str::from_utf8(&translated),
48-
&std::str::from_utf8(&expected)
49-
);
46+
let translated = std::str::from_utf8(&translated)?;
47+
let expected = std::str::from_utf8(&expected)?;
48+
49+
#[cfg(target_os = "windows")]
50+
fn fix_newlines(t: &str) -> String { t.replace("\r\n", "\n") }
51+
52+
#[cfg(not(target_os = "windows"))]
53+
fn fix_newlines(t: &str) -> String { t.to_owned() }
54+
55+
assert_eq!(fix_newlines(translated), fix_newlines(expected));
5056
}
5157
}
5258

0 commit comments

Comments
 (0)