1
0

desktop-build-paths.spec.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { join, sep } from 'node:path'
  2. import { describe, expect, it } from 'vitest'
  3. import {
  4. desktopTargetBuildPaths,
  5. resolveDesktopBuildTarget,
  6. } from '../scripts/desktop-build-paths.mjs'
  7. describe('desktop build paths', () => {
  8. it('isolates every mutable build directory by complete target', () => {
  9. const arm64 = desktopTargetBuildPaths('mac-arm64')
  10. const x64 = desktopTargetBuildPaths('mac-x64')
  11. const windows = desktopTargetBuildPaths('win-x64')
  12. const mutableKeys = [
  13. 'root',
  14. 'artifacts',
  15. 'runtime',
  16. 'packageSet',
  17. 'dsh',
  18. 'dshPnpm',
  19. 'electron',
  20. 'packedDsh',
  21. 'packedVendor',
  22. 'packedLandlock',
  23. ] as const
  24. for (const key of mutableKeys) {
  25. expect(new Set([arm64[key], x64[key], windows[key]]).size).toBe(3)
  26. }
  27. expect(arm64.artifacts).toContain(join('targets', 'mac-arm64', 'artifacts'))
  28. expect(x64.dsh).toContain(join('targets', 'mac-x64', 'dsh'))
  29. expect(windows.runtime).toContain(join('targets', 'win-x64', 'runtime'))
  30. })
  31. it('shares only the immutable upstream download cache', () => {
  32. const arm64 = desktopTargetBuildPaths('mac-arm64')
  33. const x64 = desktopTargetBuildPaths('mac-x64')
  34. expect(arm64.downloads).toBe(x64.downloads)
  35. expect(arm64.downloads).not.toContain(`${sep}targets${sep}`)
  36. })
  37. it('resolves environment overrides and rejects unsupported targets', () => {
  38. expect(resolveDesktopBuildTarget({
  39. DSH_DESKTOP_TARGET_PLATFORM: 'darwin',
  40. DSH_DESKTOP_TARGET_ARCH: 'x64',
  41. }, 'darwin', 'arm64')).toBe('mac-x64')
  42. expect(resolveDesktopBuildTarget({}, 'win32', 'x64')).toBe('win-x64')
  43. expect(() => resolveDesktopBuildTarget({}, 'linux', 'x64')).toThrow(/unsupported target/u)
  44. expect(() => desktopTargetBuildPaths('linux-x64' as 'mac-x64')).toThrow(/unsupported target/u)
  45. })
  46. })