github.com/atrn/dcc@v0.0.0-20220806184050-4470d2553272/msvc_test.go (about) 1 // dcc - dependency-driven C/C++ compiler front end 2 // 3 // Copyright © A.Newman 2015. 4 // 5 // This source code is released under version 2 of the GNU Public License. 6 // See the file LICENSE for details. 7 // 8 //go:build windows 9 10 package main 11 12 import ( 13 "os" 14 "path/filepath" 15 "testing" 16 ) 17 18 func TestMsvc(t *testing.T) { 19 makeTestDirs(t) 20 defer removeTestDirs(t) 21 22 msvc := &msvcCompiler{} 23 24 sourceFile := filepath.Join(testProjectRootDir, "main.cpp") 25 26 makeFileWithContent(t, sourceFile, `// test source file 27 #include <iostream> 28 int main() { std::cout << "Hello\n"; } 29 `, 30 ) 31 32 objectFile := ObjectFilename(filepath.Base(sourceFile), testProjectRootDir) 33 depsFile := filepath.Join(testProjectRootDir, "main.d") 34 options := []string{"/nologo", "/EHsc", "/W3", "/O2"} 35 err := msvc.Compile(sourceFile, objectFile, depsFile, options, os.Stderr) 36 if err != nil { 37 t.Fatal(err) 38 } 39 }