Repository: reframe-hpc/reframe

Issue:
The Singularity container platform doesn't change automatically to the mounted stage directory
In the Singularity container platform the change to the mounted `stage` directory is done with https://github.com/reframe-hpc/reframe/blob/0d2c11214c914584c754afffac360bfd3c3383f8/reframe/core/containers.py#L257-L258
but `-W` doesn't change the directory like docker or sarus. From `singularity --help`:
```
  -W, --workdir string         working directory to be used for /tmp,
                               /var/tmp and $HOME (if -c/--contain was
                               also used)
```
As a result the test doesn't start in the stage directory. 

Discussion:

Patch:
diff --git a/reframe/core/containers.py b/reframe/core/containers.py
index d108746b..15be3766 100644
--- a/reframe/core/containers.py
+++ b/reframe/core/containers.py
@@ -255,7 +255,7 @@ class Singularity(ContainerPlatform):
             run_opts.append('--nv')
 
         if self.workdir:
-            run_opts.append(f'-W {self.workdir}')
+            run_opts.append(f'--pwd {self.workdir}')
 
         run_opts += self.options
         if self.command:


Test patch:
diff --git a/unittests/test_containers.py b/unittests/test_containers.py
index 6518781c..ea713465 100644
--- a/unittests/test_containers.py
+++ b/unittests/test_containers.py
@@ -104,15 +104,15 @@ def expected_cmd_mount_points(container_variant):
     elif container_variant in {'Singularity', 'Singularity+nopull'}:
         return ('singularity exec -B"/path/one:/one" '
                 '-B"/path/two:/two" -B"/foo:/rfm_workdir" '
-                '-W /rfm_workdir image:tag cmd')
+                '--pwd /rfm_workdir image:tag cmd')
     elif container_variant == 'Singularity+cuda':
         return ('singularity exec -B"/path/one:/one" '
                 '-B"/path/two:/two" -B"/foo:/rfm_workdir" --nv '
-                '-W /rfm_workdir image:tag cmd')
+                '--pwd /rfm_workdir image:tag cmd')
     elif container_variant == 'Singularity+nocommand':
         return ('singularity run -B"/path/one:/one" '
                 '-B"/path/two:/two" -B"/foo:/rfm_workdir" '
-                '-W /rfm_workdir image:tag')
+                '--pwd /rfm_workdir image:tag')
 
 
 @pytest.fixture
@@ -265,7 +265,7 @@ def expected_run_with_workdir(container_variant_noopt):
             '--foo image:tag cmd1'
         )
     elif container_variant_noopt == 'Singularity':
-        return ('singularity exec -B\"/foo:/rfm_workdir\" -W foodir '
+        return ('singularity exec -B\"/foo:/rfm_workdir\" --pwd foodir '
                 '--foo image:tag cmd1')