From 46ceeed54cc4e049fc4145f299c060dc371d1c2d Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 2 Apr 2022 10:02:20 +0200 Subject: [PATCH 1/4] GNU: add a script to list the failing tests and sort them by size: (the smaller, the easier to fix in general) --- util/remaining-gnu-error.py | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 util/remaining-gnu-error.py diff --git a/util/remaining-gnu-error.py b/util/remaining-gnu-error.py new file mode 100755 index 000000000..79f1ae790 --- /dev/null +++ b/util/remaining-gnu-error.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +# This script lists the GNU failing tests by size +# Just like with util/run-gnu-test.sh, we expect the gnu sources +# to be in ../ +import urllib.request + +import urllib +import os +import glob +import json + +base = "../gnu/tests/" +urllib.request.urlretrieve( + "https://raw.githubusercontent.com/uutils/coreutils-tracking/main/gnu-full-result.json", + "result.json", +) + +tests = glob.glob(base + "/*/*.sh") +tests_pl = glob.glob(base + "/*/*.pl") +tests_xpl = glob.glob(base + "/*/*.xpl") +tests = tests + tests_pl + tests_xpl + +# sort by size +list_of_files = sorted(tests, key=lambda x: os.stat(x).st_size) + +with open("result.json", "r") as json_file: + data = json.load(json_file) + +for d in data: + for e in data[d]: + # Not all the tests are .sh files, rename them if not. + script = e.replace(".log", ".sh") + a = "%s%s/%s" % (base, d, script) + if not os.path.exists(a): + a = a.replace(".sh", ".pl") + if not os.path.exists(a): + a = a.replace(".pl", ".xpl") + + # the tests pass, we don't care anymore + if data[d][e] == "PASS": + list_of_files.remove(a) + +# Remove the factor tests and reverse the list (bigger first) +tests = list(filter(lambda k: "factor" not in k, list_of_files)) + +for f in reversed(tests): + print("%s: %s" % (f, os.stat(f).st_size)) +print("") +print("%s tests remaining" % len(tests)) From f633d52cb11caad7b4010e0db3ab10104749e4f8 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 2 Apr 2022 10:20:07 +0200 Subject: [PATCH 2/4] GNU: Document how to fix GNU tests --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index e00a01ec5..b95f05b99 100644 --- a/README.md +++ b/README.md @@ -373,6 +373,25 @@ $ bash util/run-gnu-test.sh tests/touch/not-owner.sh # for example Note that it relies on individual utilities (not the multicall binary). +### Improving the GNU compatibility + +The Python script `./util/remaining-gnu-error.py` shows the list of failing tests in the CI. + +To improve the GNU compatibility, the following process is recommended: + +1. Identify a test (the smaller, the better) on a program that you understand or easy to understand. You can use the `./util/remaining-gnu-error.py` script to help with this decision. +1. Build both the GNU and Rust coreutils using: `bash util/build-gnu.sh` +1. Run the test with `bash util/run-gnu-test.sh ` +1. Start to modify `` to understand what is wrong. Examples: + 1. Add `set -v` to have the bash verbose mode + 1. Add `echo $?` where needed + 1. Bump the content of the output (ex: `cat err`) + 1. ... +1. Or, if the test is simple, extract the relevant information to create a new test case running both GNU & Rust implementation +1. Start to modify the Rust implementation to match the expected behavior +1. Add a test to make sure that we don't regress (our test suite is super quick) + + ## Contributing To contribute to uutils, please see [CONTRIBUTING](CONTRIBUTING.md). From 950432e492a8f39021e76626ab28f4af88a1d6d8 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 3 Apr 2022 11:09:45 +0200 Subject: [PATCH 3/4] fix typo Co-authored-by: Terts Diepraam --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b95f05b99..0683e42f8 100644 --- a/README.md +++ b/README.md @@ -379,7 +379,7 @@ The Python script `./util/remaining-gnu-error.py` shows the list of failing test To improve the GNU compatibility, the following process is recommended: -1. Identify a test (the smaller, the better) on a program that you understand or easy to understand. You can use the `./util/remaining-gnu-error.py` script to help with this decision. +1. Identify a test (the smaller, the better) on a program that you understand or is easy to understand. You can use the `./util/remaining-gnu-error.py` script to help with this decision. 1. Build both the GNU and Rust coreutils using: `bash util/build-gnu.sh` 1. Run the test with `bash util/run-gnu-test.sh ` 1. Start to modify `` to understand what is wrong. Examples: From 7076cc084f92bcb85d8364eb3a6ec19daaf16024 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 3 Apr 2022 11:10:39 +0200 Subject: [PATCH 4/4] Use the more modern python string declaration --- util/remaining-gnu-error.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/remaining-gnu-error.py b/util/remaining-gnu-error.py index 79f1ae790..5be7e784c 100755 --- a/util/remaining-gnu-error.py +++ b/util/remaining-gnu-error.py @@ -30,7 +30,7 @@ for d in data: for e in data[d]: # Not all the tests are .sh files, rename them if not. script = e.replace(".log", ".sh") - a = "%s%s/%s" % (base, d, script) + a = f"{base}{d}{script}" if not os.path.exists(a): a = a.replace(".sh", ".pl") if not os.path.exists(a):