Fix doctests (#9225)

Haven’t tracked down when they broke. They used to work at some point
but atm they are very broken and don’t test anything.

This PR fixes the bash mess to parse the files correctly and fixes two
minor issues that creeped in by virtue of the doctests being broken.

changelog_begin
changelog_end
This commit is contained in:
Moritz Kiefer 2021-03-24 12:56:37 +01:00 committed by GitHub
parent b0c0306696
commit 4fd1cf7c28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -320,6 +320,7 @@ daml_doc_test(
flags = ["--no-dflags-check"],
ignored_srcs = [
"LibraryModules.daml",
"DA/Experimental/Example.daml",
"DA/Time/Types.daml",
],
)

View File

@ -82,8 +82,8 @@ fromList list = foldl (\acc (key, value) -> insert key value acc) empty list
--
-- ```
-- >>> fromListWith (++) [("A", [1]), ("A", [2]), ("B", [2]), ("B", [1]), ("A", [3])]
-- Map [("A", [1, 2, 3]), ("B", [2, 1])]
-- >>> fromListWith (++) [] == (M.empty : Map Text [Int])
-- fromList [("A", [1, 2, 3]), ("B", [2, 1])]
-- >>> fromListWith (++) [] == (empty : Map Text [Int])
-- True
-- ```
fromListWith : Ord k => (v -> v -> v) -> [(k, v)] -> Map k v

View File

@ -383,16 +383,21 @@ def daml_doc_test(
name = name,
data = [cpp, damlc] + srcs,
cmd = """\
set -eou pipefail
CPP=$$(canonicalize_rlocation $(rootpath {cpp}))
DAMLC=$$(canonicalize_rlocation $(rootpath {damlc}))
FILES=($$(
for file in {files}; do
IGNORED=false
for pattern in {ignored}; do
if [[ $$file = *$$pattern ]]; then
IGNORED=true
continue
fi
echo $$(canonicalize_rlocation $$i)
done
if [[ $$IGNORED == "false" ]]; then
echo $$(canonicalize_rlocation $$file)
fi
done
))