-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Windows paths in tests of mingw-w64 executables #2105
Conversation
I would be happier if we could isolate these changes to libdispatch/dpathcvt.c |
Since mingw has these peculiarities, we probably need to add a NCPD_MINGW |
Hi @DennisHeimbigner , I do not think this problem can be solved in the dpathcvt code. Only the bash shell (and related POSIX utilities) know the mount points in use, and there is no way for native Windows executables (such as For example, if I have tried to find a solution that is less invasive, and the best I can suggest is to use an alias for |
Is there a run-time library equivalent to pwd -W? |
I don't think there is a run-time library for mingw, apart from the Microsoft C run-time (and some wrapper code defined in the mingw header files). The mingw build environment is based on Cygwin, so the POSIX parts of the environment are linked to a Cygwin-like run-time library. But the executables produced by mingw are intended to work without the Cygwin run-time. This is a deliberate choice by the mingw designers, and I can only speculate that it may be necessary to allow direct use of Microsoft APIs. |
I was looking at this: It seems to me that best solution is to add
to test_common.in and then treat msys/mingw as windows. |
I think the variable has changed to If you have concerns about adding my changes to netcdf, I can patch netcdf in the build script for the mingw-w64-netcdf package. But patches tend to have a limited shelf life, and it may help the netcdf developers to know what is needed by mingw packages (and other software that depends on them, such as R). |
Correct me, but I thought we had two problems with mingw/msys.
Your changes for #1 see a good solution. It is #2 I am concerned about. |
I forgot to answer your question about disabling pathname translations by setting a variable ... The pathname translation already ignores URLs, which is why tests with |
Hi Dennis, you mention #2 above - that isn't one of my PRs. But I do understand the desire to keep changes small and simple, so I have trimmed this PR to the smallest change that still works. |
I am confused. What PR is not yours? |
My assumption is that the programs that get a URL argument will eventually |
The problem is caused by the virtual root directory that bash uses in msys2/mingw. When bash is launched, it mounts the msys2/mingw installation directory (on Windows) as a root directory, so paths inside that directory are referenced by stripping off the root prefix (e.g.
If you have access to an msys2/mingw installation, you could try running a few experiments to see what I mean. Ordinary paths are converted by the shell so they are prefixed by the root directory, but URLs miss out on the automatic conversion. |
|
I can't find any existing environment variables that show the path mappings used by bash (in msys2/mingw). I do like your idea of defining an environment variable inside test_common.in, which could be used in NCpathcvt when converting absolute paths from Unix form to canonical form. Even so, it seems more complicated than defining an alias (or function or variable) for Hopefully you now have a clear idea of what is causing the problem. I'll try to implement whichever solution you think is best. |
Also, it is not correct to assume that |
The problem is that aliasing pwd -R does not go far enough. Probably the only way to get the actual mount points is to parse /etc/fstab, |
Out of curiosity what output do you get when you do the command "mount"? |
Hi Dennis, I was only thinking about solving the problem in bash shell scripts, which is why I used the built-in I wasn't sure if those commands would work outside the msys2 shell, so I tried running
These commands are in the PATH used by the shell and inherited by external commands (including Windows programs). So it would be possible to run the commands in NCpathcvt, if netcdf is built with mingw and the input path is in Unix format (without a drive letter). We would also need to handle cases when the commands are not found, as may occur when netcdf executables are launched outside of the bash shell - in such cases, the Unix path could be used without adding a prefix, because there are no mount points to worry about. The presence of a |
The reason I asked about mount was because it means there is code I could use I noticed that the mount output did not include c:/mingw64, which is the mount point |
c:/mingw64 was just my choice of example from earlier - the difference is not significant. |
It looks like NCpathcvt could discover if it is running under the msys shell by checking the environment variables MSYS and/or MSYSTEM. If one or both of those variables are defined, it would make sense to use |
Refresh my memory: |
From memory, most tests fail if path conversions are disabled by setting |
Sorry for all the questions; I do not have anywhere to install msys/mingw. |
Here is my confusion. The tests that have urls should either use a relative path |
Well in any case let implement your solution (this PR) |
One last question: from where did you download msys2? |
Relative paths should work fine, with or without I suggest that msys2 is growing in importance now, because R has adopted it as their build platform on Windows. You can download msys2 from https://www.msys2.org/wiki/MSYS2-installation . I'm happy to help with a longer-term solution, if you think it would be useful. |
Your PR is confusing. Many of the changes look like stuff we have already done, like nczarr filters. |
I needed to fix a conflict, because my branch was based on unidata/master but we are merging into unidata/main. The only relevant difference was that |
The problem we have is that when there are lots of "irrelevant" changes, we have to look |
Hi @DennisHeimbigner , are we looking at the same changes? The end result of this PR is only a few lines changed in 2 files. Some of the intermediate commits made bigger changes, but I have reverted them. |
Sorry for the confusion. This was probably caused when I merged main into my branch, so that I could fix a conflict. Since then, I started with a clean copy of main and rebased my changes onto it, requiring a forced push into this branch. The end result is a total of 11 lines changed in 2 files. |
@mjwoods thanks for the clarification; I just realized the test workflow was awaiting approval to run; I've triggered that and will review the PR as well, thanks! |
1. Issue Unidata#2043 * FreeBSD build fails because of conflicts in defining the fileno() function. So removed all extern declarations of fileno. 2. Issue Unidata#2124 * There were a couple of problems here. * I was conflating msys with mingw and they need separate handling of paths. So treat mingw like windows. * memio.c was not always writing the full content of the memory to file. Untested fix by properly accounting for zero size writes. * Fix bug when skipping white space in tst_xcache.c 3. Issue Unidata#2105 * On MINGW, bash and other POSIX utilities use a mounted root directory, but executables compiled for Windows do not recognise the mount point. Ensure that Windows paths are used in tests of Windows executables. 4. Issue Unidata#2132 * Apparently the Intel C compiler on OSX defines isnan etc. So disable declaration in dutil.c under that condition. 5. Fix and re-enable test_rcmerge.sh by allowing override of where to look for .rc files 6. CMakeLists.txt suppresses certain ncdump directory tests because of differences in printing floats/doubles. * Extend the list to include those that also fail under mingw. * Suppress the mingw tests in ncdump/Makefile.am
Reviewing this one to determine whether it was incorporated already (or not) and then either incorporating or closing. |
The mingw-w64 environment is designed to produce native Windows software, but it supports build systems based on POSIX-style utilities such as shell scripts. The bash shell provided with mingw-w64 is derived from Cygwin, and it uses Unix-style paths within a root directory tree that is mounted from a Windows directory. When invoking Windows executables, the bash shell automatically converts command arguments that appear to be Unix paths into the Windows format. However, the automatic conversion causes a few problems in netcdf tests.
For example, URLs of the
file://
variety are not converted to Windows format, and the corresponding files are not found by Windows programs because they do not respect the same mount points as the bash shell.Also, some of the netcdf tests compare ideal outputs created by scripts with files created by compiled (Windows) executables, and the automatic path conversions may cause such tests to fail.
To avoid the automatic path conversions, Windows paths can be obtained in the mingw-w64 bash shell using the command
pwd -W
. In this PR, I have added logic intest_common.in
to detect the mingw shell and define the shell variablePWDCMD
to the appropriate form ofpwd
. The variable is then used in place ofpwd
commands in test scripts.The test script
ncdap_test/testpathcvt.sh
required further treatment, because it tests path conversions in a variety of Unix formats, which were failing due to the automatic conversions performed by bash. The conversions by bash are disabled completely by defining the environment variableMSYS2_ARG_CONV_EXCL='*'
.