comparison tests/test-run-tests.t @ 47572:da497189a93a

test-run-test: use explicit variables to clarify paths Since $TESTTMP and $TESTDIR are defined for both the main scope and the test run during the test, the situation get confusing. To work around that, we define some new, explicit, variables with the values we needs to keep track of. Differential Revision: https://phab.mercurial-scm.org/D11034
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 09 Jul 2021 13:36:39 +0200
parents 57bdecf4322c
children 05abe1ff1edd
comparison
equal deleted inserted replaced
47571:e9c5c368be17 47572:da497189a93a
1379 ON_END! 1379 ON_END!
1380 1380
1381 Test reusability for third party tools 1381 Test reusability for third party tools
1382 ====================================== 1382 ======================================
1383 1383
1384 $ mkdir "$TESTTMP"/anothertests 1384 $ THISTESTDIR="$TESTDIR"
1385 $ cd "$TESTTMP"/anothertests 1385 $ export THISTESTDIR
1386 $ THISTESTTMP="$TESTTMP"
1387 $ export THISTESTTMP
1388
1389 #if windows
1390
1391 $ NEWTESTDIR="$THISTESTTMP"\\anothertests
1392
1393 #else
1394
1395 $ NEWTESTDIR="$THISTESTTMP"/anothertests
1396
1397 #endif
1398
1399 $ export NEWTESTDIR
1400
1401 $ echo creating some new test in: $NEWTESTDIR
1402 creating some new test in: $TESTTMP\anothertests (windows !)
1403 creating some new test in: $TESTTMP/anothertests (no-windows !)
1404 $ mkdir "$NEWTESTDIR"
1405 $ cd "$NEWTESTDIR"
1386 1406
1387 test that `run-tests.py` can execute hghave, even if it runs not in 1407 test that `run-tests.py` can execute hghave, even if it runs not in
1388 Mercurial source tree. 1408 Mercurial source tree.
1389 1409
1390 $ cat > test-hghave.t <<EOF 1410 $ cat > test-hghave.t <<EOF
1398 # Ran 1 tests, 0 skipped, 0 failed. 1418 # Ran 1 tests, 0 skipped, 0 failed.
1399 1419
1400 test that RUNTESTDIR refers the directory, in which `run-tests.py` now 1420 test that RUNTESTDIR refers the directory, in which `run-tests.py` now
1401 running is placed. 1421 running is placed.
1402 1422
1423
1403 $ cat > test-runtestdir.t <<EOF 1424 $ cat > test-runtestdir.t <<EOF
1404 > - $TESTDIR, in which test-run-tests.t is placed 1425 > # \$THISTESTDIR, in which test-run-tests.t (this test file) is placed
1405 > - \$TESTDIR, in which test-runtestdir.t is placed (expanded at runtime) 1426 > # \$THISTESTTMP, in which test-run-tests.t (this test file) is placed
1406 > - \$RUNTESTDIR, in which run-tests.py is placed (expanded at runtime) 1427 > # \$TESTDIR, in which test-runtestdir.t is placed (expanded at runtime)
1428 > # \$RUNTESTDIR, in which run-tests.py is placed (expanded at runtime)
1407 > 1429 >
1408 > #if windows 1430 > $ test "\$TESTDIR" = "\$NEWTESTDIR"
1409 > $ test "\$TESTDIR" = "$TESTTMP\\anothertests"
1410 > #else
1411 > $ test "\$TESTDIR" = "$TESTTMP"/anothertests
1412 > #endif
1413 > If this prints a path, that means RUNTESTDIR didn't equal 1431 > If this prints a path, that means RUNTESTDIR didn't equal
1414 > TESTDIR as it should have. 1432 > THISTESTDIR as it should have.
1415 > $ test "\$RUNTESTDIR" = "$TESTDIR" || echo "\$RUNTESTDIR" 1433 > $ test "\$RUNTESTDIR" = "\$THISTESTDIR" || echo "\$RUNTESTDIR"
1416 > This should print the start of check-code. If this passes but the 1434 > This should print the start of check-code. If this passes but the
1417 > previous check failed, that means we found a copy of check-code at whatever 1435 > previous check failed, that means we found a copy of check-code at whatever
1418 > RUNTESTSDIR ended up containing, even though it doesn't match TESTDIR. 1436 > RUNTESTSDIR ended up containing, even though it doesn't match THISTESTDIR.
1419 > $ head -n 3 "\$RUNTESTDIR"/../contrib/check-code.py | sed 's@.!.*python3@#!USRBINENVPY@' 1437 > $ head -n 3 "\$RUNTESTDIR"/../contrib/check-code.py | sed 's@.!.*python3@#!USRBINENVPY@'
1420 > #!USRBINENVPY 1438 > #!USRBINENVPY
1421 > # 1439 > #
1422 > # check-code - a style and portability checker for Mercurial 1440 > # check-code - a style and portability checker for Mercurial
1423 > EOF 1441 > EOF