Skip to content

Commit

Permalink
Merge pull request #40 from pc2/39-make-test-output-env-invariant
Browse files Browse the repository at this point in the history
Make test output env invariant
  • Loading branch information
VonTum authored Dec 9, 2024
2 parents 3fe5e73 + deb4b82 commit a806ce1
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 93 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
run: cargo build --verbose --all-features
- name: Run tests
run: cargo test --verbose --all-features
- name: Run regression test
run: ./target/debug/sus_compiler test.sus --ci --nocolor 1> test.sus_output_ci.txt 2> test.sus_errors_ci.txt || true && diff test.sus_output_ci.txt test.sus_output.txt && diff test.sus_errors_ci.txt test.sus_errors.txt

# check-fmt:
# runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion src/compiler_top.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ impl Linker {
assert!(self.modules.is_empty());
assert!(self.types.is_empty());
assert!(self.constants.is_empty());
println!("Standard Library Directory: {STD_LIB_PATH}");
if !config().ci {
println!("Standard Library Directory: {STD_LIB_PATH}");
}
let stl_path = PathBuf::from_str(STD_LIB_PATH).expect("Standard library directory is not a valid path?");
self.add_all_files_in_directory(&stl_path, info_mngr);

Expand Down
7 changes: 7 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub struct ConfigStruct {
pub codegen_module_and_dependencies_one_file: Option<String>,
pub early_exit: EarlyExitUpTo,
pub use_color: bool,
pub ci: bool,
pub target_language: TargetLanguage,
pub files: Vec<PathBuf>,
}
Expand Down Expand Up @@ -100,6 +101,10 @@ fn command_builder() -> Command {
.long("nocolor")
.help("Disables color printing in the errors of the sus_compiler output")
.action(clap::ArgAction::SetTrue))
.arg(Arg::new("ci")
.long("ci")
.help("Makes the compiler output as environment agnostic as possible")
.action(clap::ArgAction::SetTrue))
.arg(Arg::new("target")
.long("target")
.help("Sets the target HDL")
Expand Down Expand Up @@ -141,6 +146,7 @@ where
let use_color = !matches.get_flag("nocolor") && !use_lsp;
let early_exit = *matches.get_one("upto").unwrap();
let codegen_module_and_dependencies_one_file = matches.get_one("standalone").cloned();
let ci = matches.get_flag("ci");
let target_language = *matches.get_one("target").unwrap();
let file_paths: Vec<PathBuf> = match matches.get_many("files") {
Some(files) => files.cloned().collect(),
Expand All @@ -163,6 +169,7 @@ where
codegen_module_and_dependencies_one_file,
early_exit,
use_color,
ci,
target_language,
files: file_paths,
})
Expand Down
8 changes: 7 additions & 1 deletion src/dev_aid/ariadne_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ impl Cache<FileUUID> for (&Linker, &mut ArenaVector<Source<String>, FileUUIDMark
Ok(&self.1[*id])
}
fn display<'a>(&self, id: &'a FileUUID) -> Option<Box<dyn std::fmt::Display + 'a>> {
Some(Box::new(self.0.files[*id].file_identifier.clone()))
if config().ci {
let filename = self.0.files[*id].file_identifier.rsplit("/").next().unwrap_or(self.0.files[*id].file_identifier.as_str());
Some(Box::new(filename.to_string()))
} else {
Some(Box::new(self.0.files[*id].file_identifier.clone()))
}

}
}

Expand Down
142 changes: 71 additions & 71 deletions test.sus_errors.txt
Original file line number Diff line number Diff line change
@@ -1,130 +1,130 @@
Warning: Unused Variable: This variable does not affect the output ports of this module
╭─[core.sus:3:43]
3 │ __builtin__ module LatencyOffset #(T, int OFFSET) {
│ ───┬──
│ ╰──── Unused Variable: This variable does not affect the output ports of this module
───╯
Warning: Unused Variable: This variable does not affect the output ports of this module
╭─[core.sus:4:33]
4 │ interface LatencyOffset : T in'0 -> T out'OFFSET
│ ─┬
│ ╰── Unused Variable: This variable does not affect the output ports of this module
───╯
Warning: Unused Variable: This variable does not affect the output ports of this module
╭─[core.sus:9:29]
9 │ interface in_domain : T in'0
│ ─┬
│ ╰── Unused Variable: This variable does not affect the output ports of this module
───╯
Warning: Unused Variable: This variable does not affect the output ports of this module
╭─[core.sus:15:31]
15 │ interface IntToBits : int value'0 -> bool[32] bits'0
│ ──┬──
│ ╰──── Unused Variable: This variable does not affect the output ports of this module
────╯
Warning: Unused Variable: This variable does not affect the output ports of this module
╭─[core.sus:19:36]
19 │ interface IntToBits : bool[32] bits'0 -> int value'0
│ ──┬─
│ ╰─── Unused Variable: This variable does not affect the output ports of this module
────╯
Warning: Unused port 'ready'
╭─[util.sus:87:2]
49 │ output bool ready'0
│ ──┬──
│ ╰──── Port 'ready' declared here
87 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f
│ ──────────────────────┬────────────────────── ┬
│ ╰────────────────────────── Unused port 'ready'
│ │
│ ╰── f declared here
────╯
Warning: Unused port 'push'
╭─[/home/lennart/.sus/0.2.0-devel/stl/util.sus:86:2]
╭─[util.sus:87:2]
48 │ interface push : bool push'READY_SLACK, T data_in'READY_SLACK
50 │ interface push : bool push'READY_SLACK, T data_in'READY_SLACK
│ ──┬─
│ ╰─── Port 'push' declared here
86 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f
87 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f
│ ──────────────────────┬────────────────────── ┬
│ ╰────────────────────────── Unused port 'push'
│ │
│ ╰── f declared here
────╯
Warning: Unused port 'data_in'
╭─[/home/lennart/.sus/0.2.0-devel/stl/util.sus:86:2]
╭─[util.sus:87:2]
48 │ interface push : bool push'READY_SLACK, T data_in'READY_SLACK
50 │ interface push : bool push'READY_SLACK, T data_in'READY_SLACK
│ ───┬───
│ ╰───── Port 'data_in' declared here
86 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f
87 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f
│ ──────────────────────┬────────────────────── ┬
│ ╰────────────────────────── Unused port 'data_in'
│ │
│ ╰── f declared here
────╯
Warning: Unused port 'ready'
╭─[/home/lennart/.sus/0.2.0-devel/stl/util.sus:86:2]
50 │ output bool ready'0
│ ──┬──
│ ╰──── Port 'ready' declared here
86 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f
│ ──────────────────────┬────────────────────── ┬
│ ╰────────────────────────── Unused port 'ready'
│ │
│ ╰── f declared here
────╯
Warning: Unused port 'pop'
╭─[/home/lennart/.sus/0.2.0-devel/stl/util.sus:86:2]
╭─[util.sus:87:2]
53 │ interface pop : bool pop -> bool data_valid, T data_out
│ ─┬─
│ ╰─── Port 'pop' declared here
86 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f
87 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f
│ ──────────────────────┬────────────────────── ┬
│ ╰────────────────────────── Unused port 'pop'
│ │
│ ╰── f declared here
────╯
Warning: Unused port 'data_valid'
╭─[/home/lennart/.sus/0.2.0-devel/stl/util.sus:86:2]
╭─[util.sus:87:2]
53 │ interface pop : bool pop -> bool data_valid, T data_out
│ ─────┬────
│ ╰────── Port 'data_valid' declared here
86 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f
87 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f
│ ──────────────────────┬────────────────────── ┬
│ ╰────────────────────────── Unused port 'data_valid'
│ │
│ ╰── f declared here
────╯
Warning: Unused port 'data_out'
╭─[/home/lennart/.sus/0.2.0-devel/stl/util.sus:86:2]
╭─[util.sus:87:2]
53 │ interface pop : bool pop -> bool data_valid, T data_out
│ ────┬───
│ ╰───── Port 'data_out' declared here
86 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f
87 │ FIFO #(DEPTH: 3, READY_SLACK: 5, T: type int) f
│ ──────────────────────┬────────────────────── ┬
│ ╰────────────────────────── Unused port 'data_out'
│ │
│ ╰── f declared here
────╯
Warning: Unused Variable: This variable does not affect the output ports of this module
╭─[/home/lennart/.sus/0.2.0-devel/stl/util.sus:190:10]
╭─[util.sus:191:10]
190 │ int[20] arr
191 │ int[20] arr
│ ─┬─
│ ╰─── Unused Variable: This variable does not affect the output ports of this module
─────╯
Warning: Unused Variable: This variable does not affect the output ports of this module
╭─[/home/lennart/.sus/0.2.0-devel/stl/util.sus:192:9]
╭─[util.sus:193:9]
192 │ int[5] subArr = Slice #(SIZE: 20, OUT_SIZE: 5, FROM: 3, T: type int)(arr)
193 │ int[5] subArr = Slice #(SIZE: 20, OUT_SIZE: 5, FROM: 3, T: type int)(arr)
│ ───┬──
│ ╰──── Unused Variable: This variable does not affect the output ports of this module
─────╯
Warning: Unused Variable: This variable does not affect the output ports of this module
╭─[/home/lennart/.sus/0.2.0-devel/stl/core.sus:3:43]
3 │ __builtin__ module LatencyOffset #(T, int OFFSET) {
│ ───┬──
│ ╰──── Unused Variable: This variable does not affect the output ports of this module
───╯
Warning: Unused Variable: This variable does not affect the output ports of this module
╭─[/home/lennart/.sus/0.2.0-devel/stl/core.sus:4:33]
4 │ interface LatencyOffset : T in'0 -> T out'OFFSET
│ ─┬
│ ╰── Unused Variable: This variable does not affect the output ports of this module
───╯
Warning: Unused Variable: This variable does not affect the output ports of this module
╭─[/home/lennart/.sus/0.2.0-devel/stl/core.sus:9:29]
9 │ interface in_domain : T in'0
│ ─┬
│ ╰── Unused Variable: This variable does not affect the output ports of this module
───╯
Warning: Unused Variable: This variable does not affect the output ports of this module
╭─[/home/lennart/.sus/0.2.0-devel/stl/core.sus:15:31]
15 │ interface IntToBits : int value'0 -> bool[32] bits'0
│ ──┬──
│ ╰──── Unused Variable: This variable does not affect the output ports of this module
────╯
Warning: Unused Variable: This variable does not affect the output ports of this module
╭─[/home/lennart/.sus/0.2.0-devel/stl/core.sus:19:36]
19 │ interface IntToBits : bool[32] bits'0 -> int value'0
│ ──┬─
│ ╰─── Unused Variable: This variable does not affect the output ports of this module
────╯
Error: 'contains_submodule_submodule' conflicts with other declarations:
╭─[test.sus:441:8]
Expand Down Expand Up @@ -658,7 +658,7 @@ Error: MIN is not a valid template argument of ::int
│ ─┬─
│ ╰─── MIN is not a valid template argument of ::int
├─[/home/lennart/.sus/0.2.0-devel/stl/core.sus:28:20]
├─[core.sus:28:20]
28 │ __builtin__ struct int {}
│ ─┬─
Expand All @@ -671,7 +671,7 @@ Error: MAX is not a valid template argument of ::int
│ ─┬─
│ ╰─── MAX is not a valid template argument of ::int
├─[/home/lennart/.sus/0.2.0-devel/stl/core.sus:28:20]
├─[core.sus:28:20]
28 │ __builtin__ struct int {}
│ ─┬─
Expand Down Expand Up @@ -858,7 +858,7 @@ Error: beep is not a valid template argument of ::int
│ ──┬─
│ ╰─── beep is not a valid template argument of ::int
├─[/home/lennart/.sus/0.2.0-devel/stl/core.sus:28:20]
├─[core.sus:28:20]
28 │ __builtin__ struct int {}
│ ─┬─
Expand All @@ -871,7 +871,7 @@ Error: BEEP is not a valid template argument of ::int
│ ──┬─
│ ╰─── BEEP is not a valid template argument of ::int
├─[/home/lennart/.sus/0.2.0-devel/stl/core.sus:28:20]
├─[core.sus:28:20]
28 │ __builtin__ struct int {}
│ ─┬─
Expand All @@ -884,7 +884,7 @@ Error: ::int is not a named wire: local or constant, it is a Struct instead!
│ ─┬─
│ ╰─── ::int is not a named wire: local or constant, it is a Struct instead!
├─[/home/lennart/.sus/0.2.0-devel/stl/core.sus:28:20]
├─[core.sus:28:20]
28 │ __builtin__ struct int {}
│ ─┬─
Expand All @@ -904,7 +904,7 @@ Error: BITWIDTH is not a valid template argument of ::FIFO
│ ────┬───
│ ╰───── BITWIDTH is not a valid template argument of ::FIFO
├─[/home/lennart/.sus/0.2.0-devel/stl/util.sus:35:8]
├─[util.sus:35:8]
35 │ module FIFO #(
│ ──┬─
Expand Down Expand Up @@ -1252,7 +1252,7 @@ Error: ABC is not a valid template argument of ::int
│ ─┬─
│ ╰─── ABC is not a valid template argument of ::int
├─[/home/lennart/.sus/0.2.0-devel/stl/core.sus:28:20]
├─[core.sus:28:20]
28 │ __builtin__ struct int {}
│ ─┬─
Expand Down
Loading

0 comments on commit a806ce1

Please sign in to comment.