mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
fix clippy issues in tests and add it to CI
This commit is contained in:
parent
6535fa5744
commit
e1b27c51f5
@ -11,6 +11,7 @@ code-quality:
|
||||
script:
|
||||
- ln -s /dockercache/cache-all target
|
||||
- cargo clippy -- -D warnings
|
||||
- cargo clippy --tests -- -D warnings
|
||||
- cargo fmt --all -- --check
|
||||
|
||||
security:
|
||||
|
@ -384,7 +384,7 @@ mod tests {
|
||||
assert_eq!(sword, loadout.second_item);
|
||||
|
||||
// Verify inventory
|
||||
assert_eq!(inv.slots[0], Some(sword.clone().unwrap().item));
|
||||
assert_eq!(inv.slots[0], Some(sword.unwrap().item));
|
||||
assert_eq!(inv.slots.len(), 1);
|
||||
}
|
||||
|
||||
@ -459,7 +459,7 @@ mod tests {
|
||||
|
||||
// The swap should return the sword
|
||||
assert_eq!(
|
||||
Some(sword.clone().unwrap().item),
|
||||
Some(sword.unwrap().item),
|
||||
loadout_remove(EquipSlot::Mainhand, &mut loadout,)
|
||||
);
|
||||
|
||||
|
@ -138,9 +138,9 @@ mod tests {
|
||||
assert_eq!(mb.data[0], 3);
|
||||
assert_eq!(mb.data[1], 0);
|
||||
assert_eq!(mb.data[7], 0);
|
||||
assert_eq!(mb.data[8], 'a' as u8);
|
||||
assert_eq!(mb.data[8], b'a');
|
||||
assert_eq!(mb.data[8], 97);
|
||||
assert_eq!(mb.data[9], 'b' as u8);
|
||||
assert_eq!(mb.data[10], 'c' as u8);
|
||||
assert_eq!(mb.data[9], b'b');
|
||||
assert_eq!(mb.data[10], b'c');
|
||||
}
|
||||
}
|
||||
|
@ -353,8 +353,8 @@ mod tests {
|
||||
#[test]
|
||||
fn pid_cid_frame_cache() {
|
||||
let pid = Pid::fake(1);
|
||||
let frame1 = Frame::Raw("Foo".as_bytes().to_vec());
|
||||
let frame2 = Frame::Raw("Bar".as_bytes().to_vec());
|
||||
let frame1 = Frame::Raw(b"Foo".to_vec());
|
||||
let frame2 = Frame::Raw(b"Bar".to_vec());
|
||||
let metrics = NetworkMetrics::new(&pid).unwrap();
|
||||
let mut cache = PidCidFrameCache::new(metrics.frames_in_total, pid);
|
||||
let v1 = cache.with_label_values(1, &frame1);
|
||||
@ -377,8 +377,8 @@ mod tests {
|
||||
#[test]
|
||||
fn cid_frame_cache() {
|
||||
let pid = Pid::fake(1);
|
||||
let frame1 = Frame::Raw("Foo".as_bytes().to_vec());
|
||||
let frame2 = Frame::Raw("Bar".as_bytes().to_vec());
|
||||
let frame1 = Frame::Raw(b"Foo".to_vec());
|
||||
let frame2 = Frame::Raw(b"Bar".to_vec());
|
||||
let metrics = NetworkMetrics::new(&pid).unwrap();
|
||||
let mut cache = CidFrameCache::new(metrics.frames_wire_out_total, 1);
|
||||
let v1 = cache.with_label_values(&frame1);
|
||||
|
@ -327,6 +327,7 @@ mod tests {
|
||||
const SIZE: u64 = PrioManager::FRAME_DATA_SIZE;
|
||||
const USIZE: usize = PrioManager::FRAME_DATA_SIZE as usize;
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn mock_new() -> (
|
||||
PrioManager,
|
||||
Sender<(Prio, Sid, OutgoingMessage)>,
|
||||
@ -605,10 +606,10 @@ mod tests {
|
||||
fn gigantic_message() {
|
||||
let (mut mgr, msg_tx, _flush_tx) = mock_new();
|
||||
let mut data = vec![1; USIZE];
|
||||
data.extend_from_slice(&vec![2; USIZE]);
|
||||
data.extend_from_slice(&vec![3; USIZE]);
|
||||
data.extend_from_slice(&vec![4; USIZE]);
|
||||
data.extend_from_slice(&vec![5; USIZE]);
|
||||
data.extend_from_slice(&[2; USIZE]);
|
||||
data.extend_from_slice(&[3; USIZE]);
|
||||
data.extend_from_slice(&[4; USIZE]);
|
||||
data.extend_from_slice(&[5; USIZE]);
|
||||
let sid = Sid::new(2);
|
||||
msg_tx
|
||||
.send((16, sid, OutgoingMessage {
|
||||
@ -634,10 +635,10 @@ mod tests {
|
||||
fn gigantic_message_order() {
|
||||
let (mut mgr, msg_tx, _flush_tx) = mock_new();
|
||||
let mut data = vec![1; USIZE];
|
||||
data.extend_from_slice(&vec![2; USIZE]);
|
||||
data.extend_from_slice(&vec![3; USIZE]);
|
||||
data.extend_from_slice(&vec![4; USIZE]);
|
||||
data.extend_from_slice(&vec![5; USIZE]);
|
||||
data.extend_from_slice(&[2; USIZE]);
|
||||
data.extend_from_slice(&[3; USIZE]);
|
||||
data.extend_from_slice(&[4; USIZE]);
|
||||
data.extend_from_slice(&[5; USIZE]);
|
||||
let sid = Sid::new(2);
|
||||
msg_tx
|
||||
.send((16, sid, OutgoingMessage {
|
||||
@ -666,10 +667,10 @@ mod tests {
|
||||
fn gigantic_message_order_other_prio() {
|
||||
let (mut mgr, msg_tx, _flush_tx) = mock_new();
|
||||
let mut data = vec![1; USIZE];
|
||||
data.extend_from_slice(&vec![2; USIZE]);
|
||||
data.extend_from_slice(&vec![3; USIZE]);
|
||||
data.extend_from_slice(&vec![4; USIZE]);
|
||||
data.extend_from_slice(&vec![5; USIZE]);
|
||||
data.extend_from_slice(&[2; USIZE]);
|
||||
data.extend_from_slice(&[3; USIZE]);
|
||||
data.extend_from_slice(&[4; USIZE]);
|
||||
data.extend_from_slice(&[5; USIZE]);
|
||||
let sid = Sid::new(2);
|
||||
msg_tx
|
||||
.send((16, sid, OutgoingMessage {
|
||||
|
@ -322,7 +322,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn frame_get_int() {
|
||||
assert_eq!(Frame::get_int(&Frame::Raw("Foo".as_bytes().to_vec())), 7);
|
||||
assert_eq!(Frame::get_int(&Frame::Raw(b"Foo".to_vec())), 7);
|
||||
assert_eq!(Frame::get_int(&Frame::Shutdown), 2);
|
||||
}
|
||||
|
||||
|
@ -101,11 +101,11 @@ fn failed_listen_on_used_ports() -> std::result::Result<(), Box<dyn std::error::
|
||||
let e2 = block_on(network2.listen(tcp1));
|
||||
match e1 {
|
||||
Err(NetworkError::ListenFailed(e)) if e.kind() == ErrorKind::AddrInUse => (),
|
||||
_ => assert!(false),
|
||||
_ => panic!(),
|
||||
};
|
||||
match e2 {
|
||||
Err(NetworkError::ListenFailed(e)) if e.kind() == ErrorKind::AddrInUse => (),
|
||||
_ => assert!(false),
|
||||
_ => panic!(),
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
@ -178,7 +178,7 @@ fn wrong_parse() {
|
||||
|
||||
s1_a.send(1337).unwrap();
|
||||
match block_on(s1_b.recv::<String>()) {
|
||||
Err(StreamError::DeserializeError(_)) => assert!(true),
|
||||
_ => assert!(false, "this should fail, but it doesnt!"),
|
||||
Err(StreamError::DeserializeError(_)) => (),
|
||||
_ => panic!("this should fail, but it doesnt!"),
|
||||
}
|
||||
}
|
||||
|
@ -81,15 +81,12 @@ fn generate_key_version<'a>(
|
||||
.map(|k| (k.to_owned(), LocalizationEntryState::new()))
|
||||
.collect();
|
||||
let mut to_process: HashSet<&String> = localization.string_map.keys().map(|k| k).collect();
|
||||
let mut line_nb = 0;
|
||||
|
||||
// Find key start lines
|
||||
for line in std::str::from_utf8(file_blob.content())
|
||||
for (line_nb, line) in std::str::from_utf8(file_blob.content())
|
||||
.expect("UTF-8 file")
|
||||
.split('\n')
|
||||
.enumerate()
|
||||
{
|
||||
line_nb += 1;
|
||||
|
||||
let mut found_key = None;
|
||||
|
||||
for key in to_process.iter() {
|
||||
|
Loading…
Reference in New Issue
Block a user