From 2e3a54d485f28ec43baa83f88e7498c27d32f81b Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Thu, 7 Nov 2024 10:41:16 +0900 Subject: [PATCH] XXX Windows test hack --- .github/workflows/build.yml | 33 ++-------------------------- Cargo.lock | 1 + lib/Cargo.toml | 1 + lib/tests/test_local_working_copy.rs | 20 +++++++++++++++-- 4 files changed, 22 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 118f48a702..8ece30c83b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,11 +16,8 @@ jobs: fail-fast: false matrix: # macos-13 is x86; macos-14 is ARM - os: [ubuntu-latest, macos-13, macos-14, windows-latest] + os: [windows-latest] cargo_flags: [""] - include: - - os: ubuntu-latest - cargo_flags: "--all-features" runs-on: ${{ matrix.os }} # TODO FIXME (aseipp): keep the timeout limit to ~15 minutes. this is long @@ -38,32 +35,6 @@ jobs: steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - # The default version of gpg installed on the runners is a version baked in with git - # which only contains the components needed by git and doesn't work for our test cases. - # - # This installs the latest gpg4win version, which is a variation of GnuPG built for - # Windows. - # - # There is some issue with windows PATH max length which is what all the PATH wrangling - # below is for. Please see the below link for where this fix was derived from: - # https://github.com/orgs/community/discussions/24933 - - name: Setup GnuPG [windows] - if: ${{ matrix.os == 'windows-latest' }} - run: | - $env:PATH = "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin" - [Environment]::SetEnvironmentVariable("Path", $env:PATH, "Machine") - choco install --yes gpg4win - echo "C:\Program Files (x86)\Gpg4win\..\GnuPG\bin" >> $env:GITHUB_PATH - - # The default version of openssh on windows server is quite old (8.1) and doesn't have - # all the necessary signing/verification commands available (such as -Y find-principals) - - name: Setup ssh-agent [windows] - if: ${{ matrix.os == 'windows-latest' }} - run: | - Remove-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 - Remove-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 - choco install openssh --pre - - name: Install Rust uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 with: @@ -71,7 +42,7 @@ jobs: - name: Build run: cargo build --workspace --all-targets --verbose ${{ matrix.cargo_flags }} - name: Test - run: cargo test --workspace --all-targets --verbose ${{ matrix.cargo_flags }} + run: cargo test working --workspace --all-targets --verbose ${{ matrix.cargo_flags }} --no-fail-fast -- --show-output env: RUST_BACKTRACE: 1 diff --git a/Cargo.lock b/Cargo.lock index 7cba36cdfa..69bd34fef9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1890,6 +1890,7 @@ dependencies = [ "config", "criterion", "digest", + "dunce", "either", "esl01-renderdag", "futures 0.3.31", diff --git a/lib/Cargo.toml b/lib/Cargo.toml index b75e3bf49b..07a6d3c783 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -42,6 +42,7 @@ chrono-english = { workspace = true } clru = { workspace = true } config = { workspace = true } digest = { workspace = true } +dunce = { workspace = true } either = { workspace = true } futures = { workspace = true } git2 = { workspace = true, optional = true } diff --git a/lib/tests/test_local_working_copy.rs b/lib/tests/test_local_working_copy.rs index d4bd1a2c3f..6856db6ce3 100644 --- a/lib/tests/test_local_working_copy.rs +++ b/lib/tests/test_local_working_copy.rs @@ -1345,7 +1345,7 @@ fn test_check_out_existing_file_symlink_icase_fs(victim_exists: bool) { if victim_exists { std::fs::write(&victim_file_path, "old").unwrap(); } - assert_eq!(workspace_root.join("parent").exists(), victim_exists); + assert_eq!(workspace_root.join("parent").try_exists().unwrap(), victim_exists); let file_path = RepoPath::from_internal_string("PARENT"); let tree = create_tree(repo, &[(file_path, "bad")]); @@ -1364,7 +1364,7 @@ fn test_check_out_existing_file_symlink_icase_fs(victim_exists: bool) { if victim_exists { assert_eq!(std::fs::read(&victim_file_path).unwrap(), b"old"); } else { - assert!(!victim_file_path.exists()); + assert!(!victim_file_path.try_exists().unwrap()); } } @@ -1648,7 +1648,23 @@ fn test_check_out_reserved_file_path_vfat(vfat_path_str: &str, file_path_strs: & let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); std::fs::create_dir(workspace_root.join(".git")).unwrap(); + std::fs::create_dir(workspace_root.join("..git")).unwrap(); + std::fs::create_dir(workspace_root.join("...git")).unwrap(); + std::fs::create_dir(workspace_root.join("....git")).unwrap(); + std::fs::create_dir(workspace_root.join(".....git")).unwrap(); + assert!(workspace_root.join(".jj").exists()); let is_vfat = check_vfat(&workspace_root); + for i in 0..=9 { + for name in ["GIT", "JJ"] { + let path = workspace_root.join(format!("{name}~{i}")); + eprintln!("XXX {} {}", path.display(), path.exists()); + } + } + std::process::Command::new("cmd") + .args(["/c", "dir /x"]) + .current_dir(dunce::simplified(&workspace_root)) + .status() + .unwrap(); let vfat_disk_path = workspace_root.join(vfat_path_str); let file_paths = file_path_strs