From e8c6ac0d72fe4f4e75490dfbb38d9d39266fcf44 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Wed, 19 May 2021 21:49:32 +0200 Subject: [PATCH] [Frontend] Add test that we can create a module if same filename is used twice and `-experimental-allow-module-with-compiler-errors` is passed --- test/Frontend/Inputs/same_filename/A/File.swift | 1 + test/Frontend/Inputs/same_filename/B/File.swift | 1 + test/Frontend/same_filename_twice.swift | 13 +++++++++++++ 3 files changed, 15 insertions(+) create mode 100644 test/Frontend/Inputs/same_filename/A/File.swift create mode 100644 test/Frontend/Inputs/same_filename/B/File.swift create mode 100644 test/Frontend/same_filename_twice.swift diff --git a/test/Frontend/Inputs/same_filename/A/File.swift b/test/Frontend/Inputs/same_filename/A/File.swift new file mode 100644 index 00000000000..4e6a6de6531 --- /dev/null +++ b/test/Frontend/Inputs/same_filename/A/File.swift @@ -0,0 +1 @@ +class Foo {} diff --git a/test/Frontend/Inputs/same_filename/B/File.swift b/test/Frontend/Inputs/same_filename/B/File.swift new file mode 100644 index 00000000000..bf1673a0911 --- /dev/null +++ b/test/Frontend/Inputs/same_filename/B/File.swift @@ -0,0 +1 @@ +class Bar {} diff --git a/test/Frontend/same_filename_twice.swift b/test/Frontend/same_filename_twice.swift new file mode 100644 index 00000000000..ab624734fa3 --- /dev/null +++ b/test/Frontend/same_filename_twice.swift @@ -0,0 +1,13 @@ +// RUN: %empty-directory(%t) + +// A module should fail to be generated if the same filename is used twice and '-experimental-allow-module-with-compiler-errors' is not passed + +// RUN: not %target-swift-frontend -emit-module -o %t/no_allow_compiler_errors.swiftmodule %S/Inputs/same_filename/A/File.swift %S/Inputs/same_filename/B/File.swift +// RUN: not ls %t/no_allow_compiler_errors.swiftmodule + +// If '-experimental-allow-module-with-compiler-errors' is passed, we should throw an error but still generate a module + +// RUN: %target-swift-frontend -emit-module -experimental-allow-module-with-compiler-errors -o %t/allow_compiler_errors.swiftmodule %S/Inputs/same_filename/A/File.swift %S/Inputs/same_filename/B/File.swift 2>&1 | %FileCheck %s +// RUN: ls %t/allow_compiler_errors.swiftmodule + +// CHECK: filename "File.swift" used twice: