sim: support "--" as comment

Using this in my sim files that are also mdwn files to avoid comments
being displayed as headers.
This commit is contained in:
Joey Hess 2024-09-25 14:47:32 -04:00
parent dc6c0f0f1f
commit 6a95e4edad
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 24 additions and 22 deletions

View file

@ -27,7 +27,8 @@ parseSimFile = go [] . lines
parseSimFileLine :: String -> Either String SimCommand
parseSimFileLine s
| "#" `isPrefixOf` s = Right (CommandComment s)
| "#" `isPrefixOf` s || "--" `isPrefixOf` s =
Right (CommandComment s)
| all isSpace s = Right (CommandBlank)
| otherwise = parseSimCommand (words s)

View file

@ -42,7 +42,8 @@ shown before it is stopped.
This text file is used to configure the simulation and also to report on
the results of the simulation. Each line takes the form of a command
followed by parameters to the command. Lines starting with "#" are comments.
followed by parameters to the command. Lines starting with "#" or "--"
are comments.
Here is an example sim file:

View file

@ -1,4 +1,4 @@
# size balanced preferred content sim
-- size balanced preferred content sim
seed -4592890916829221843
init foo
init bar

View file

@ -1,6 +1,6 @@
# This is a simulation of random preferred content expressions.
# git-annex sim run this in a loop to explore if an expression can fail to
# stabilize
-- This is a simulation of random preferred content expressions.
-- git-annex sim run this in a loop to explore if an expression can fail to
-- stabilize
init foo
init bar
connect foo <-> bar
@ -8,6 +8,6 @@ addmulti 10 .x 100.0kB 10.0MB foo
addmulti 10 .y 100.0kB 10.0MB foo
randomwanted bar largerthan=1MB include=*.x anything present
randomwanted foo largerthan=1MB include=*.x anything present
# 40 is the maximum possible steps, in case bar wants to get all 20 files,
# and foo wants to drop them all
-- 40 is the maximum possible steps, in case bar wants to get all 20 files,
-- and foo wants to drop them all
stepstable 40

View file

@ -1,8 +1,8 @@
# Size balanced preferred content sim with multiple repositories sending
# concurrently to the same repositories, in a cluster.
#
# This demonstrates that size balanced preferred content does not get out
# of balance when used with cluster nodes.
-- Size balanced preferred content sim with multiple repositories sending
-- concurrently to the same repositories, in a cluster.
--
-- This demonstrates that size balanced preferred content does not get out
-- of balance when used with cluster nodes.
init foo
init bar
init node1

View file

@ -1,9 +1,9 @@
# Size balanced preferred content sim with multiple repositories sending
# concurrently to the same repositories, without communication.
#
# This demonstrates how size balanced preferred content can get out of
# balance in this situation. Since there is no random seed, each
# git-annex sim start of this file will display a different result.
-- Size balanced preferred content sim with multiple repositories sending
-- concurrently to the same repositories, without communication.
--
-- This demonstrates how size balanced preferred content can get out of
-- balance in this situation. Since there is no random seed, each
-- git-annex sim start of this file will display a different result.
init foo
init fii
init fum
@ -56,6 +56,6 @@ connect fum <- foo -> fii
action foo gitpull fii
action foo gitpull fum
visit foo git-annex maxsize
#rebalance on
#step 100
#visit foo echo "after rebalance:"; git-annex maxsize
--rebalance on
--step 100
--visit foo echo "after rebalance:"; git-annex maxsize