Skip to content

Commit

Permalink
Merge pull request #144 from tavianator/dejagnu
Browse files Browse the repository at this point in the history
ci: Also run the dejagnu tests from GNU findutils
  • Loading branch information
sylvestre authored Feb 8, 2022
2 parents a7af227 + 43027d0 commit 48d6f63
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 45 deletions.
48 changes: 7 additions & 41 deletions .github/workflows/compat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,13 @@ jobs:
- name: Extract testing info
shell: bash
run: |
LOG_FILE=findutils.gnu/tests/test-suite.log
if test -f "$LOG_FILE"; then
TOTAL=$(sed -n "s/.*# TOTAL: \(.*\)/\1/p" "$LOG_FILE"|tr -d '\r'|head -n1)
PASS=$(sed -n "s/.*# PASS: \(.*\)/\1/p" "$LOG_FILE"|tr -d '\r'|head -n1)
SKIP=$(sed -n "s/.*# SKIP: \(.*\)/\1/p" "$LOG_FILE"|tr -d '\r'|head -n1)
FAIL=$(sed -n "s/.*# FAIL: \(.*\)/\1/p" "$LOG_FILE"|tr -d '\r'|head -n1)
XPASS=$(sed -n "s/.*# XPASS: \(.*\)/\1/p" "$LOG_FILE"|tr -d '\r'|head -n1)
ERROR=$(sed -n "s/.*# ERROR: \(.*\)/\1/p" "$LOG_FILE"|tr -d '\r'|head -n1)
if [[ "$TOTAL" -eq 0 || "$TOTAL" -eq 1 ]]; then
echo "Error in the execution, failing early"
exit 1
fi
output="GNU tests summary = TOTAL: $TOTAL / PASS: $PASS / FAIL: $FAIL / ERROR: $ERROR"
echo "${output}"
if [[ "$FAIL" -gt 0 || "$ERROR" -gt 0 ]]; then echo "::warning ::${output}" ; fi
jq -n \
--arg date "$(date --rfc-email)" \
--arg sha "$GITHUB_SHA" \
--arg total "$TOTAL" \
--arg pass "$PASS" \
--arg skip "$SKIP" \
--arg fail "$FAIL" \
--arg xpass "$XPASS" \
--arg error "$ERROR" \
'{($date): { sha: $sha, total: $total, pass: $pass, skip: $skip, fail: $fail, xpass: $xpass, error: $error, }}' > gnu-result.json
else
echo "::error ::Failed to get summary of test results"
fi
- uses: actions/upload-artifact@v2
with:
name: gnu-test-report
path: findutils.gnu/tests/**/*.log
path: |
findutils.gnu/find/testsuite/*.log
findutils.gnu/xargs/testsuite/*.log
findutils.gnu/tests/**/*.log
- uses: actions/upload-artifact@v2
with:
name: gnu-result
Expand All @@ -95,18 +70,9 @@ jobs:
- name: Compare failing tests against master
shell: bash
run: |
OLD_FAILING=$(sed -n "s/^FAIL: \([[:print:]]\+\).*/\1/p" dl/test-suite.log | sort)
NEW_FAILING=$(sed -n "s/^FAIL: \([[:print:]]\+\).*/\1/p" findutils.gnu/tests/test-suite.log | sort)
for LINE in $OLD_FAILING; do
if ! grep -Fxq $LINE<<<"$NEW_FAILING"; then
echo "::warning ::Congrats! The gnu test $LINE is now passing!"
fi
done
for LINE in $NEW_FAILING; do
if ! grep -Fxq $LINE<<<"$OLD_FAILING"; then
echo "::error ::gnu test failed: $LINE. $LINE is passing on 'main'. Maybe you have to rebase?"
fi
done
mkdir -p ./logs
cp findutils.gnu/{tests,{find,xargs}/testsuite}/*.log ./logs
./findutils/util/diff-gnu.sh dl logs
- name: Compare against main results
shell: bash
run: |
Expand Down
21 changes: 20 additions & 1 deletion src/find/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ fn parse_args(args: &[&str]) -> Result<ParsedInfo, Box<dyn Error>> {
let mut i = 0;
let mut config = Config::default();

while i < args.len() {
match args[i] {
"-O0" | "-O1" | "-O2" | "-O3" => {
// GNU find optimization level flag (ignored)
}
_ => break,
}

i += 1;
}

let paths_start = i;
while i < args.len()
&& (args[i] == "-" || !args[i].starts_with('-'))
&& args[i] != "!"
Expand All @@ -96,7 +108,7 @@ fn parse_args(args: &[&str]) -> Result<ParsedInfo, Box<dyn Error>> {
paths.push(args[i].to_string());
i += 1;
}
if i == 0 {
if i == paths_start {
paths.push(".".to_string());
}
let matcher = matchers::build_top_level_matcher(&args[i..], &mut config)?;
Expand Down Expand Up @@ -339,6 +351,13 @@ mod tests {
}
}

#[test]
fn parse_optimize_flag() {
let parsed_info =
super::parse_args(&["-O0", ".", "-print"]).expect("parsing should succeed");
assert_eq!(parsed_info.paths, ["."]);
}

#[test]
fn find_main_not_depth_first() {
let deps = FakeDependencies::new();
Expand Down
58 changes: 55 additions & 3 deletions util/build-gnu.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash

set -e

if test ! -d ../findutils.gnu; then
echo "Could not find ../findutils.gnu"
echo "git clone https://git.savannah.gnu.org/git/findutils.git findutils.gnu"
echo "git clone https://git.savannah.gnu.org/git/findutils.git findutils.gnu"
exit 1
fi

Expand All @@ -16,7 +17,7 @@ cp target/release/xargs ../findutils.gnu/xargs.rust
cd ../findutils.gnu
if test ! -f configure; then
./bootstrap
./configure --quiet --disable-gcc-warnings
./configure --quiet
make -j "$(nproc)"
fi

Expand All @@ -30,4 +31,55 @@ if test -n "$1"; then
fi

# Run the tests
make check-TESTS $RUN_TEST
make check-TESTS $RUN_TEST || :
make -C find/testsuite check || :
make -C xargs/testsuite check || :

PASS=0
SKIP=0
FAIL=0
XPASS=0
ERROR=0

LOG_FILE=./find/testsuite/find.log
if test -f "$LOG_FILE"; then
((PASS += $(sed -En 's/# of expected passes\s*//p' "$LOG_FILE"))) || :
((FAIL += $(sed -En 's/# of unexpected failures\s*//p' "$LOG_FILE"))) || :
fi

LOG_FILE=./xargs/testsuite/xargs.log
if test -f "$LOG_FILE"; then
((PASS += $(sed -En 's/# of expected passes\s*//p' "$LOG_FILE"))) || :
((FAIL += $(sed -En 's/# of unexpected failures\s*//p' "$LOG_FILE"))) || :
fi

((TOTAL = PASS + FAIL)) || :

LOG_FILE=./tests/test-suite.log
if test -f "$LOG_FILE"; then
((TOTAL += $(sed -n "s/.*# TOTAL: \(.*\)/\1/p" "$LOG_FILE" | tr -d '\r' | head -n1))) || :
((PASS += $(sed -n "s/.*# PASS: \(.*\)/\1/p" "$LOG_FILE" | tr -d '\r' | head -n1))) || :
((SKIP += $(sed -n "s/.*# SKIP: \(.*\)/\1/p" "$LOG_FILE" | tr -d '\r' | head -n1))) || :
((FAIL += $(sed -n "s/.*# FAIL: \(.*\)/\1/p" "$LOG_FILE" | tr -d '\r' | head -n1))) || :
((XPASS += $(sed -n "s/.*# XPASS: \(.*\)/\1/p" "$LOG_FILE" | tr -d '\r' | head -n1))) || :
((ERROR += $(sed -n "s/.*# ERROR: \(.*\)/\1/p" "$LOG_FILE" | tr -d '\r' | head -n1))) || :
fi

if ((TOTAL <= 1)); then
echo "Error in the execution, failing early"
exit 1
fi

output="GNU tests summary = TOTAL: $TOTAL / PASS: $PASS / FAIL: $FAIL / ERROR: $ERROR"
echo "${output}"
if [[ "$FAIL" -gt 0 || "$ERROR" -gt 0 ]]; then echo "::warning ::${output}" ; fi
jq -n \
--arg date "$(date --rfc-email)" \
--arg sha "$GITHUB_SHA" \
--arg total "$TOTAL" \
--arg pass "$PASS" \
--arg skip "$SKIP" \
--arg fail "$FAIL" \
--arg xpass "$XPASS" \
--arg error "$ERROR" \
'{($date): { sha: $sha, total: $total, pass: $pass, skip: $skip, fail: $fail, xpass: $xpass, error: $error, }}' > ../gnu-result.json
19 changes: 19 additions & 0 deletions util/diff-gnu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -eu

export LC_COLLATE=C

# Extract the failing test lines from log files
failing_tests() {
sed -En 's/FAIL: ([^,:]*)[,:].*/\1/p' "$@" | sort
}

comm -3 <(failing_tests $1/*.log) <(failing_tests $2/*.log) | tr '\t' ',' | while IFS=, read old new foo; do
if [ -n "$old" ]; then
echo "::warning ::Congrats! The GNU test $old is now passing!"
fi
if [ -n "$new" ]; then
echo "::error ::GNU test failed: $new. $new is passing on 'main'. Maybe you have to rebase?"
fi
done

0 comments on commit 48d6f63

Please sign in to comment.