Mercurial > evolve
changeset 5611:11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sat, 24 Oct 2020 23:47:01 +0800 |
parents | 57030b9d71c3 |
children | 6576f6bb644b |
files | tests/test-stablesort-branchpoint-criss-cross.t tests/test-stablesort-branchpoint.t tests/test-stablesort-criss-cross.t tests/test-stablesort.t tests/testlib/random-revs.py |
diffstat | 5 files changed, 27 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test-stablesort-branchpoint-criss-cross.t Sat Oct 24 23:26:41 2020 +0800 +++ b/tests/test-stablesort-branchpoint-criss-cross.t Sat Oct 24 23:47:01 2020 +0800 @@ -21,16 +21,6 @@ > done; > } - $ cat << EOF >> random_rev.py - > import random - > import sys - > - > loop = int(sys.argv[1]) - > var = int(sys.argv[2]) - > for x in range(loop): - > print(x + random.randint(0, var)) - > EOF - Check criss cross merge ======================= @@ -708,7 +698,7 @@ updating to branch default 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd crisscross_random - $ for x in `python ../random_rev.py 50 44`; do + $ for x in `python "$TESTDIR/testlib/random-revs.py" 50 44`; do > # using python to benefit from the random seed > hg pull -r $x --quiet > done;
--- a/tests/test-stablesort-branchpoint.t Sat Oct 24 23:26:41 2020 +0800 +++ b/tests/test-stablesort-branchpoint.t Sat Oct 24 23:47:01 2020 +0800 @@ -23,16 +23,6 @@ > done; > } - $ cat << EOF >> random_rev.py - > import random - > import sys - > - > loop = int(sys.argv[1]) - > var = int(sys.argv[2]) - > for x in range(loop): - > print(x + random.randint(0, var)) - > EOF - Basic tests =========== (no criss cross merge) @@ -667,7 +657,7 @@ updating to branch default 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd recursion_random - $ for x in `python ../random_rev.py 15 5`; do + $ for x in `python "$TESTDIR/testlib/random-revs.py" 15 5`; do > # using python to benefit from the random seed > hg pull -r $x --quiet > done;
--- a/tests/test-stablesort-criss-cross.t Sat Oct 24 23:26:41 2020 +0800 +++ b/tests/test-stablesort-criss-cross.t Sat Oct 24 23:47:01 2020 +0800 @@ -21,16 +21,6 @@ > done; > } - $ cat << EOF >> random_rev.py - > import random - > import sys - > - > loop = int(sys.argv[1]) - > var = int(sys.argv[2]) - > for x in range(loop): - > print(x + random.randint(0, var)) - > EOF - Check criss cross merge ======================= @@ -820,7 +810,7 @@ updating to branch default 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd crisscross_random - $ for x in `python ../random_rev.py 50 44`; do + $ for x in `python "$TESTDIR/testlib/random-revs.py" 50 44`; do > # using python to benefit from the random seed > hg pull -r $x --quiet > done;
--- a/tests/test-stablesort.t Sat Oct 24 23:26:41 2020 +0800 +++ b/tests/test-stablesort.t Sat Oct 24 23:47:01 2020 +0800 @@ -24,16 +24,6 @@ > done; > } - $ cat << EOF >> random_rev.py - > import random - > import sys - > - > loop = int(sys.argv[1]) - > var = int(sys.argv[2]) - > for x in range(loop): - > print(x + random.randint(0, var)) - > EOF - Basic tests =========== (no criss cross merge) @@ -822,7 +812,7 @@ updating to branch default 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd recursion_random - $ for x in `python ../random_rev.py 15 5`; do + $ for x in `python "$TESTDIR/testlib/random-revs.py" 15 5`; do > # using python to benefit from the random seed > hg pull -r $x --quiet > done;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/testlib/random-revs.py Sat Oct 24 23:47:01 2020 +0800 @@ -0,0 +1,23 @@ +#!/usr/bin/env python +""" +This simple script outputs a sequence of numbers separated by newlines. The +amount of numbers and their approximate values can be controlled by two command +line arguments. + +Usage: $0 COUNT MAXADD. COUNT will determine the amount of numbers printed, and +MAXADD will limit the value that will be added to each of those numbers. +""" + +from __future__ import print_function + +import random +import sys + +def main(): + count = int(sys.argv[1]) + maxadd = int(sys.argv[2]) + for x in range(count): + print(x + random.randint(0, maxadd)) + +if __name__ == '__main__': + main()