diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_OutOfRangeArgument01.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/codepage/E_InvalidArgument.fs
similarity index 100%
rename from tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_OutOfRangeArgument01.fs
rename to tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/codepage/E_InvalidArgument.fs
diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/Functional01.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/codepage/ReferenceBoth.fs
similarity index 71%
rename from tests/fsharpqa/Source/CompilerOptions/fsc/codepage/Functional01.fs
rename to tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/codepage/ReferenceBoth.fs
index 382cf1b56a..f8294b88ce 100644
--- a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/Functional01.fs
+++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/codepage/ReferenceBoth.fs
@@ -1,6 +1,6 @@
// #NoMT #CompilerOptions
// This test is designed to test the --codepage options.
-// - The same source file (FunctionalLibrary01.fs) is compile twice, with different --codepage options
+// - The same source file (libCodepage.fs) is compile twice, with different --codepage options
// - The library file is designed so that it gets compiled to slightly different assemblies
// - This file references both assemblies and should compile without problems
//
@@ -10,4 +10,4 @@
let a = N.M.á.M()
let b = N.M.б.M()
-(if a = b then 0 else 1) |> exit
+if a = b then () else failwith "Failed: 1"
\ No newline at end of file
diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/Zero.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/codepage/Zero.fs
similarity index 79%
rename from tests/fsharpqa/Source/CompilerOptions/fsc/codepage/Zero.fs
rename to tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/codepage/Zero.fs
index 55e151c551..c96e994946 100644
--- a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/Zero.fs
+++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/codepage/Zero.fs
@@ -7,4 +7,4 @@
let x = "a"
let y = 'a'.ToString();
-(if x = y then 0 else 1) |> exit
+if x = y then () else failwith "Failed: 1"
\ No newline at end of file
diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/codepage/codepage.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/codepage/codepage.fs
new file mode 100644
index 0000000000..5145fa4dcd
--- /dev/null
+++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/codepage/codepage.fs
@@ -0,0 +1,206 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
+
+namespace FSharp.Compiler.ComponentTests.CompilerOptions.fsc
+
+open Xunit
+open FSharp.Test
+open FSharp.Test.Compiler
+open System
+open System.IO
+
+module codepage =
+
+ let libCodepage1250 =
+ FsFromPath (Path.Combine(__SOURCE_DIRECTORY__, "libCodepage.fs"))
+ |> withCodepage "1250"
+ |> withName "libCodepage1250"
+ |> asLibrary
+
+ let libCodepage1251 =
+ FsFromPath (Path.Combine(__SOURCE_DIRECTORY__, "libCodepage.fs"))
+ |> withCodepage "1251"
+ |> withName "libCodepage1251"
+ |> asLibrary
+
+ let secondLibCodepage1250 =
+ FsFromPath (Path.Combine(__SOURCE_DIRECTORY__, "libCodepage.fs"))
+ |> withCodepage "1250"
+ |> withName "secondLibCodepage1250"
+ |> asLibrary
+
+
+#if NETFRAMEWORK
+
+ []
+ let ``Reference assembly compiled with same codepages`` compilation =
+ compilation
+ |> asExe
+ |> withReferences [ libCodepage1250; secondLibCodepage1250 ]
+ |> compile
+ |> shouldFail
+ |> withDiagnostics [
+ (Error 39, Line 11, Col 13, Line 11, Col 14, "The value, constructor, namespace or type 'б' is not defined.")
+ ]
+
+ []
+ let ``Reference assembly compiled with different codepages`` compilation =
+ compilation
+ |> asExe
+ |> withReferences [ libCodepage1250; libCodepage1251 ]
+ |> compileAndRun
+ |> shouldSucceed
+#endif
+
+ //# Boundary case
+ // SOURCE=E_NoDataForEncoding65535.fs SCFLAGS="--codepage:65535" # E_NoDataForEncoding65535.fs
+ []
+ let ``Reference assembly compiled with no data for codepage`` compilation =
+ compilation
+ |> withCodepage "65535"
+ |> asExe
+ |> compile
+ |> shouldFail
+ |> withDiagnostics [
+ (Error 193, Line 1, Col 1, Line 1, Col 1, "No data is available for encoding 65535. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.")
+ ]
+
+ //# Boundary case
+ // SOURCE=Zero.fs SCFLAGS="--codepage:0x0" # Zero.fs
+ []
+ let ``Reference assembly compiled with zero for codepage`` compilation =
+ compilation
+ |> withNoWarn 52
+ |> withCodepage "0x0"
+ |> asExe
+ |> compileAndRun
+ |> shouldSucceed
+
+
+//# Negative cases
+ // SOURCE=E_OutOfRangeArgument01.fs SCFLAGS="--codepage:65536" # E_OutOfRangeArgument01.fs
+ []
+ let ``OutOfRangeArgument01_fs`` compilation =
+ compilation
+ |> asExe
+ |> withCodepage "65536"
+ |> compile
+ |> shouldFail
+ |> withDiagnostics [
+#if NETFRAMEWORK
+ (Error 1000, Line 0, Col 1, Line 0, Col 1, "Problem with codepage '65536': Valid values are between 0 and 65535, inclusive.
+Parameter name: codepage")
+#else
+ (Error 1000, Line 0, Col 1, Line 0, Col 1, "Problem with codepage '65536': Valid values are between 0 and 65535, inclusive. (Parameter 'codepage')")
+#endif
+ ]
+
+ // SOURCE=E_OutOfRangeArgument01.fs SCFLAGS="--codepage:65536" FSIMODE=EXEC # E_OutOfRangeArgument01.fs-fsi
+ []
+ let ``E_OutOfRangeArgument01_fsx`` compilation =
+ compilation
+ |> asFsx
+ |> withCodepage "65536"
+ |> compile
+ |> shouldFail
+ |> withDiagnostics [
+#if NETFRAMEWORK
+ (Error 1000, Line 0, Col 1, Line 0, Col 1, "Problem with codepage '65536': Valid values are between 0 and 65535, inclusive.
+Parameter name: codepage")
+#else
+ (Error 1000, Line 0, Col 1, Line 0, Col 1, "Problem with codepage '65536': Valid values are between 0 and 65535, inclusive. (Parameter 'codepage')")
+#endif
+ ]
+
+ // SOURCE=E_NegativeArgument01.fs SCFLAGS="--codepage:-1" # E_NegativeArgument01.fs
+ []
+ let ``E_NegativeArgument01_fs`` compilation =
+ compilation
+ |> asExe
+ |> withCodepage "-1"
+ |> compile
+ |> shouldFail
+ |> withDiagnostics [
+#if NETFRAMEWORK
+ (Error 1000, Line 0, Col 1, Line 0, Col 1, "Problem with codepage '-1': Valid values are between 0 and 65535, inclusive.
+Parameter name: codepage")
+#else
+ (Error 1000, Line 0, Col 1, Line 0, Col 1, "Problem with codepage '-1': Valid values are between 0 and 65535, inclusive. (Parameter 'codepage')")
+#endif
+ ]
+
+ // SOURCE=E_NegativeArgument01.fs SCFLAGS="--codepage:-1" FSIMODE=EXEC # E_NegativeArgument01.fs-fsi
+ []
+ let ``E_NegativeArgument01_fsx`` compilation =
+ compilation
+ |> asFsx
+ |> withCodepage "-1"
+ |> compile
+ |> shouldFail
+ |> withDiagnostics [
+#if NETFRAMEWORK
+ (Error 1000, Line 0, Col 1, Line 0, Col 1, "Problem with codepage '-1': Valid values are between 0 and 65535, inclusive.
+Parameter name: codepage")
+#else
+ (Error 1000, Line 0, Col 1, Line 0, Col 1, "Problem with codepage '-1': Valid values are between 0 and 65535, inclusive. (Parameter 'codepage')")
+#endif
+ ]
+
+ // SOURCE=E_NotAValidInteger01.fs SCFLAGS="--codepage:invalidinteger" # E_NotAValidInteger01.fs
+ []
+ let ``E_NotAValidInteger01_fs`` compilation =
+ compilation
+ |> asExe
+ |> withCodepage "invalidinteger"
+ |> compile
+ |> shouldFail
+ |> withDiagnostics [
+ (Error 241, Line 0, Col 1, Line 0, Col 1, "'invalidinteger' is not a valid integer argument")
+ ]
+
+ // SOURCE=E_NotAValidInteger01.fs SCFLAGS="--codepage:invalidinteger" FSIMODE=EXEC # E_NotAValidInteger01.fs-fsi
+ []
+ let ``E_NotAValidInteger01_fsx`` compilation =
+ compilation
+ |> asFsx
+ |> withCodepage "invalidinteger"
+ |> compile
+ |> shouldFail
+ |> withDiagnostics [
+ (Error 241, Line 0, Col 1, Line 0, Col 1, "'invalidinteger' is not a valid integer argument")
+ ]
+
+ // SOURCE=E_RequiresParameter01.fs TAILFLAGS="--codepage" # E_RequiresParameter01.fs
+ []
+ let ``E_RequiresParameter01_fs`` compilation =
+ compilation
+ |> asExe
+ |> withOptions ["--codepage"]
+ |> compile
+ |> shouldFail
+ |> withDiagnostics [
+ (Error 224, Line 0, Col 1, Line 0, Col 1, "Option requires parameter: --codepage:")
+ ]
+
+// SOURCE=E_RequiresParameter01.fs TAILFLAGS="--codepage" FSIMODE=EXEC # E_RequiresParameter01.fs-fsi
+ []
+ let ``E_RequiresParameter01_fsx`` compilation =
+ compilation
+ |> asFsx
+ |> withOptions ["--codepage"]
+ |> compile
+ |> shouldFail
+ |> withDiagnostics [
+ (Error 224, Line 0, Col 1, Line 0, Col 1, "Option requires parameter: --codepage:")
+ ]
+
+ // SOURCE=E_DefaultCodePage02.fsx COMPILE_ONLY=1 # E_DefaultCodePage02.fsx
+ []
+ let ``libCodepage_fs`` compilation =
+ compilation
+ |> asLibrary
+ |> compile
+ |> shouldFail
+ |> withDiagnostics [
+ (Error 10, Line 7, Col 10, Line 7, Col 11, "Unexpected character '�' in type name")
+ (Error 10, Line 9, Col 14, Line 9, Col 17, "Unexpected keyword 'end' in implementation file")
+ ]
diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/FunctionalLibrary01.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/codepage/libCodepage.fs
similarity index 90%
rename from tests/fsharpqa/Source/CompilerOptions/fsc/codepage/FunctionalLibrary01.fs
rename to tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/codepage/libCodepage.fs
index 8300dbef32..c3083e013b 100644
--- a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/FunctionalLibrary01.fs
+++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/codepage/libCodepage.fs
@@ -3,7 +3,7 @@
namespace N
-module M =
+module M =
type á = class
static member M() = 11
end
diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj
index c244723eb7..3c836afa30 100644
--- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj
+++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj
@@ -191,6 +191,7 @@
+
diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs
index 8ea26ea602..c65ee3b130 100644
--- a/tests/FSharp.Test.Utilities/Compiler.fs
+++ b/tests/FSharp.Test.Utilities/Compiler.fs
@@ -354,6 +354,9 @@ module rec Compiler =
| FS fs -> FS { fs with Options = fs.Options @ options }
| _ -> failwith message
+ let withCodepage (codepage:string) (cUnit: CompilationUnit) : CompilationUnit =
+ withOptionsHelper [ $"--codepage:{codepage}" ] "codepage is only supported on F#" cUnit
+
let withDebug (cUnit: CompilationUnit) : CompilationUnit =
withOptionsHelper [ "--debug+" ] "debug+ is only supported on F#" cUnit
diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_DefaultCodePage02.fsx b/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_DefaultCodePage02.fsx
deleted file mode 100644
index 63014ebf57..0000000000
--- a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_DefaultCodePage02.fsx
+++ /dev/null
@@ -1,9 +0,0 @@
-// #NoMT #CompilerOptions
-//Unexpected keyword 'end' in implementation file$
-//Unexpected character '\?' in type name$
-namespace N
-
-module M =
- type á = class
- static member M() = 11
- end
diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_NegativeArgument01.fs b/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_NegativeArgument01.fs
deleted file mode 100644
index 8f28f874ad..0000000000
--- a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_NegativeArgument01.fs
+++ /dev/null
@@ -1,9 +0,0 @@
-// #Regression #NoMT #CompilerOptions
-// --codepage -1
-// Actual message is: error FS0191: Valid values are between 0 and 65535, inclusive.
-// Parameter Name: codepage
-// but is is localized!
-//Problem with codepage '-1': Valid values are between 0 and 65535, inclusive
-
-
-exit 1
diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_NoDataForEncoding65535.fs b/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_NoDataForEncoding65535.fs
deleted file mode 100644
index f6fa59d83b..0000000000
--- a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_NoDataForEncoding65535.fs
+++ /dev/null
@@ -1,7 +0,0 @@
-// #Regression #NoMT #CompilerOptions
-// --codepage 65535
-// Actual message is localized: No data is available for encoding 65535
-//65535
-#light
-
-exit 1
diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_NotAValidInteger01.fs b/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_NotAValidInteger01.fs
deleted file mode 100644
index f310dde0fd..0000000000
--- a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_NotAValidInteger01.fs
+++ /dev/null
@@ -1,6 +0,0 @@
-// #Regression #NoMT #CompilerOptions
-// --codepage foo
-//'foo' is not a valid integer argument
-#light
-
-exit 1
diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_RequiresParameter01.fs b/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_RequiresParameter01.fs
deleted file mode 100644
index 457373ce6f..0000000000
--- a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_RequiresParameter01.fs
+++ /dev/null
@@ -1,6 +0,0 @@
-// #Regression #NoMT #CompilerOptions
-// --codepage (not followed by anything)
-//Option requires parameter: --codepage:
-#light
-
-exit 1
diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_UnrecognizedArgument01.fs b/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_UnrecognizedArgument01.fs
deleted file mode 100644
index d7d98fbdb3..0000000000
--- a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/E_UnrecognizedArgument01.fs
+++ /dev/null
@@ -1,6 +0,0 @@
-// #Regression #NoMT #CompilerOptions
-// See bug FSHARP1.0:3901 (and update this test when it is fixed)
-//Unrecognized argument: --codepage
-#light
-
-exit 1
diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/MatchingCodePage01.fsx b/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/MatchingCodePage01.fsx
deleted file mode 100644
index d4ca66733d..0000000000
--- a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/MatchingCodePage01.fsx
+++ /dev/null
@@ -1,4 +0,0 @@
-// #NoMT #CompilerOptions
-#load "FunctionalLibrary01.fs";;
-#q;;
-//
diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/env.lst b/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/env.lst
deleted file mode 100644
index b80eac641b..0000000000
--- a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/env.lst
+++ /dev/null
@@ -1,34 +0,0 @@
-
-# Verify that value must be between 0 and 65535
-# Functional:
-# Same source file, parsed with different codepage options
-
- SOURCE=FunctionalLibrary01.fs COMPILE_ONLY=1 SCFLAGS="-a --codepage:1250 -o:A1250.dll" # FunctionalLibrary01.fs-A1250
- SOURCE=FunctionalLibrary01.fs COMPILE_ONLY=1 SCFLAGS="-a --codepage:1251 -o:A1251.dll" # FunctionalLibrary01.fs-A1251
- SOURCE=Functional01.fs SCFLAGS="-r:A1250.dll -r:A1251.dll" # Functional01.fs
-
-# Boundary cases:
-# 0, 65535
-# Hex num
- SOURCE=E_NoDataForEncoding65535.fs SCFLAGS="--codepage:65535" # E_NoDataForEncoding65535.fs
- SOURCE=Zero.fs SCFLAGS="--codepage:0x0" # Zero.fs
-
-# Negative cases:
-# String
-# -1, 65536
-# Not specified
- SOURCE=E_OutOfRangeArgument01.fs SCFLAGS="--codepage:65536" # E_OutOfRangeArgument01.fs
- SOURCE=E_OutOfRangeArgument01.fs SCFLAGS="--codepage:65536" FSIMODE=EXEC # E_OutOfRangeArgument01.fs-fsi
-
- SOURCE=E_NegativeArgument01.fs SCFLAGS="--codepage:-1" # E_NegativeArgument01.fs
- SOURCE=E_NegativeArgument01.fs SCFLAGS="--codepage:-1" FSIMODE=EXEC # E_NegativeArgument01.fs-fsi
-
- SOURCE=E_NotAValidInteger01.fs SCFLAGS="--codepage:foo" # E_NotAValidInteger01.fs
- SOURCE=E_NotAValidInteger01.fs SCFLAGS="--codepage:foo" FSIMODE=EXEC # E_NotAValidInteger01.fs-fsi
-
- SOURCE=E_RequiresParameter01.fs TAILFLAGS="--codepage" # E_RequiresParameter01.fs
- SOURCE=E_RequiresParameter01.fs TAILFLAGS="--codepage" FSIMODE=EXEC # E_RequiresParameter01.fs-fsi
-
- SOURCE=E_DefaultCodePage02.fsx COMPILE_ONLY=1 # E_DefaultCodePage02.fsx
- SOURCE=MatchingCodePage01.fsx COMPILE_ONLY=1 SCFLAGS="--codepage:1250" FSIMODE=EXEC # MatchingCodePage01.fsx
-
diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/keep.lst b/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/keep.lst
deleted file mode 100644
index 9fdd73ba19..0000000000
--- a/tests/fsharpqa/Source/CompilerOptions/fsc/codepage/keep.lst
+++ /dev/null
@@ -1,2 +0,0 @@
-A1250.dll
-A1251.dll
diff --git a/tests/fsharpqa/Source/test.lst b/tests/fsharpqa/Source/test.lst
index 2c9482e246..a8b470a9d2 100644
--- a/tests/fsharpqa/Source/test.lst
+++ b/tests/fsharpqa/Source/test.lst
@@ -5,7 +5,6 @@
# ReqNOCov -- skip this test/suite if we are doing a code coverage run
# ReqENU -- skip this test/suite if we are running on non-ENU (useful to exclude hard-to-localize tests)
-CompilerOptions01,NoMT CompilerOptions\fsc\codepage
CompilerOptions01,NoMT CompilerOptions\fsc\crossoptimize
CompilerOptions01,NoMT,Determinism CompilerOptions\fsc\determinism
CompilerOptions01,NoMT CompilerOptions\fsc\dumpAllCommandLineOptions