Skip to content

Commit

Permalink
Rename dir_separator/path_separator to match GNAT...
Browse files Browse the repository at this point in the history
... in the Python testsuite
  • Loading branch information
mosteo committed Jul 2, 2020
1 parent b2bce1d commit 5575cb9
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 23 deletions.
4 changes: 4 additions & 0 deletions testsuite/drivers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def check_line_in(filename, line):


def path_separator():
return ':' if os.name != 'nt' else ';'


def dir_separator():
return '/' if os.name != 'nt' else '\\'


Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/pin/change-type/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from drivers.alr import run_alr
from drivers.asserts import assert_match
from drivers.helpers import path_separator
from drivers.helpers import dir_separator


def check_version_pin():
Expand All @@ -33,7 +33,7 @@ def check_version_pin():

# Check that it shows as such in the solution
p = run_alr('show', '--solve')
s = re.escape(path_separator()) # platform-dependent
s = re.escape(dir_separator()) # platform-dependent
assert_match('.*Dependencies \(external\):.*'
'libhello\* \(direct,linked'
',pin=.*' + s + 'my_index' + s +
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/pin/dir-crate/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from drivers.alr import run_alr
from drivers.asserts import assert_match
from drivers.helpers import path_separator
from drivers.helpers import dir_separator
from glob import glob

# Retrieve a crate
Expand All @@ -25,7 +25,7 @@
# Pin the hello crate as local dir dependency. The version in the folder is
# different to the one we had in the solution, so this should cause a downgrade
# but with complete solution. Now hello=1 --> libhello=1.1.
run_alr('pin', 'hello', '--use', '..' + path_separator() + target)
run_alr('pin', 'hello', '--use', '..' + dir_separator() + target)

# Verify that hello dependencies are detected and used, and are the ones
# corresponding to the linked dir versions.
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/pin/dir-mismatch/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from drivers.alr import run_alr
from drivers.asserts import assert_match
from drivers.helpers import path_separator
from drivers.helpers import dir_separator
from glob import glob

# Retrieve a crate
Expand All @@ -22,7 +22,7 @@
run_alr('with', 'nothello', '--use', '..')

# Try to repin to a dir with valid crate metadata
p = run_alr('with', 'nothello', '--use', '..' + path_separator() + target,
p = run_alr('with', 'nothello', '--use', '..' + dir_separator() + target,
complain_on_error=False)

# Expected error
Expand Down
1 change: 0 additions & 1 deletion testsuite/tests/pin/pin-dir-with-regular/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from drivers.alr import run_alr
from drivers.asserts import assert_match
from drivers.helpers import path_separator, with_project

# Initialize a workspace, enter, and add a regular dependency
run_alr('init', '--bin', 'xxx')
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/pin/pin-dir/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from drivers.alr import run_alr
from drivers.asserts import assert_match
from drivers.helpers import path_separator, with_project
from drivers.helpers import dir_separator, with_project

# Initialize a workspace, enter, and add a regular dependency
run_alr('init', '--bin', 'xxx')
Expand All @@ -29,7 +29,7 @@
p = run_alr('with', '--solve')
# For this match we don't know where the test is temporarily put, so we skip
# over some parts of the output
s = re.escape(path_separator()) # platform-dependent
s = re.escape(dir_separator()) # platform-dependent
assert_match('.*Dependencies \(external\):.*'
'libhello\* \(direct,linked'
',pin=.*' + s + 'my_index' + s +
Expand Down
1 change: 0 additions & 1 deletion testsuite/tests/setenv/env-during-fetch/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from drivers.alr import run_alr
from drivers.asserts import assert_match
from drivers.helpers import path_separator


def verify_output(text):
Expand Down
9 changes: 4 additions & 5 deletions testsuite/tests/setenv/linked-paths/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from drivers.alr import run_alr
from drivers.asserts import assert_match
from drivers.helpers import path_separator
from drivers.helpers import dir_separator, path_separator

# Initialize test crate
run_alr("init", "--bin", "xxx")
Expand All @@ -18,11 +18,10 @@
run_alr("with", "--use=../my_index/crates/crate_1234")

# Check paths are proper (base and one extra nested)
s = path_separator()
p = run_alr("setenv")
assert_match('export GPR_PROJECT_PATH=".*/my_index/crates/crate_1234'
':.*/my_index/crates/crate_1234/nested/"\n'
'export ALIRE="True"\n'.replace('/', re.escape(path_separator())),
assert_match(('export GPR_PROJECT_PATH=".*/my_index/crates/crate_1234' +
path_separator() + '.*/my_index/crates/crate_1234/nested/"\n' +
'export ALIRE="True"\n').replace('/', re.escape(dir_separator())),
p.out)


Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/with/pin-dir-crate-autodetect/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from drivers.alr import run_alr
from drivers.asserts import assert_match
from drivers.helpers import path_separator
from drivers.helpers import dir_separator
from glob import glob

# Retrieve a crate
Expand All @@ -21,7 +21,7 @@

# Add the directory as pinned crate, with autodetection (no crate given,
# inferred from the crate metadata found at target).
run_alr('with', '--use', '..' + path_separator() + target)
run_alr('with', '--use', '..' + dir_separator() + target)

# Verify that hello^1 is a new dependency and also that hello dependencies are
# in the solution.
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/with/pin-dir-crate/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from drivers.alr import run_alr
from drivers.asserts import assert_match
from drivers.helpers import path_separator
from drivers.helpers import dir_separator
from glob import glob

# Retrieve a crate
Expand All @@ -19,7 +19,7 @@
os.chdir('xxx')

# Pin the hello crate as local dir dependency
run_alr('with', 'hello', '--use', '..' + path_separator() + target)
run_alr('with', 'hello', '--use', '..' + dir_separator() + target)

# Verify that hello dependencies are detected and used
p = run_alr('with', '--solve')
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/with/pin-dir-mismatch/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from drivers.alr import run_alr
from drivers.asserts import assert_match
from drivers.helpers import path_separator
from drivers.helpers import dir_separator
from glob import glob

# Retrieve a crate
Expand All @@ -19,7 +19,7 @@
os.chdir('xxx')

# Try to pin the hello crate as local dir dependency
p = run_alr('with', 'nothello', '--use', '..' + path_separator() + target,
p = run_alr('with', 'nothello', '--use', '..' + dir_separator() + target,
complain_on_error=False)

# Expected error
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/with/pin-dir/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from drivers.alr import run_alr
from drivers.asserts import assert_match
from drivers.helpers import path_separator, with_project
from drivers.helpers import dir_separator, with_project

# Initialize a workspace, enter, and add a pinned dependency
run_alr('init', '--bin', 'xxx')
Expand All @@ -28,7 +28,7 @@
p = run_alr('with', '--solve')
# For this match we don't know where the test is temporarily put, so we skip
# over some parts of the output
s = re.escape(path_separator()) # platform-dependent
s = re.escape(dir_separator()) # platform-dependent
assert_match('.*Dependencies \(external\):.*'
'libhello\* \(direct,linked'
',pin=.*' + s + 'my_index' + s +
Expand Down

0 comments on commit 5575cb9

Please sign in to comment.