Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: TestingResearchIllinois/idoft
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 316e1a0d16e664481d91e0b5e916bbfc0034a1b0
Choose a base ref
..
head repository: TestingResearchIllinois/idoft
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f03940d1cb802c78089ea8c53ec7f55c52023348
Choose a head ref
45 changes: 20 additions & 25 deletions auto-check-deletion/check-deletion.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
#!/bin/bash

filtered_tests=$(cat filtered_tests.txt | sed 's/,.*\//,/' | rev | cut -d'.' -f 1,2 | rev);
filtered_tests=$(cat filtered_tests.txt | sed 's/,.*\//,/' | rev | cut -d'.' -f 1,2 | rev)

output_file='check-deletion-output.txt';
output_file='check-deletion-output.txt'
rm "$output_file"

# Check the file is exists or not
if [ -f $output_file ]; then
rm check-deletion-output.txt;
fi
echo "$filtered_tests" | while IFS=',' read -r test commit; do
if [ -z "$test" ] || [ -z "$commit" ]; then
continue
fi

IFS=','
echo "Processing test: $test with commit: $commit"

printf "$filtered_tests" | while read line;
do
read -a split_line <<< $line
test=${split_line[0]};
commit=${split_line[1]};
commit=$(printf "$commit");
class=$(printf "$test" | cut -d'.' -f 1);
test_method=$(printf "$test" | cut -d'.' -f 2);
git_show=$(git show "${commit::-1}");
echo ==== deleted ${test} ? ==== |& tee -a $output_file;
if echo "$git_show" | grep -q "^-.*${test_method}"
then
echo "$git_show" | grep "^-.*${test_method}" |& tee -a $output_file;
else
echo "Deleted method not found. Finding deleted test class." |& tee -a $output_file;
echo "$git_show" | grep "^-.*${class}" |& tee -a $output_file;
fi
class=$(printf "%s" "$test" | cut -d'.' -f 1)
test_method=$(printf "%s" "$test" | cut -d'.' -f 2)
git_show=$(git show "${commit::-1}")

echo "==== deleted ${test} ? ====" 2>&1 | tee -a "$output_file"
if echo "$git_show" | grep -q "^-.*${test_method}"; then
echo "$git_show" | grep "^-.*${test_method}" |& tee -a "$output_file"
else
echo "Deleted method not found. Finding deleted test class." |& tee -a "$output_file"
echo "$git_show" | grep "^-.*${class}" |& tee -a "$output_file"
fi
done

echo "$output_file";
echo "Output written to $output_file"
17 changes: 13 additions & 4 deletions auto-check-fix-commit/README.md
Original file line number Diff line number Diff line change
@@ -17,12 +17,21 @@ Reference - https://git-scm.com/docs/git-bisect/

### Usage

1. Copy scripts `git-bisect-runner.sh` and `git-bisect-script.sh` to the directory of the project containing the fixed flaky test.
1. Fork/clone this repo with the auto-check-fix-commit module containing the `git-bisect-runner.sh` and `git-bisect-script.sh` scripts.

2. Copy scripts `git-bisect-runner.sh` and `git-bisect-script.sh` to the directory of the project containing the fixed flaky test.

2. Run the script using the below command
3. Within the project containing the DeveloperFixed test, run the script using the command below. Modify arguments to specific flaky commit, fixed commit, module path, test case of your project, mvn install options, and NonDex version. This command will also ensure standard error and output messages go to `git_bisect_output.log`, while running command in the background (since using nohup).
```shell
./git-bisect-runner.sh --flaky e6d76803f27133d7700811585f5310470e50e487 --fixed 5828d56a824748e7c91076842fad75efb42f92f9 --module core/server/worker --test alluxio.worker.block.BlockLockManagerTest#lockAlreadyReadLockedBlock
nohup ./git-bisect-runner.sh --flaky <FLAKY_COMMIT> --fixed <FIXED_COMMIT> --module <MODULE_PATH> --test <TEST_CASE> --nondex-version "<NONDEX VERSION>" --mvn-install "<MAVEN_OPTIONS>" &> git_bisect_output.log
```
Example:
```shell
nohup ./git-bisect-runner.sh --flaky ecf41be2ecd007853c2db19e1c6a038cf356cb9e --fixed f69557e325c5bb9e4e250bb0ec2db12d85298211 --module pinot-core --test org.apache.pinot.queries.ForwardIndexHandlerReloadQueriesTest#testSelectQueries --nondex-version "2.1.7" --mvn-install "-Dspotless.skip" &> git_bisect_output.log
```

The output of this execution will give the commit where the flaky test was fixed. Messages within process can be found in log file within project directory.

The output of this execution will give the commit where the flaky test was fixed.
To check for errors during process, run: `git bisect status`
To check log as process is running, run: `git bisect log`
To stop and reset bisect process, run: `git bisect reset`
47 changes: 28 additions & 19 deletions auto-check-fix-commit/git-bisect-runner.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
#!/bin/bash

for arg in "$@"; do
shift
case "$arg" in
'--flaky') set -- "$@" '-f' ;;
'--fixed') set -- "$@" '-x' ;;
'--module') set -- "$@" '-m' ;;
'--test') set -- "$@" '-t' ;;
*) set -- "$@" "$arg" ;;
mvn_options=""
nondex_version=""
flaky_commit=""
fixed_commit=""
test_module=""
test_case=""

while [[ $# -gt 0 ]]; do
case "$1" in
'--flaky') flaky_commit="$2"; shift 2 ;;
'--fixed') fixed_commit="$2"; shift 2 ;;
'--module') test_module="$2"; shift 2 ;;
'--test') test_case="$2"; shift 2 ;;
'--nondex-version') nondex_version="$2"; shift 2 ;;
'--mvn-install') mvn_options="$2"; shift 2 ;;
*) echo "Unknown argument: $1"; exit 1 ;;
esac
done

OPTIND=1
while getopts "f:x:m:t:" opt; do
case "$opt" in
'f') flaky_commit=$OPTARG ;;
'x') fixed_commit=$OPTARG ;;
'm') test_module=$OPTARG ;;
't') test_case=$OPTARG ;;
esac
done
shift $(expr $OPTIND - 1)
echo "Flaky Commit: $flaky_commit"
echo "Fixed Commit: $fixed_commit"
echo "Test Module: $test_module"
echo "Test Case: $test_case"
echo "NonDex Version: $nondex_version"
echo "Maven Options: $mvn_options"

if [[ -z "$flaky_commit" || -z "$fixed_commit" || -z "$test_module" || -z "$test_case" || -z "$nondex_version" ]]; then
echo "Error: Missing required argument(s)."
exit 1
fi

git checkout $fixed_commit

@@ -32,4 +41,4 @@ git checkout $flaky_commit

git bisect good

git bisect run ./git-bisect-script.sh $test_module $test_case
git bisect run ./git-bisect-script.sh $test_module $test_case "$nondex_version" "$mvn_options"
6 changes: 4 additions & 2 deletions auto-check-fix-commit/git-bisect-script.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -4,14 +4,16 @@ echo "Started Execution"

test_module=$1
test_case=$2
nondex_version=$3
mvn_options=$4

echo "Started Build"
mvn clean install -pl $test_module -am -DskipTests -Dlicense.skip
mvn clean install -pl $test_module -am -DskipTests -Dlicense.skip $mvn_options
if [[ "$?" -ne 0 ]]; then
echo "Build Failed"
exit 1
else
mvn -pl $test_module edu.illinois:nondex-maven-plugin:1.1.2:nondex -Dtest=$test_case -DnondexRuns=5 -Dlicense.skip=true
mvn -pl $test_module edu.illinois:nondex-maven-plugin:$nondex_version:nondex -Dtest=$test_case -DnondexRuns=5 -Dlicense.skip=true
if [[ "$?" -ne 0 ]]; then
echo "NonDex Test Failed"
exit 0
48 changes: 48 additions & 0 deletions auto-check-moved-or-rename/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Overview
This script helps identify if specific test files in a Git repository have been moved or renamed in their commit history. Currently, it only supports detecting whether a test class has been moved to a different location in previous commits.

# Usage Instructions

1. Use a tool like "auto-filter-tests-by-letter" or other methods to identify the test classes you want to verify.

2. Create a text file named `test.txt` and list all the test you want to check within a specific repository.

3. Copy `test.txt` and the script (`check_moved_or_rename.sh`) to the root directory of the repository you want to check.

4. Execute the script by running:
```bash
chmod +x check_moved_or_rename.sh
./check_moved_or_rename.sh
```
The output will be written to a new text file named `output.txt` in the same folder.

# Example Input and Output

### Example Input (`test.txt`)
```
https://github.com/apache/dubbo,737f7a7ea67832d7f17517326fb2491d0a086dd7,dubbo-filter/dubbo-filter-cache,org.apache.dubbo.cache.support.jcache.JCacheFactoryTest.testJCacheGetExpired,OD-Vic,,,
https://github.com/apache/dubbo,5349c13a36d277a090e1dc68fbe7c3b46d78fc90,dubbo-common,org.apache.dubbo.common.beanutil.JavaBeanSerializeUtilTest.testDeserializeBean,OD-Vic,,,
```
### Example Output (`output.txt`)
```
Processing line: https://github.com/apache/dubbo,737f7a7ea67832d7f17517326fb2491d0a086dd7,dubbo-filter/dubbo-filter-cache,org.apache.dubbo.cache.support.jcache.JCacheFactoryTest.testJCacheGetExpired,OD-Vic,,,
File 'dubbo-filter/dubbo-filter-cache/src/test/java/org/apache/dubbo/cache/support/jcache/JCacheFactoryTest.java' was moved or renamed in commit acee3e2f03227894b5aa4d852de1a6a4bcfab60e:
From: dubbo-filter/dubbo-filter-cache/src/test/java/org/apache/dubbo/cache/support/jcache/JCacheFactoryTest.java
To: dubbo-plugin/dubbo-filter-cache/src/test/java/org/apache/dubbo/cache/support/jcache/JCacheFactoryTest.java
Found move or rename for line: https://github.com/apache/dubbo,737f7a7ea67832d7f17517326fb2491d0a086dd7,dubbo-filter/dubbo-filter-cache,org.apache.dubbo.cache.support.jcache.JCacheFactoryTest.testJCacheGetExpired,OD-Vic,,,

Processing line: https://github.com/apache/dubbo,5349c13a36d277a090e1dc68fbe7c3b46d78fc90,dubbo-common,org.apache.dubbo.common.beanutil.JavaBeanSerializeUtilTest.testDeserializeBean,OD-Vic,,,
No move or rename found for line: https://github.com/apache/dubbo,5349c13a36d277a090e1dc68fbe7c3b46d78fc90,dubbo-common,org.apache.dubbo.common.beanutil.JavaBeanSerializeUtilTest.testDeserializeBean,OD-Vic,,,
```
### Explanation
- **Moved File**:
- For the first record, the script found that `JCacheFactoryTest.java` was moved from `dubbo-filter/dubbo-filter-cache` to a different directory (`dubbo-plugin/dubbo-filter-cache`) at commit `acee3e2f03227894b5aa4d852de1a6a4bcfab60e`.
- **Unchanged File**:
- For records where the test class was not moved or renamed, the script outputs a message indicating that no changes were found for that specific line:
```
No moved or rename found for line: <input_line>
```
57 changes: 57 additions & 0 deletions auto-check-moved-or-rename/check_moved_or_rename.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

input_file="test.txt"
output_file="output.txt"

if [ ! -f "$input_file" ]; then
echo "Error: File '$input_file' does not exist."
exit 1
fi

> "$output_file"

while IFS= read -r line || [[ -n "$line" ]]; do
echo "Processing line: $line" | tee -a "$output_file"

IFS=',' read -r project_url sha module_path package_class_path _ <<< "$line"

class_name=$(echo "$package_class_path" | awk -F '.' '{print $(NF-1)}')
package_path=$(echo "$package_class_path" | awk -F '.' '{for (i=1; i<NF-1; i++) printf "%s/", $i; print ""}')
current_file_path="$module_path/src/test/java/$package_path$class_name.java"

# get the commit history of the file
commits=$(git log --follow --format=%H -- "$current_file_path" 2>/dev/null)

if [ -z "$commits" ]; then
echo "No moved or rename found for Line: $line" | tee -a "$output_file"
continue
fi

# for each commit, check if the file was moved
found_moved_commit=false
for commit in $commits; do
rename_info=$(git show --name-status "$commit" | grep "^R" | grep "$current_file_path")

if [ -n "$rename_info" ]; then
new_path=$(echo "$rename_info" | awk '{print $3}')

# ensure the new path exists in the commit, and it is different from the current path
if [[ "$new_path" != "$current_file_path" ]] && git show "$commit:$new_path" &>/dev/null; then
echo "File '$current_file_path' was moved or renamed in commit $commit:" | tee -a "$output_file"
echo "From: $current_file_path" | tee -a "$output_file"
echo "To: $new_path" | tee -a "$output_file"
echo "Found moved or renamed for line: $line" | tee -a "$output_file"
current_file_path=$new_path
found_moved_commit=true
break
fi
fi
done

if [ "$found_moved_commit" = false ]; then
echo "No moved or rename found for Line: $line" | tee -a "$output_file"
fi

echo | tee -a "$output_file"

done < "$input_file"
30 changes: 30 additions & 0 deletions auto-filter-tests-by-letter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Filter Tests Script

This script filters rows from a CSV file based on specific criteria and writes the results to a new CSV file. It is designed to find repository names starting with a specified letter and having an empty `Status` column.

## Requirements

- Python 3.9 or later
- CSV file with the following columns (at a minimum):
- A column containing repository URLs name `Project URL`.
- A column named `Status`.

## Usage

1. Run the script

```
python3 filter_tests_by_letter.py <letter> <file_path>
```

Parameters:
<letter>: The letter that repository names should start with (case-insensitive).
<file_path>: Path to the CSV file to process.

Example:

```
python3 filter_tests_by_letter.py b ../pr-data.csv
```

This will print to the terminal all repositories in pr-data.csv that start with the letter B and have an empty Status column.
69 changes: 69 additions & 0 deletions auto-filter-tests-by-letter/filter_tests_by_letter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""
This script filters rows from a CSV file based on specific criteria.
It identifies rows where the project name (extracted from a URL column)
starts with a given letter and where the "Status" column is empty.
The filtered rows are saved to a new CSV file.
Usage:
python3 filter_tests_by_letter.py <letter> <file_path>
Arguments:
letter: The starting letter of the project name to filter.
file_path: The path to the input CSV file.
"""

import csv
import argparse
import sys


def filter_tests_by_letter(file_path: str, letter: str) -> tuple[list[str], list]:
"""
Filters rows from a CSV file where the project name starts with a given letter
and the "Status" column is empty.
Args:
file_path (str): The path to the input CSV file.
letter (str): The letter to match at the start of project names.
Returns:
tuple[list[str], list]: A tuple containing:
- The header row from the CSV file as a list of strings.
- A list of rows that match the criteria, where each row is a list of values.
"""

matching_lines = []
header = []

with open(file_path, mode='r', newline='', encoding='utf-8') as input_file:
reader = csv.reader(input_file)
header = next(reader)
url_index = header.index("Project URL")
status_index = header.index("Status")

for row in reader:
project_url = row[url_index]
project_name = project_url.split('/')[4]
status = row[status_index]
if project_name.lower().startswith(letter.lower()) and status == '':
matching_lines.append(row)

return header, matching_lines


if __name__ == "__main__":
parser = argparse.ArgumentParser(
description='Find unique repos starting with a specific letter.')
parser.add_argument('letter', type=str,
help='The starting letter of the project name')
parser.add_argument('file_path', type=str, help='The path to the CSV file')

args = parser.parse_args()

output_header, filtered_lines = filter_tests_by_letter(
args.file_path, args.letter)

writer = csv.writer(sys.stdout)
writer.writerow(output_header)
writer.writerows(filtered_lines)
17 changes: 17 additions & 0 deletions auto-run-dockerized-nondex/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use a Maven image with a configurable Java version
ARG JAVA_VERSION=17
FROM maven:3.9.4-eclipse-temurin-${JAVA_VERSION}

WORKDIR /app

RUN apt-get update && apt-get install -y git && apt-get clean

# Thanks - https://github.com/TestingResearchIllinois/idoft/pull/1491
ENV MAVEN_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1"

COPY entrypoint.sh /entrypoint.sh

RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]

Loading