Skip to content

Commit 6c02e62

Browse files
committed
test: adjust the test to improve the viability on Windows
Convert the line endings manually since the parser is sensitive to the trailing whitespace (the writing of the file will create a `\r\n` rather than `\n`). This largely fixes the issues for Windows with the issue that the processing of the file location is currently not properly processing escape characters and results in issues. In theory, it should be possible for `getStringLiteralIfNotInterpolated` to process the literal segments with `getEncodedStringSegment` for each segment and then return a literal value cooked. However, doing so will require that the function return a `std::string` rather than `StringRef` since the cooking means that we cannot simply provide a reference to the SourceManager view.
1 parent 08c4e73 commit 6c02e62

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/SILGen/magic_identifier_file_conflicting.swift.gyb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %gyb -D TEMPDIR=%t %s -o %t/magic_identifier_file_conflicting.swift
2+
// RUN: %gyb -D TEMPDIR=%t %s > %t/magic_identifier_file_conflicting.swift
3+
// RUN: %{python} -c "import sys; t = open(sys.argv[1], 'rb').read().replace('\r\n', '\n'); open(sys.argv[1], 'wb').write(t)" %t/magic_identifier_file_conflicting.swift
34

45
// We want to check both the diagnostics and the SIL output.
56
// RUN: %target-swift-emit-silgen -verify -emit-sorted-sil -enable-experimental-concise-pound-file -module-name Foo %t/magic_identifier_file_conflicting.swift %S/Inputs/magic_identifier_file_conflicting_other.swift | %FileCheck %s
@@ -11,12 +12,14 @@
1112

1213
%{
1314
TEMPDIR_ESC = TEMPDIR.replace('\\', '\\\\')
15+
16+
import os
1417
def fixit_loc(start_col, orig_suffix):
1518
"""
1619
Computes a "start-end" string for a fix-it replacing a string literal which
1720
starts at start_col and joins orig_suffix to TEMPDIR with a slash.
1821
"""
19-
original = '"{0}/{1}"'.format(TEMPDIR, orig_suffix)
22+
original = '"{0}"'.format(os.path.join(TEMPDIR, orig_suffix))
2023
end_col = start_col + len(original)
2124
return '{0}-{1}'.format(start_col, end_col)
2225
}%

0 commit comments

Comments
 (0)