Skip to content

Commit

Permalink
fix: extend rule hash (#593)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspar030 authored Dec 23, 2024
2 parents 8639590 + f2dd30d commit 248ad59
Show file tree
Hide file tree
Showing 33 changed files with 53 additions and 34 deletions.
12 changes: 11 additions & 1 deletion src/ninja/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use indexmap::IndexMap;
use crate::model::VarExportSpec;
use crate::nested_env::{self, IfMissing};

#[derive(Debug, PartialEq, Eq, Clone, Default)]
#[derive(Debug, PartialEq, Eq, Clone, Default, Hash)]
pub enum NinjaRuleDeps {
#[default]
None,
Expand Down Expand Up @@ -132,6 +132,16 @@ impl Hash for NinjaRule<'_> {
self.name.hash(state);
self.command.hash(state);
self.description.hash(state);

// only these are optionally hashed as to not break hashes.
// TODO: once we break them, make all options optional
if let NinjaRuleDeps::GCC(_) = self.deps {
self.deps.hash(state);
}
if self.pool.is_some() {
self.pool.hash(state);
}

self.rspfile.hash(state);
self.rspfile_content.hash(state);
match &self.deps {
Expand Down
2 changes: 1 addition & 1 deletion src/tests/01_basic/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/02_vars/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/03_var_override/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/04_var_lists/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/05_select_use_depend/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/06_module_defaults/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build_expected build
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/07_early_env/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/08_multiple_documents/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/09_defaults/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/10_notify/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/11_optional_sources/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/12_selects_uses_removal/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/13_disable/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/14_ifthendeps/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/15_blocklist_allowlist/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ echo skipping 15
# build
# clean_temp_files

# diff -r build build_expected
# diff_build_dir

# echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/18_always/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ echo "building second time"
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/19_context_select/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/20_custom_build_object_cache/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/21_multiple_contexts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/22_ifthendeps_order/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/23_multiple_users_custom_build/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/25_import_git_commit_from_local_path/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ clean_temp_files
rm -Rf testrepo
rm -Rf build/imports

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/28_provides/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
8 changes: 4 additions & 4 deletions src/tests/29_ninja_args/build_expected/build-global.ninja
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
builddir = build
build ALWAYS: phony
rule CC_7950216292150676175
rule CC_13815167931066592534
command = cat ${in} > ${out}
description = CC
pool = console

build build/objects/single_app.8352856137977294963.o: $
CC_7950216292150676175 $
build build/objects/single_app.17922776573255433378.o: $
CC_13815167931066592534 $
single_app.c

rule LINK_7531752039969474517
Expand All @@ -17,5 +17,5 @@ rule LINK_7531752039969474517

build build/single_builder/single_app/single_app.elf: $
LINK_7531752039969474517 $
build/objects/single_app.8352856137977294963.o
build/objects/single_app.17922776573255433378.o

2 changes: 1 addition & 1 deletion src/tests/29_ninja_args/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build -j4 -v -c
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/30_cli_env/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build -DVAR1=var1 -DVAR2+=foo -DVAR2+=bar -DVAR3=var3
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/31_expr/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/40_import_root_cwd/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ clean_temp_files
rm -Rf testrepo
rm -Rf build/imports

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/41_insights/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cleanup
build -i build/insights.json -G
clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
2 changes: 1 addition & 1 deletion src/tests/45_import_from_local_path/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ${LAZE} build -g

clean_temp_files

diff -r build build_expected
diff_build_dir

echo TEST_OK

Expand Down
9 changes: 9 additions & 0 deletions src/tests/test-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ cleanup() {
rm -rf build
}

diff_build_dir() {
if [ "$UPDATE_BUILD_EXPECTED" = 1 ]; then
rm -Rf build_expected
mv build build_expected
else
diff -r build build_expected
fi
}

build() {
if [ -f EXPECTED_EXIT_CODE ]; then
# ignore actual exit code
Expand Down

0 comments on commit 248ad59

Please sign in to comment.