diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index d77240cd7..6e8238e78 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -340,3 +340,61 @@ jobs: ${SCCACHE_PATH} --show-stats ${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]" + + test-mock-msvc: + runs-on: windows-2019 + env: + TARGET: x86_64-pc-windows-msvc + SCCACHE_EXE: ${{ github.workspace }}\\target\\x86_64-pc-windows-msvc\\debug\\sccache.exe + SCCACHE_LOG: "trace" + SCCACHE_ERROR_LOG: "${{ github.workspace }}\\server_log.txt" + + steps: + - uses: ilammy/msvc-dev-cmd@v1 + + - name: Clone repository + uses: actions/checkout@v3 + + - name: Install rust + uses: ./.github/actions/rust-toolchain + with: + toolchain: "stable" + target: $TARGET + + - name: Build + run: cargo build --bin sccache --target $env:TARGET --features=openssl/vendored + + - name: Compile MSVC (no cache) + shell: bash + working-directory: ./tests/msvc + run: cl "@args.rsp" + + - name: Start Server + shell: bash + run: $SCCACHE_EXE --start-server + + - name: Compile - Cache Miss + shell: bash + working-directory: ./tests/msvc + run: | + $SCCACHE_EXE "$(where cl.exe)" -c "@args.rsp" + $SCCACHE_EXE --show-stats + $SCCACHE_EXE --show-stats | grep -e "Cache misses\s*[1-9]" + + - name: Compile - Cache Hit + shell: bash + working-directory: ./tests/msvc + run: | + $SCCACHE_EXE "$(where cl.exe)" -c "@args.rsp" + $SCCACHE_EXE --show-stats + $SCCACHE_EXE --show-stats | grep -e "Cache hits\s*[1-9]" + + - name: Stop Server + if: success() || failure() + shell: bash + run: $SCCACHE_EXE --stop-server + + - name: Show Server Log + if: success() || failure() + shell: bash + run: cat "$SCCACHE_ERROR_LOG" diff --git a/src/compiler/msvc.rs b/src/compiler/msvc.rs index e5946f2b8..132f27394 100644 --- a/src/compiler/msvc.rs +++ b/src/compiler/msvc.rs @@ -1167,6 +1167,8 @@ impl<'a> Iterator for ExpandIncludeFile<'a> { } }; + trace!("Expanded response file {:?} to {:?}", file_path, content); + // Parse the response file contents, taking into account quote-wrapped strings and new-line separators. // Special implementation to account for MSVC response file format. let resp_file_args = SplitMsvcResponseFileArgs::from(&content).collect::>(); diff --git a/tests/msvc/args.rsp b/tests/msvc/args.rsp new file mode 100644 index 000000000..8dbf4e012 --- /dev/null +++ b/tests/msvc/args.rsp @@ -0,0 +1 @@ +foo.cpp -Fofoo.o \ No newline at end of file diff --git a/tests/msvc/foo.cpp b/tests/msvc/foo.cpp new file mode 100644 index 000000000..73e2f6af3 --- /dev/null +++ b/tests/msvc/foo.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + std::cout << "Hello World!\n"; + return 0; +}