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
[SR-14579] Unable to import XCTest on Windows #4428
Comments
Comment by Eugene Gubin (JIRA) IIRC location of XCTest should be added to the PATH environment variable. |
Please provide a verbose log of the build and the environment. I suspect that your environment is not setup properly as XCTest works out of the box for me on a number of environments. |
Comment by Jeremy David Giesbrecht (JIRA)
I will try to fish out a full verbose log. |
Comment by Jeremy David Giesbrecht (JIRA) I trimmed the package down to a single target with only one source file, this is the log of D:\a\SDGCornerstone\SDGCornerstone>swift build --verbose
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -print-target-info
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -print-target-info
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -L C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\lib\swift\pm\4_2 -lPackageDescription -sdk C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk -libc MD -swift-version 5 -I C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\lib\swift\pm\4_2 -package-description-version 5.3.0 D:\a\SDGCornerstone\SDGCornerstone\Package.swift -o "C:\Users\RUNNER~1\AppData\Local\Temp\TemporaryDirectory.hWctI3\sdgcornerstone-manifest.exe"
"C:\Users\RUNNER~1\AppData\Local\Temp\TemporaryDirectory.hWctI3\sdgcornerstone-manifest.exe" -handle 39c
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -module-name SDGXCTestUtilities -incremental -emit-dependencies -emit-module -emit-module-path D:\a\SDGCornerstone\SDGCornerstone\.build\x86_64-unknown-windows-msvc\debug\SDGXCTestUtilities.swiftmodule -output-file-map D:\a\SDGCornerstone\SDGCornerstone\.build\x86_64-unknown-windows-msvc\debug\SDGXCTestUtilities.build\output-file-map.json -parse-as-library -c D:\a\SDGCornerstone\SDGCornerstone\Sources\SDGXCTestUtilities\TestCase.swift -I D:\a\SDGCornerstone\SDGCornerstone\.build\x86_64-unknown-windows-msvc\debug -target x86_64-unknown-windows-msvc -swift-version 5 -enable-batch-mode -index-store-path D:\a\SDGCornerstone\SDGCornerstone\.build\x86_64-unknown-windows-msvc\debug\index\store -sdk C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk -libc MD -Onone -enable-testing -g -j2 -DSWIFT_PACKAGE -DDEBUG -module-cache-path D:\a\SDGCornerstone\SDGCornerstone\.build\x86_64-unknown-windows-msvc\debug\ModuleCache -parseable-output
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -frontend -c -primary-file D:\a\SDGCornerstone\SDGCornerstone\Sources\SDGXCTestUtilities\TestCase.swift -emit-module-path D:\a\SDGCornerstone\SDGCornerstone\.build\x86_64-unknown-windows-msvc\debug\SDGXCTestUtilities.build\TestCase~partial.swiftmodule -emit-module-doc-path D:\a\SDGCornerstone\SDGCornerstone\.build\x86_64-unknown-windows-msvc\debug\SDGXCTestUtilities.build\TestCase~partial.swiftdoc -emit-module-source-info-path D:\a\SDGCornerstone\SDGCornerstone\.build\x86_64-unknown-windows-msvc\debug\SDGXCTestUtilities.build\TestCase~partial.swiftsourceinfo -emit-dependencies-path D:\a\SDGCornerstone\SDGCornerstone\.build\x86_64-unknown-windows-msvc\debug\SDGXCTestUtilities.build\TestCase.d -emit-reference-dependencies-path D:\a\SDGCornerstone\SDGCornerstone\.build\x86_64-unknown-windows-msvc\debug\SDGXCTestUtilities.build\TestCase.swiftdeps -target x86_64-unknown-windows-msvc -disable-objc-interop -sdk C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk -I D:\a\SDGCornerstone\SDGCornerstone\.build\x86_64-unknown-windows-msvc\debug -enable-testing -g -module-cache-path D:\a\SDGCornerstone\SDGCornerstone\.build\x86_64-unknown-windows-msvc\debug\ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -enable-anonymous-context-mangled-names -autolink-library oldnames -autolink-library msvcrt -Xcc -D_MT -Xcc -D_DLL -parse-as-library -module-name SDGXCTestUtilities -o D:\a\SDGCornerstone\SDGCornerstone\.build\x86_64-unknown-windows-msvc\debug\SDGXCTestUtilities.build\TestCase.swift.o -index-store-path D:\a\SDGCornerstone\SDGCornerstone\.build\x86_64-unknown-windows-msvc\debug\index\store -index-system-modules
D:\a\SDGCornerstone\SDGCornerstone\Sources\SDGXCTestUtilities\TestCase.swift:15:8: error: no such module 'XCTest'
import XCTest
^ |
Comment by Jeremy David Giesbrecht (JIRA) Actually, never mind about a difference between target tests. My memory failed me. Just now I moved it to a test target and got the same error and essentially the same log, (the only differences being the temporary directory, handle identifier and the fact that the target path moved from `Sources` to `Tests`). |
Comment by Jeremy David Giesbrecht (JIRA) Are we supposed to manually create a
|
The installer creates the environment variables for you. You should relaunch the session after the installation to ensure that all the system changes are picked up. |
I'm going to mark this as resolved for now. If this is still an issue, feel free to re-open it. |
Comment by Jeremy David Giesbrecht (JIRA) This seems to still be an issue in 5.5.1: curl --location ^
https://swift.org/builds/swift-5.5.1-release/windows10/swift-5.5.1-RELEASE/swift-5.5.1-RELEASE-windows10.exe ^
--output %TEMP%\swift-5.5.1-RELEASE-windows10.exe
%TEMP%\swift-5.5.1-RELEASE-windows10.exe /passive
set SDKROOT=C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk
echo SDKROOT=%SDKROOT%>>%GITHUB_ENV%
copy %SDKROOT%\usr\share\ucrt.modulemap "%UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt\module.modulemap"
copy %SDKROOT%\usr\share\visualc.modulemap "%VCToolsInstallDir%\include\module.modulemap"
copy %SDKROOT%\usr\share\visualc.apinotes "%VCToolsInstallDir%\include\visualc.apinotes"
copy %SDKROOT%\usr\share\winsdk.modulemap "%UniversalCRTSdkDir%\Include\%UCRTVersion%\um\module.modulemap"
set Path=C:\Library\icu-67\usr\bin;%Path%
set Path=C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin;%Path%
set Path=C:\Library\Swift-development\bin;%Path%
set Path=C:\Library\Developer\Platforms\Windows.platform\Developer\Library\XCTest-development\usr\bin;%Path%
swift --version
swift test (...happily building all sorts of targets... but then suddenly...) error: no such module 'XCTest'
import XCTest
^ Note that despite what the updates to the downloads page say, the module maps must still be copied and the path must still be added to manually. Remove any of that, and the whole thing breaks. That makes me think the core of the issue might have something to do with your comment about relaunching the session. (I am not sitting at a Windows machine, I am only using it remotely for CI tests.) |
Comment by Jeremy David Giesbrecht (JIRA) I found and switched to gha-setup-swift and the problem vanished. |
Environment
Windows 10
Swift 5.4
Additional Detail from JIRA
md5: 67816bae400b324ab24712ed7c9bdd16
Issue Description:
The issue can be evaded by specifying its location manually:
In case it makes a difference, this is in a normal target (not a test target).
The text was updated successfully, but these errors were encountered: