Skip to content

Commit ac77928

Browse files
committed
Added missing file + added a tool for running the compiler test suite
1 parent a66f0e5 commit ac77928

File tree

5 files changed

+134
-0
lines changed

5 files changed

+134
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ test/out
1717
*.pdb
1818
*.out
1919
*.cilly
20+
*.cilly2
2021
.cargo/
2122
config.toml
2223
rust/

cilly/src/v2/hashable.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
4+
/// f32, which is hashed as its bit representation, and compared bitwise. Usefull for consts in nodes
5+
pub struct HashableF32(pub f32);
6+
7+
impl std::ops::Deref for HashableF32 {
8+
type Target = f32;
9+
10+
fn deref(&self) -> &Self::Target {
11+
&self.0
12+
}
13+
}
14+
impl std::hash::Hash for HashableF32 {
15+
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
16+
self.0.to_bits().hash(state);
17+
}
18+
}
19+
impl PartialEq for HashableF32 {
20+
fn eq(&self, other: &Self) -> bool {
21+
self.0.to_bits() == other.0.to_bits()
22+
}
23+
}
24+
impl Eq for HashableF32 {}
25+
26+
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
27+
/// f64, which is hashed as its bit representation, and compared bitwise. Usefull for consts in nodes
28+
pub struct HashableF64(pub f64);
29+
30+
impl std::ops::Deref for HashableF64 {
31+
type Target = f64;
32+
33+
fn deref(&self) -> &Self::Target {
34+
&self.0
35+
}
36+
}
37+
impl std::hash::Hash for HashableF64 {
38+
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
39+
self.0.to_bits().hash(state);
40+
}
41+
}
42+
impl PartialEq for HashableF64 {
43+
fn eq(&self, other: &Self) -> bool {
44+
self.0.to_bits() == other.0.to_bits()
45+
}
46+
}
47+
impl Eq for HashableF64 {}

cilly/src/v2/il_exporter/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ impl ILExporter {
5959
writeln!(out, ".field {tpe} '{name}'")
6060
}?;
6161
}
62+
crate::utilis::assert_unique(class_def.static_fields(), format!("The class {} contains a duplicate static field",asm.get_string(class_def.name())));
6263
// Export all static fields
6364
for (tpe, name, thread_local) in class_def.static_fields() {
6465
let name = asm.get_string(*name);

src/bin/autotest.rs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
use core::str;
2+
use std::collections::HashSet;
3+
4+
fn main() {
5+
let exec_path = std::env::args().nth(1).unwrap();
6+
let mut ok: HashSet<String> = HashSet::default();
7+
let mut failures: HashSet<String> = HashSet::default();
8+
let mut broken: Vec<String> = Vec::default();
9+
10+
loop {
11+
let mut cmd = std::process::Command::new("timeout");
12+
cmd.arg("-k");
13+
cmd.arg("20");
14+
cmd.arg("20");
15+
cmd.arg("dotnet");
16+
cmd.arg(exec_path.clone());
17+
cmd.arg("--test-threads=1");
18+
cmd.args(broken.iter().flat_map(|arg| ["--skip", arg]));
19+
println!("\n{cmd:?}");
20+
println!(
21+
"\nsearch status: ok:{ok}, failures:{failures} broken:{broken}",
22+
ok = ok.len(),
23+
failures = failures.len(),
24+
broken = broken.len()
25+
);
26+
let out = cmd.output().unwrap();
27+
let stderr = str::from_utf8(&out.stderr).unwrap().to_string();
28+
let stdout = str::from_utf8(&out.stdout).unwrap().to_string();
29+
for line in stdout.lines() {
30+
if !line.contains("test ") {
31+
continue;
32+
}
33+
let mut split = line.split("...");
34+
35+
let name = match split.next() {
36+
Some(some) => some,
37+
None => continue,
38+
};
39+
let name = name["test ".len()..].trim();
40+
let name = name.split("-").next().unwrap().trim();
41+
let status = split.next().unwrap_or("");
42+
if status.contains("ok") {
43+
ok.insert(name.to_owned());
44+
} else if status.contains("FAILED") {
45+
failures.insert(name.to_owned());
46+
} else {
47+
if !broken.iter().any(|exisitng| exisitng == name) {
48+
broken.push(name.to_owned());
49+
}
50+
}
51+
}
52+
if stderr.contains("failures:") | stdout.contains("failures:") {
53+
println!("search done.");
54+
break;
55+
}
56+
}
57+
println!();
58+
println!("BROKEN:");
59+
for broken in &broken {
60+
println!("{broken}");
61+
}
62+
println!("FAILURES:");
63+
for faliure in &failures {
64+
println!("{faliure}");
65+
}
66+
println!("COMMAND:");
67+
let mut cmd = std::process::Command::new("dotnet");
68+
cmd.arg(exec_path.clone());
69+
cmd.args(broken.iter().flat_map(|arg| ["--skip", arg]));
70+
println!("{cmd:?}");
71+
println!(
72+
"\nsearch result: ok:{ok}, failures:{failures} broken:{broken}",
73+
ok = ok.len(),
74+
failures = failures.len(),
75+
broken = broken.len()
76+
);
77+
}

src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,11 @@ const METADATA: &str = "m";
338338
const DATA_PTR: &str = "d";
339339
/// The tag of an enum
340340
const ENUM_TAG: &str = "v";
341+
/*
342+
Compiler test flags, used to skip tests which cause crashes.
343+
344+
For core:
345+
--test-threads 1 --skip atomic --skip refcell_ref_coercion --skip future --skip test_writer_hasher --skip test_iterator_step_by_nth_try_fold --skip test_range_advance_by --skip test_monad_laws_left_identity --skip manually_drop::smoke --skip nonzero_trailing_zeros --skip midpoint --skip test_count_ones --skip test_count_zeros --skip test_leading_trailing_ones --skip test_rotate --skip test_saturating_abs --skip test_saturating_neg --skip test_isqrt --skip test_reverse_bits --skip ptr_metadata --skip test_variadic_fnptr --skip result_try_trait_v2_branch --skip simd --skip select_nth_unstable --skip take_in_bounds_max_range --skip take_mut_in_bounds_max_range --skip take_mut_oob_max_rang --skip take_oob_max_rang
346+
For alloc:
347+
--test-threads 1
348+
*/

0 commit comments

Comments
 (0)