-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stringtable: allow bin with just warnings (#854)
- Loading branch information
1 parent
9f04af8
commit f2c2356
Showing
35 changed files
with
20,824 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#![allow(clippy::unwrap_used)] | ||
|
||
use std::io::BufReader; | ||
|
||
use hemtt_stringtable::{rapify::rapify, Project}; | ||
|
||
#[test] | ||
fn bin_pass() { | ||
let stringtable = Project::from_reader(BufReader::new( | ||
std::fs::File::open("tests/bin/pass.xml").unwrap(), | ||
)) | ||
.unwrap(); | ||
// Has 2 languages with unique translations | ||
let bin = rapify(&stringtable); | ||
assert!(bin.is_some()); | ||
insta::assert_debug_snapshot!(bin.unwrap()); | ||
} | ||
|
||
#[test] | ||
fn bin_containers() { | ||
let stringtable = Project::from_reader(BufReader::new( | ||
std::fs::File::open("tests/bin/containers.xml").unwrap(), | ||
)) | ||
.unwrap(); | ||
// Has 2 languages with unique translations | ||
let bin = rapify(&stringtable); | ||
assert!(bin.is_some()); | ||
insta::assert_debug_snapshot!(bin.unwrap()); | ||
} | ||
|
||
#[test] | ||
fn bin_invalid() { | ||
let stringtable = Project::from_reader(BufReader::new( | ||
std::fs::File::open("tests/bin/invalid.xml").unwrap(), | ||
)) | ||
.unwrap(); | ||
// Cannot be binnerized | ||
let bin = rapify(&stringtable); | ||
assert!(bin.is_none()); | ||
} | ||
|
||
#[test] | ||
fn bin_unescaped() { | ||
let stringtable = Project::from_reader(BufReader::new( | ||
std::fs::File::open("tests/bin/unescaped.xml").unwrap(), | ||
)) | ||
.unwrap(); | ||
// Cannot be binnerized | ||
let bin = rapify(&stringtable); | ||
assert!(bin.is_none()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project name="HEMTT"> | ||
<Package name="Test"> | ||
<Key ID="A1"> | ||
<Original>Origin</Original> | ||
</Key> | ||
<Key ID="A2"> | ||
<German>DE</German> | ||
<English>EN</English> | ||
</Key> | ||
<Container name="A3"> | ||
<Key ID="A4"> | ||
<Original>Origin</Original> | ||
</Key> | ||
<Key ID="A5"> | ||
<German>DE</German> | ||
<English>EN</English> | ||
</Key> | ||
</Container> | ||
</Package> | ||
</Project> |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project name="HEMTT"> | ||
<Package name="Test"> | ||
<Key ID="A1"> | ||
<Original>A & B</Original> | ||
</Key> | ||
<Key ID="A2"> | ||
<German>DE</German> | ||
<English>EN</English> | ||
</Key> | ||
</Package> | ||
</Project> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#![allow(clippy::unwrap_used)] | ||
|
||
use std::io::BufReader; | ||
|
||
use hemtt_stringtable::{ | ||
analyze::{lint_all, lint_one}, | ||
Project, | ||
}; | ||
use hemtt_workspace::{ | ||
reporting::{Codes, WorkspaceFiles}, | ||
LayerType, | ||
}; | ||
|
||
const ROOT: &str = "tests/lints/"; | ||
|
||
macro_rules! lint { | ||
($dir:ident) => { | ||
paste::paste! { | ||
#[test] | ||
fn [<simple_ $dir>]() { | ||
insta::assert_snapshot!(lint(stringify!($dir))); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
lint!(l01_sorted); | ||
|
||
fn lint(file: &str) -> String { | ||
let folder = std::path::PathBuf::from(ROOT); | ||
let workspace = hemtt_workspace::Workspace::builder() | ||
.physical(&folder, LayerType::Source) | ||
.finish(None, false, &hemtt_common::config::PDriveOption::Disallow) | ||
.unwrap(); | ||
let source = workspace.join(format!("{file}.xml")).unwrap(); | ||
let workspace_files = WorkspaceFiles::new(); | ||
|
||
let existing = source.read_to_string().expect("vfs issue"); | ||
let stringtable = Project::from_reader(BufReader::new(existing.as_bytes())).unwrap(); | ||
|
||
let mut codes: Codes = Vec::new(); | ||
codes.extend(lint_one( | ||
&(stringtable.clone(), workspace.clone(), existing.clone()), | ||
None, | ||
)); | ||
codes.extend(lint_all(&vec![(stringtable, workspace, existing)], None)); | ||
|
||
codes | ||
.iter() | ||
.map(|e| e.diagnostic().unwrap().to_string(&workspace_files)) | ||
.collect::<Vec<_>>() | ||
.join("\n") | ||
.replace('\r', "") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Project name="test"> | ||
<Package name="test"> | ||
<Key ID="A1"> | ||
<Original>Origin</Original> | ||
</Key> | ||
<Container name="B"> | ||
<Key ID="B1"> | ||
<Original>Origin</Original> | ||
</Key> | ||
<Key ID="A2"> | ||
<German>DE</German> | ||
<English>EN</English> | ||
</Key> | ||
</Container> | ||
<Container name="A"> | ||
<Key ID="A3"> | ||
<Original>Origin</Original> | ||
</Key> | ||
</Container> | ||
</Package> | ||
</Project> |
Oops, something went wrong.