diff --git a/mutation-testing/packages-output/pox-locking/caught.txt b/mutation-testing/packages-output/pox-locking/caught.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/mutation-testing/packages-output/pox-locking/missed.txt b/mutation-testing/packages-output/pox-locking/missed.txt new file mode 100644 index 0000000000..abe9b69202 --- /dev/null +++ b/mutation-testing/packages-output/pox-locking/missed.txt @@ -0,0 +1,30 @@ +pox-locking/src/pox_1.rs:128: replace handle_contract_call -> Result<(), ClarityError> with Ok(()) +pox-locking/src/pox_2.rs:217: replace pox_lock_extend_v2 -> Result with Ok(1) +pox-locking/src/pox_3.rs:72: replace pox_lock_extend_v3_not_tested -> Result with Ok(0) +pox-locking/src/events.rs:47: replace create_event_info_stack_or_delegate_code -> String with String::new() +pox-locking/src/events.rs:351: replace synthesize_pox_2_or_3_event_info -> Result, ClarityError> with Ok(None) +pox-locking/src/events.rs:76: replace create_event_info_aggregation_code -> String with "xyzzy".into() +pox-locking/src/pox_2.rs:248: replace pox_lock_v2 -> Result<(), LockingError> with Ok(()) +pox-locking/src/pox_2.rs:280: replace handle_stack_lockup_pox_v2 -> Result, ClarityError> with Ok(None) +pox-locking/src/pox_1.rs:90: replace pox_lock_v1 -> Result<(), LockingError> with Ok(()) +pox-locking/src/pox_3.rs:363: replace handle_contract_call -> Result<(), ClarityError> with Ok(()) +pox-locking/src/events.rs:103: replace create_event_info_data_code -> String with String::new() +pox-locking/src/events.rs:103: replace create_event_info_data_code -> String with "xyzzy".into() +pox-locking/src/pox_3.rs:236: replace handle_stack_lockup_extension_pox_v3 -> Result, ClarityError> with Ok(None) +pox-locking/src/pox_2.rs:409: replace handle_stack_lockup_increase_pox_v2 -> Result, ClarityError> with Ok(None) +pox-locking/src/pox_1.rs:69: replace is_read_only -> bool with false +pox-locking/src/pox_3.rs:300: replace handle_stack_lockup_increase_pox_v3 -> Result, ClarityError> with Ok(None) +pox-locking/src/pox_1.rs:69: replace is_read_only -> bool with true +pox-locking/src/pox_2.rs:33: replace is_read_only -> bool with true +pox-locking/src/pox_3.rs:87: replace pox_lock_extend_v3 -> Result with Ok(1) +pox-locking/src/pox_3.rs:169: replace handle_stack_lockup_pox_v3 -> Result, ClarityError> with Ok(None) +pox-locking/src/pox_2.rs:33: replace is_read_only -> bool with false +pox-locking/src/events.rs:76: replace create_event_info_aggregation_code -> String with String::new() +pox-locking/src/lib.rs:65: replace handle_contract_call_special_cases -> Result<(), ClarityError> with Ok(()) +pox-locking/src/pox_2.rs:345: replace handle_stack_lockup_extension_pox_v2 -> Result, ClarityError> with Ok(None) +pox-locking/src/pox_3.rs:42: replace pox_lock_v3 -> Result<(), LockingError> with Ok(()) +pox-locking/src/pox_3.rs:87: replace pox_lock_extend_v3 -> Result with Ok(0) +pox-locking/src/events.rs:47: replace create_event_info_stack_or_delegate_code -> String with "xyzzy".into() +pox-locking/src/pox_2.rs:473: replace handle_contract_call -> Result<(), ClarityError> with Ok(()) +pox-locking/src/pox_2.rs:217: replace pox_lock_extend_v2 -> Result with Ok(0) +pox-locking/src/pox_3.rs:72: replace pox_lock_extend_v3_not_tested -> Result with Ok(1) diff --git a/mutation-testing/packages-output/pox-locking/timeout.txt b/mutation-testing/packages-output/pox-locking/timeout.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/mutation-testing/packages-output/pox-locking/unviable.txt b/mutation-testing/packages-output/pox-locking/unviable.txt new file mode 100644 index 0000000000..f0f8e4328f --- /dev/null +++ b/mutation-testing/packages-output/pox-locking/unviable.txt @@ -0,0 +1,22 @@ +pox-locking/src/events.rs:32: replace get_stacker -> Value with Default::default() +pox-locking/src/events.rs:351: replace synthesize_pox_2_or_3_event_info -> Result, ClarityError> with Ok(Some(Default::default())) +pox-locking/src/pox_3.rs:236: replace handle_stack_lockup_extension_pox_v3 -> Result, ClarityError> with Ok(Some(Default::default())) +pox-locking/src/pox_2.rs:409: replace handle_stack_lockup_increase_pox_v2 -> Result, ClarityError> with Ok(Some(Default::default())) +pox-locking/src/pox_2.rs:127: replace parse_pox_increase -> std::result::Result<(PrincipalData, u128), i128> with Ok((Default::default(), 0)) +pox-locking/src/pox_1.rs:36: replace parse_pox_stacking_result_v1 -> std::result::Result<(PrincipalData, u128, u64), i128> with Ok((Default::default(), 1, 1)) +pox-locking/src/pox_2.rs:127: replace parse_pox_increase -> std::result::Result<(PrincipalData, u128), i128> with Ok((Default::default(), 1)) +pox-locking/src/pox_2.rs:64: replace parse_pox_stacking_result -> std::result::Result<(PrincipalData, u128, u64), i128> with Ok((Default::default(), 0, 0)) +pox-locking/src/pox_3.rs:123: replace pox_lock_increase_v3 -> Result with Ok(Default::default()) +pox-locking/src/pox_3.rs:169: replace handle_stack_lockup_pox_v3 -> Result, ClarityError> with Ok(Some(Default::default())) +pox-locking/src/pox_2.rs:164: replace pox_lock_increase_v2 -> Result with Ok(Default::default()) +pox-locking/src/pox_1.rs:36: replace parse_pox_stacking_result_v1 -> std::result::Result<(PrincipalData, u128, u64), i128> with Ok((Default::default(), 1, 0)) +pox-locking/src/pox_1.rs:36: replace parse_pox_stacking_result_v1 -> std::result::Result<(PrincipalData, u128, u64), i128> with Ok((Default::default(), 0, 1)) +pox-locking/src/pox_3.rs:300: replace handle_stack_lockup_increase_pox_v3 -> Result, ClarityError> with Ok(Some(Default::default())) +pox-locking/src/pox_2.rs:98: replace parse_pox_extend_result -> std::result::Result<(PrincipalData, u64), i128> with Ok((Default::default(), 0)) +pox-locking/src/pox_2.rs:64: replace parse_pox_stacking_result -> std::result::Result<(PrincipalData, u128, u64), i128> with Ok((Default::default(), 0, 1)) +pox-locking/src/pox_2.rs:98: replace parse_pox_extend_result -> std::result::Result<(PrincipalData, u64), i128> with Ok((Default::default(), 1)) +pox-locking/src/pox_2.rs:280: replace handle_stack_lockup_pox_v2 -> Result, ClarityError> with Ok(Some(Default::default())) +pox-locking/src/pox_2.rs:64: replace parse_pox_stacking_result -> std::result::Result<(PrincipalData, u128, u64), i128> with Ok((Default::default(), 1, 0)) +pox-locking/src/pox_1.rs:36: replace parse_pox_stacking_result_v1 -> std::result::Result<(PrincipalData, u128, u64), i128> with Ok((Default::default(), 0, 0)) +pox-locking/src/pox_2.rs:345: replace handle_stack_lockup_extension_pox_v2 -> Result, ClarityError> with Ok(Some(Default::default())) +pox-locking/src/pox_2.rs:64: replace parse_pox_stacking_result -> std::result::Result<(PrincipalData, u128, u64), i128> with Ok((Default::default(), 1, 1)) diff --git a/mutation-testing/packages-output/stx-genesis/missed.txt b/mutation-testing/packages-output/stx-genesis/missed.txt index 40e4c3349b..8dd26c3f38 100644 --- a/mutation-testing/packages-output/stx-genesis/missed.txt +++ b/mutation-testing/packages-output/stx-genesis/missed.txt @@ -1,3 +1,3 @@ stx-genesis/src/lib.rs:108: replace ::count -> usize with 1 -stx-genesis/src/lib.rs:100: replace ::next -> Option with None stx-genesis/src/lib.rs:108: replace ::count -> usize with 0 +stx-genesis/src/lib.rs:100: replace ::next -> Option with None diff --git a/mutation-testing/packages-output/stx-genesis/unviable.txt b/mutation-testing/packages-output/stx-genesis/unviable.txt index 12714bff17..8933e39cf7 100644 --- a/mutation-testing/packages-output/stx-genesis/unviable.txt +++ b/mutation-testing/packages-output/stx-genesis/unviable.txt @@ -1,11 +1,11 @@ -stx-genesis/src/lib.rs:71: replace GenesisData::read_namespaces -> Box> with Box::new(Default::default()) -stx-genesis/src/lib.rs:148: replace read_lockups -> Box> with Box::new(Default::default()) +stx-genesis/src/lib.rs:78: replace GenesisData::read_names -> Box> with Box::new(Default::default()) +stx-genesis/src/lib.rs:140: replace read_balances -> Box> with Box::new(Default::default()) stx-genesis/src/lib.rs:157: replace read_namespaces -> Box> with Box::new(Default::default()) stx-genesis/src/lib.rs:129: replace iter_deflated_csv -> Box>> with Box::new(Default::default()) -stx-genesis/src/lib.rs:140: replace read_balances -> Box> with Box::new(Default::default()) -stx-genesis/src/lib.rs:85: replace GenesisData::read_name_zonefiles -> Box> with Box::new(Default::default()) -stx-genesis/src/lib.rs:78: replace GenesisData::read_names -> Box> with Box::new(Default::default()) -stx-genesis/src/lib.rs:64: replace GenesisData::read_lockups -> Box> with Box::new(Default::default()) -stx-genesis/src/lib.rs:115: replace read_deflated_zonefiles -> Box> with Box::new(Default::default()) stx-genesis/src/lib.rs:57: replace GenesisData::read_balances -> Box> with Box::new(Default::default()) +stx-genesis/src/lib.rs:115: replace read_deflated_zonefiles -> Box> with Box::new(Default::default()) stx-genesis/src/lib.rs:171: replace read_names -> Box> with Box::new(Default::default()) +stx-genesis/src/lib.rs:148: replace read_lockups -> Box> with Box::new(Default::default()) +stx-genesis/src/lib.rs:64: replace GenesisData::read_lockups -> Box> with Box::new(Default::default()) +stx-genesis/src/lib.rs:85: replace GenesisData::read_name_zonefiles -> Box> with Box::new(Default::default()) +stx-genesis/src/lib.rs:71: replace GenesisData::read_namespaces -> Box> with Box::new(Default::default()) diff --git a/mutation-testing/scripts/append-match-package.sh b/mutation-testing/scripts/append-match-package.sh index e69de29bb2..d9efe6a5bb 100644 --- a/mutation-testing/scripts/append-match-package.sh +++ b/mutation-testing/scripts/append-match-package.sh @@ -0,0 +1,88 @@ +# the append-match-package.sh +## goes through each line in the output and based on the package ( first element before /) +### verifies the line with the other lines in that specific folder +#### in our case folder_name == package_name + + +# goes through each PR file line by line +# for each first_element/the_rest_of_the_line goes through it +## search in that specific folder on all 4 files +## if it is matchy, remove it from that file +## based on the file it was taken from, append it to the same file in the STABLE folder + + + +#!/bin/bash + +PR_FOLDER="./../temp/mutants.out" +STABLE_FOLDER_PARENT="./../packages-output" +FILES=("caught.txt" "missed.txt" "timeout.txt" "unviable.txt") + +echo "Starting script..." +echo "PR Folder: $PR_FOLDER" +echo "STABLE Folder: $STABLE_FOLDER_PARENT" +echo "Files to process: ${FILES[*]}" + +# Function to escape special characters for awk +escape_for_awk() { + echo "$1" | sed -E 's/([][\/$*.^|])/\\&/g' +} + +# Iterate over the specified files +for file in "${FILES[@]}"; do + pr_file="$PR_FOLDER/$file" + stable_file="$STABLE_FOLDER_PARENT/$file" + + echo "Processing file: $file" + + # Check if PR file exists and is not empty + if [[ -s "$pr_file" ]]; then + # Read each line from the PR file + while IFS= read -r line; do + echo "Reading line from PR file: $line" + + # Extract the core pattern without the line number and escape it for awk + core_pattern=$(echo "$line" | sed -E 's/^[^:]+:[0-9]+:(.+)/\1/') + escaped_pattern=$(escape_for_awk "$core_pattern") + echo "Extracted and escaped pattern: $escaped_pattern" + + # Iterate over each file in the STABLE folder + for target_file in "${FILES[@]}"; do + target_path="$STABLE_FOLDER_PARENT/$target_file" + echo "Checking against STABLE file: $target_path" + + # Remove the line matching the pattern, ignoring line numbers + awk -v pat="$escaped_pattern" '$0 !~ pat' "$target_path" > temp_file && mv temp_file "$target_path" + done + done < "$pr_file" + else + echo "PR file $pr_file is empty or does not exist, skipping..." + fi +done + +# After processing all lines, append contents from PR_DIR to STABLE_DIR +for file in "${FILES[@]}"; do + cat "$PR_FOLDER/$file" >> "$STABLE_FOLDER_PARENT/$file" +done + +# Echo the contents of the STABLE folder for verification +echo "Updated contents of STABLE folder:" +for file in "${FILES[@]}"; do + stable_file="$STABLE_FOLDER_PARENT/$file" + echo "Contents of $stable_file:" + cat "$stable_file" + echo "" +done + +echo "Script completed." + + + + +# goes only through txt + + + + +# remove temp/mutants.out +## rm -rf ../temp/ diff --git a/mutation-testing/scripts/create-stable.sh b/mutation-testing/scripts/create-stable.sh index df27ee5eb9..1659714ed0 100644 --- a/mutation-testing/scripts/create-stable.sh +++ b/mutation-testing/scripts/create-stable.sh @@ -4,34 +4,52 @@ #!/bin/bash -# Create mutants directory -mkdir -p mutants +# moves to mutation-testing folder +cd ../packages-output ### Run mutation testing on the packages uncommented # Run mutation testing for stx-genesis package -cargo mutants --package stx-genesis --output mutants/stx-genesis +cargo mutants --package stx-genesis --output stx-genesis +mv stx-genesis/mutants.out/*.txt stx-genesis/ +rm -rf stx-genesis/mutants.out # Run mutation testing for pox-locking package -cargo mutants --package pox-locking --output mutants/pox-locking +cargo mutants --package pox-locking --output pox-locking +mv pox-locking/mutants.out/*.txt pox-locking/ +rm -rf pox-locking/mutants.out # # Run mutation testing for libsigner package -# cargo mutants --package libsigner --output mutants/libsigner +# cargo mutants --package libsigner --output libsigner +# mv libsigner/mutants.out/*.txt libsigner/ +# rm -rf libsigner/mutants.out # # Run mutation testing for libstackerdb package -# cargo mutants --package libstackerdb --output mutants/libstackerdb +# cargo mutants --package libstackerdb --output libstackerdb +# mv libstackerdb/mutants.out/*.txt libstackerdb/ +# rm -rf libstackerdb/mutants.out # # Run mutation testing for stacks-common package -# cargo mutants --package stacks-common --output mutants/stacks-common +# cargo mutants --package stacks-common --output stacks-common +# mv stacks-common/mutants.out/*.txt stacks-common/ +# rm -rf stacks-common/mutants.out # # Run mutation testing for clarity package -# cargo mutants --package clarity --output mutants/clarity +# cargo mutants --package clarity --output clarity +# mv clarity/mutants.out/*.txt clarity/ +# rm -rf clarity/mutants.out # Run mutation testing for stacks-signer package - working, 10 min approx. -# cargo mutants --package stacks-signer --output mutants/stacks-signer +# cargo mutants --package stacks-signer --output stacks-signer +# mv stacks-signer/mutants.out/*.txt stacks-signer/ +# rm -rf stacks-signer/mutants.out # Commented out mutation testing for stacks-node package due to test errors and long compile/testing time -# cargo mutants --package stacks-node --output mutants/stacks-node +# cargo mutants --package stacks-node --output stacks-node +# mv stacks-node/mutants.out/*.txt stacks-node/ +# rm -rf stacks-node/mutants.out # Commented out mutation testing for stackslib package due to long compile/testing time -# cargo mutants --package stackslib --output mutants/stackslib \ No newline at end of file +# cargo mutants --package stackslib --output stackslib +# mv stackslib/mutants.out/*.txt stackslib/ +# rm -rf stackslib/mutants.out \ No newline at end of file diff --git a/mutation-testing/scripts/git-diff.sh b/mutation-testing/scripts/git-diff.sh index beeef5345f..b9dd7f3da5 100644 --- a/mutation-testing/scripts/git-diff.sh +++ b/mutation-testing/scripts/git-diff.sh @@ -1,17 +1,18 @@ # script that makes .git for the differences # it saves the .git on scripts folder -# it runs cargo mutants for those specific changed functions +# run from scripts folder +cd .. +git diff > git.diff -# it creates a new output +# it runs cargo mutants for those specific changed functions and outputs to /temp/mutants.out +# for faster builds: increase number to 4 if at least 16 gb ram and 6 cores CPU +cargo mutants --no-shuffle -j 2 -vV --in-diff git.diff --output temp/ -# then the append-match-package.sh is called -## TODO: update append-match-package.sh with what would be the output from the cargo mutants diff +# call append-match-package.sh to update the content from the stable output +### sh scripts/append-match-package.sh + -# the append-match-package.sh -## goes through each line in the output and based on the package ( first element before /) -### verifies the line with the other lines in that specific folder -#### in our case folder_name == package_name