Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
feat: stable sh outputs in the right folder
Browse files Browse the repository at this point in the history
  • Loading branch information
ASuciuX committed Nov 30, 2023
1 parent 4b14963 commit 97695b1
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 27 deletions.
Empty file.
30 changes: 30 additions & 0 deletions mutation-testing/packages-output/pox-locking/missed.txt
Original file line number Diff line number Diff line change
@@ -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<u128, LockingError> with Ok(1)
pox-locking/src/pox_3.rs:72: replace pox_lock_extend_v3_not_tested -> Result<u128, LockingError> 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<Option<Value>, 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<Option<StacksTransactionEvent>, 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<Option<StacksTransactionEvent>, ClarityError> with Ok(None)
pox-locking/src/pox_2.rs:409: replace handle_stack_lockup_increase_pox_v2 -> Result<Option<StacksTransactionEvent>, 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<Option<StacksTransactionEvent>, 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<u128, LockingError> with Ok(1)
pox-locking/src/pox_3.rs:169: replace handle_stack_lockup_pox_v3 -> Result<Option<StacksTransactionEvent>, 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<Option<StacksTransactionEvent>, 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<u128, LockingError> 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<u128, LockingError> with Ok(0)
pox-locking/src/pox_3.rs:72: replace pox_lock_extend_v3_not_tested -> Result<u128, LockingError> with Ok(1)
Empty file.
22 changes: 22 additions & 0 deletions mutation-testing/packages-output/pox-locking/unviable.txt
Original file line number Diff line number Diff line change
@@ -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<Option<Value>, ClarityError> with Ok(Some(Default::default()))
pox-locking/src/pox_3.rs:236: replace handle_stack_lockup_extension_pox_v3 -> Result<Option<StacksTransactionEvent>, ClarityError> with Ok(Some(Default::default()))
pox-locking/src/pox_2.rs:409: replace handle_stack_lockup_increase_pox_v2 -> Result<Option<StacksTransactionEvent>, 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<STXBalance, LockingError> with Ok(Default::default())
pox-locking/src/pox_3.rs:169: replace handle_stack_lockup_pox_v3 -> Result<Option<StacksTransactionEvent>, ClarityError> with Ok(Some(Default::default()))
pox-locking/src/pox_2.rs:164: replace pox_lock_increase_v2 -> Result<STXBalance, LockingError> 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<Option<StacksTransactionEvent>, 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<Option<StacksTransactionEvent>, 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<Option<StacksTransactionEvent>, 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))
2 changes: 1 addition & 1 deletion mutation-testing/packages-output/stx-genesis/missed.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
stx-genesis/src/lib.rs:108: replace <impl Iterator for LinePairReader>::count -> usize with 1
stx-genesis/src/lib.rs:100: replace <impl Iterator for LinePairReader>::next -> Option<Self::Item> with None
stx-genesis/src/lib.rs:108: replace <impl Iterator for LinePairReader>::count -> usize with 0
stx-genesis/src/lib.rs:100: replace <impl Iterator for LinePairReader>::next -> Option<Self::Item> with None
14 changes: 7 additions & 7 deletions mutation-testing/packages-output/stx-genesis/unviable.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
stx-genesis/src/lib.rs:71: replace GenesisData::read_namespaces -> Box<dyn Iterator<Item = GenesisNamespace>> with Box::new(Default::default())
stx-genesis/src/lib.rs:148: replace read_lockups -> Box<dyn Iterator<Item = GenesisAccountLockup>> with Box::new(Default::default())
stx-genesis/src/lib.rs:78: replace GenesisData::read_names -> Box<dyn Iterator<Item = GenesisName>> with Box::new(Default::default())
stx-genesis/src/lib.rs:140: replace read_balances -> Box<dyn Iterator<Item = GenesisAccountBalance>> with Box::new(Default::default())
stx-genesis/src/lib.rs:157: replace read_namespaces -> Box<dyn Iterator<Item = GenesisNamespace>> with Box::new(Default::default())
stx-genesis/src/lib.rs:129: replace iter_deflated_csv -> Box<dyn Iterator<Item = Vec<String>>> with Box::new(Default::default())
stx-genesis/src/lib.rs:140: replace read_balances -> Box<dyn Iterator<Item = GenesisAccountBalance>> with Box::new(Default::default())
stx-genesis/src/lib.rs:85: replace GenesisData::read_name_zonefiles -> Box<dyn Iterator<Item = GenesisZonefile>> with Box::new(Default::default())
stx-genesis/src/lib.rs:78: replace GenesisData::read_names -> Box<dyn Iterator<Item = GenesisName>> with Box::new(Default::default())
stx-genesis/src/lib.rs:64: replace GenesisData::read_lockups -> Box<dyn Iterator<Item = GenesisAccountLockup>> with Box::new(Default::default())
stx-genesis/src/lib.rs:115: replace read_deflated_zonefiles -> Box<dyn Iterator<Item = GenesisZonefile>> with Box::new(Default::default())
stx-genesis/src/lib.rs:57: replace GenesisData::read_balances -> Box<dyn Iterator<Item = GenesisAccountBalance>> with Box::new(Default::default())
stx-genesis/src/lib.rs:115: replace read_deflated_zonefiles -> Box<dyn Iterator<Item = GenesisZonefile>> with Box::new(Default::default())
stx-genesis/src/lib.rs:171: replace read_names -> Box<dyn Iterator<Item = GenesisName>> with Box::new(Default::default())
stx-genesis/src/lib.rs:148: replace read_lockups -> Box<dyn Iterator<Item = GenesisAccountLockup>> with Box::new(Default::default())
stx-genesis/src/lib.rs:64: replace GenesisData::read_lockups -> Box<dyn Iterator<Item = GenesisAccountLockup>> with Box::new(Default::default())
stx-genesis/src/lib.rs:85: replace GenesisData::read_name_zonefiles -> Box<dyn Iterator<Item = GenesisZonefile>> with Box::new(Default::default())
stx-genesis/src/lib.rs:71: replace GenesisData::read_namespaces -> Box<dyn Iterator<Item = GenesisNamespace>> with Box::new(Default::default())
88 changes: 88 additions & 0 deletions mutation-testing/scripts/append-match-package.sh
Original file line number Diff line number Diff line change
@@ -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/
40 changes: 29 additions & 11 deletions mutation-testing/scripts/create-stable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
# cargo mutants --package stackslib --output stackslib
# mv stackslib/mutants.out/*.txt stackslib/
# rm -rf stackslib/mutants.out
17 changes: 9 additions & 8 deletions mutation-testing/scripts/git-diff.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 97695b1

Please sign in to comment.