Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ jobs:
# cache hits and cache evictions (github has a 10GB cache limit).
save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/next' }}
- name: build benches
run: cargo bench --no-run
run: cargo build --benches
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
- name: Install rust
run: rustup update --no-self-update
- name: Build tests
run: make test-build
run: make test-release-build
- name: test
run: make test
run: make test-release # runs without debug mode

doc-tests:
name: doc-tests
Expand Down
21 changes: 17 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,29 @@ serve-docs: ## Serves the docs

# --- testing -------------------------------------------------------------------------------------

.PHONY: test-build
test-build: ## Build the test binary
$(BUILD_GENERATED_FILES_IN_SRC) cargo nextest run --cargo-profile test-dev --features concurrent,testing,std --no-run
.PHONY: test-release-build
test-release-build: ## Build the test binary
$(BUILD_GENERATED_FILES_IN_SRC) cargo nextest run --cargo-profile test-dev --no-default-features --features concurrent,testing,std --no-run


# Run all tests without debug mode. This is fast but produces worse error message.
# Running `make test-release name=test_name` will only run the test `test_name`.
.PHONY: test-release
test-release:
$(BUILD_GENERATED_FILES_IN_SRC) $(BACKTRACE) cargo nextest run --profile default --cargo-profile test-dev --no-default-features --features concurrent,testing,std $(name)

# Shorthand for make test-release.
.PHONY: test-release testr
testr: test-release

# Run all tests with debug mode. This is slower but produces better error message.
# Running `make test name=test_name` will only run the test `test_name`.
.PHONY: test
test: ## Run all tests. Running `make test name=test_name` will only run the test `test_name`.
test:
$(BUILD_GENERATED_FILES_IN_SRC) $(BACKTRACE) cargo nextest run --profile default --cargo-profile test-dev --features concurrent,testing,std $(name)


# Run all tests except the proving tests (imperfectly filtered based on name) with debug mode.
# This uses the std feature to be able to load the MASM source files back into the assembler
# source manager (see `source_manager_ext::load_masm_source_files`).
.PHONY: test-dev
Expand Down
22 changes: 19 additions & 3 deletions crates/miden-agglayer/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,9 @@ pub proc load_zeros_to_memory\n",

zero_constants.push_str("\tdrop\nend\n");

// write the resulting masm content into the file
fs::write(target_dir.join("canonical_zeros.masm"), zero_constants).into_diagnostic()?;
// write the resulting masm content into the file only if it changed to avoid
// invalidating the cargo fingerprint for the `asm/` directory
shared::write_if_changed(target_dir.join("canonical_zeros.masm"), zero_constants)?;

Ok(())
}
Expand Down Expand Up @@ -546,11 +547,26 @@ mod shared {
.into_diagnostic()?;
}

std::fs::write(module.file_name, output).into_diagnostic()?;
write_if_changed(module.file_name, output)?;

Ok(())
}

/// Writes `contents` to `path` only if the file doesn't exist or its current contents
/// differ. This avoids updating the file's mtime when nothing changed, which prevents
/// cargo from treating the crate as dirty on the next build.
pub fn write_if_changed(path: impl AsRef<Path>, contents: impl AsRef<[u8]>) -> Result<()> {
let path = path.as_ref();
let new_contents = contents.as_ref();
if path.exists() {
let existing = std::fs::read(path).into_diagnostic()?;
if existing == new_contents {
return Ok(());
}
}
std::fs::write(path, new_contents).into_diagnostic()
}

pub type ErrorName = String;

#[derive(Debug, Clone)]
Expand Down
20 changes: 17 additions & 3 deletions crates/miden-protocol/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ fn generate_kernel_proc_hash_file(kernel: KernelLibrary) -> Result<()> {
txt
}).collect::<Vec<_>>().join("\n");

fs::write(
shared::write_if_changed(
KERNEL_PROCEDURES_RS_FILE,
format!(
r#"// This file is generated by build.rs, do not modify
Expand All @@ -247,7 +247,6 @@ pub const KERNEL_PROCEDURES: [Word; {proc_count}] = [
"#,
),
)
.into_diagnostic()
}

fn parse_proc_offsets(filename: impl AsRef<Path>) -> Result<BTreeMap<String, usize>> {
Expand Down Expand Up @@ -784,11 +783,26 @@ mod shared {
.into_diagnostic()?;
}

std::fs::write(module.file_name, output).into_diagnostic()?;
write_if_changed(module.file_name, output)?;

Ok(())
}

/// Writes `contents` to `path` only if the file doesn't exist or its current contents
/// differ. This avoids updating the file's mtime when nothing changed, which prevents
/// cargo from treating the crate as dirty on the next build.
pub fn write_if_changed(path: impl AsRef<Path>, contents: impl AsRef<[u8]>) -> Result<()> {
let path = path.as_ref();
let new_contents = contents.as_ref();
if path.exists() {
let existing = std::fs::read(path).into_diagnostic()?;
if existing == new_contents {
return Ok(());
}
}
std::fs::write(path, new_contents).into_diagnostic()
}

pub type ErrorName = String;

#[derive(Debug, Clone)]
Expand Down
17 changes: 16 additions & 1 deletion crates/miden-standards/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,26 @@ mod shared {
.into_diagnostic()?;
}

std::fs::write(module.file_name, output).into_diagnostic()?;
write_if_changed(module.file_name, output)?;

Ok(())
}

/// Writes `contents` to `path` only if the file doesn't exist or its current contents
/// differ. This avoids updating the file's mtime when nothing changed, which prevents
/// cargo from treating the crate as dirty on the next build.
pub fn write_if_changed(path: impl AsRef<Path>, contents: impl AsRef<[u8]>) -> Result<()> {
let path = path.as_ref();
let new_contents = contents.as_ref();
if path.exists() {
let existing = std::fs::read(path).into_diagnostic()?;
if existing == new_contents {
return Ok(());
}
}
std::fs::write(path, new_contents).into_diagnostic()
}

pub type ErrorName = String;

#[derive(Debug, Clone)]
Expand Down
7 changes: 6 additions & 1 deletion crates/miden-testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ rust-version.workspace = true
version.workspace = true

[features]
std = ["miden-protocol/std", "miden-standards/std", "miden-tx/std"]
default = ["tx_context_debug"]
std = ["miden-protocol/std", "miden-standards/std", "miden-tx/std"]
# Enables debug mode in the transaction context, which in turn enables debug mode in the transaction
# executor. It is enabled by default and should generally be enabled. Can be opted out of to improve
# CI test performance.
tx_context_debug = []

[dependencies]
# Workspace dependencies
Expand Down
2 changes: 1 addition & 1 deletion crates/miden-testing/src/tx_context/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl TransactionContextBuilder {
signatures: Vec::new(),
note_scripts: BTreeMap::new(),
is_lazy_loading_enabled: true,
is_debug_mode_enabled: true,
is_debug_mode_enabled: cfg!(feature = "tx_context_debug"),
}
}

Expand Down