Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust tests for new compiler #53

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions ci-rust
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/bin/sh

set -eu
. ./config

mkdir -p "$TEST_OUT_DIR/rust"

cd spec/rust
mkdir src
touch src/lib.rs
cargo build
cargo test-junit \
--name "../../$TEST_OUT_DIR/rust/results.xml"
rm -rf "spec/rust/src"
mkdir -p "spec/rust/src/"
for rs in $(ls "$FORMATS_COMPILED_DIR/rust/"); do
cp "$FORMATS_COMPILED_DIR/rust/$rs" "spec/rust/src"
mod_name="$(echo "$rs" | cut -d'.' -f1)"
echo "pub mod $mod_name;" >> "spec/rust/src/lib.rs"
done

cd "spec/rust"
cargo junit --name "../../$TEST_OUT_DIR/rust/results.xml"
118 changes: 11 additions & 107 deletions spec/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions spec/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "rust"
name = "kaitai_test"
version = "0.1.0"
authors = ["Connor Wood <[email protected]>"]
build = "build.rs"
authors = ["Connor Wood <[email protected]>", "Bradlee Speice<[email protected]>"]
edition = "2018"

[dependencies]
kaitai_struct = { git = "https://github.com/CWood1/kaitai_struct_rust_runtime" }
kaitai = { git = "https://github.com/bspeice/kaitai_rust" }
52 changes: 0 additions & 52 deletions spec/rust/build.rs

This file was deleted.

14 changes: 0 additions & 14 deletions spec/rust/test_expr_sizeof_type_0.rs

This file was deleted.

15 changes: 0 additions & 15 deletions spec/rust/test_expr_sizeof_type_1.rs

This file was deleted.

18 changes: 0 additions & 18 deletions spec/rust/test_expr_sizeof_value_0.rs

This file was deleted.

18 changes: 0 additions & 18 deletions spec/rust/test_expr_sizeof_value_sized.rs

This file was deleted.

15 changes: 0 additions & 15 deletions spec/rust/test_io_local_var.rs

This file was deleted.

13 changes: 0 additions & 13 deletions spec/rust/test_meta_tags.rs

This file was deleted.

13 changes: 0 additions & 13 deletions spec/rust/test_meta_xref.rs

This file was deleted.

14 changes: 0 additions & 14 deletions spec/rust/test_repeat_eos_bit.rs

This file was deleted.

26 changes: 13 additions & 13 deletions spec/rust/tests/test_bcd_user_type_be.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Autogenerated from KST: please remove this line if doing any edits by hand!

extern crate kaitai_struct;
extern crate rust;

use kaitai_struct::KaitaiStruct;
use rust::BcdUserTypeBe;
use kaitai::{BytesReader, KStruct, KStructUnit};
use kaitai_test::bcd_user_type_be::*;
use std::fs;

#[test]
fn test_bcd_user_type_be() {
if let Ok(r) = BcdUserTypeBe::from_file("src/bcd_user_type_be.bin") {
assert_eq!(r.ltr.as_int, 12345678);
assert_eq!(r.ltr.as_str, "12345678");
assert_eq!(r.rtl.as_int, 87654321);
assert_eq!(r.rtl.as_str, "87654321");
assert_eq!(r.leading_zero_ltr.as_int, 123456);
assert_eq!(r.leading_zero_ltr.as_str, "00123456");
}
let data = fs::read("../../src/bcd_user_type_be.bin").expect("Unable to read data.");
let reader = BytesReader::new(&data[..]);
let mut r = BcdUserTypeBe::default();
r.read(&reader, None, KStructUnit::parent_stack()).expect("Unable to parse data.");
// assert_eq!(Attribute(Attribute(Name(identifier(q1w2e3)),identifier(ltr)),identifier(as_int)), IntNum(12345678))
// assert_eq!(Attribute(Attribute(Name(identifier(q1w2e3)),identifier(ltr)),identifier(as_str)), Str(12345678))
// assert_eq!(Attribute(Attribute(Name(identifier(q1w2e3)),identifier(rtl)),identifier(as_int)), IntNum(87654321))
// assert_eq!(Attribute(Attribute(Name(identifier(q1w2e3)),identifier(rtl)),identifier(as_str)), Str(87654321))
// assert_eq!(Attribute(Attribute(Name(identifier(q1w2e3)),identifier(leading_zero_ltr)),identifier(as_int)), IntNum(123456))
// assert_eq!(Attribute(Attribute(Name(identifier(q1w2e3)),identifier(leading_zero_ltr)),identifier(as_str)), Str(00123456))
}
Loading