Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
// CodeQL [SM04514] Using MD5 to convert a file path to a fixed length
:
URI
.
file
(
)
}
;
}
function
toWorkspaceBackupInfo
(
:
string
,
?
:
string
)
:
{
return
{
:
{
:
createHash
(
'md5'
)
.
update
(
sanitizePath
(
)
)
.
digest
(
'hex'
)
,
// CodeQL [SM04514] Using MD5 to convert a file path to a fixed length
:
URI
.
file
(
)
}
,
}
;
}
function
toFolderBackupInfo
(
:
URI
,
?
:
string
)
:
{
return
{
:
,
}
;
}
function
toSerializedWorkspace
(
:
)
:
{
return
{
:
.
,
:
.
.
toString
(
)
}
;
}
function
ensureFolderExists
(
:
URI
)
:
Promise
<
void
>
{
if
(
!
.
existsSync
(
.
)
)
{
.
mkdirSync
(
.
)
;
}
const
=
.
toBackupPath
(
)
;
return
createBackupFolder
(
)
;
}
async
function
ensureWorkspaceExists
(
:
)
:
Promise
<
>
{
if
(
!
.
existsSync
(
.
.
)
)
{
await
.
writeFile
(
.
.
,
'Hello'
)
;
}
const
=
.
toBackupPath
(
.
)
;
await
createBackupFolder
(
)
;
return
;
}
async
function
createBackupFolder
(
:
string
)
:
Promise
<
void
>
{
if
(
!
.
existsSync
(
)
)
{
.
mkdirSync
(
)
;
.
mkdirSync
(
.
join
(
,
.
)
)
;
await
.
writeFile
(
.
join
(
,
.
,
'foo.txt'
)
,
'Hello'
)
;
}
}
function
readWorkspacesMetadata
(
)
:
{
return
.
getItem
(
'backupWorkspaces'
)
as
;
}
function
writeWorkspacesMetadata
(
:
string
)
:
void
{
if
(
!
)
{
.
removeItem
(
'backupWorkspaces'
)
;
}
else
{
.
setItem
(
'backupWorkspaces'
,
JSON
.
parse
(
)
)
;
}
}
function
sanitizePath
(
:
string
)
:
string
{
return
.
?
:
.
toLowerCase
(
)
;
}
const
=
URI
.
file
(
.
?
'C:\\foo'
:
'/foo'
)
;
const
=
URI
.
file
(
.
?
'C:\\bar'
:
'/bar'
)
;
let
:
&
{
toBackupPath
(
:
URI
|
string
)
:
string
;
testGetFolderHash
(
:
)
:
string
;
testGetWorkspaceBackups
(
)
:
[
]
;
testGetFolderBackups
(
)
:
[
]
;
}
;
let
:
;
let
:
;
let
:
;
let
:
string
;
let
:
string
;
let
:
URI
;
setup
(
async
(
)
=>
{
=
getRandomTestPath
(
.
tmpdir
(
)
,
'vsctests'
,
'backupmainservice'
)
;
=
.
join
(
,
'Backups'
)
;
=
URI
.
file
(
.
join
(
,
'folder1'
)
)
;
=
new
EnvironmentMainService
(
parseArgs
(
.
,
OPTIONS
)
,
{
:
undefined
,
...
}
)
;
await
.
.
mkdir
(
,
{
:
true
}
)
;
=
new
TestConfigurationService
(
)
;
=
new
InMemoryTestStateMainService
(
)
;
=
new
class
extends
BackupMainService
{
constructor
(
)
{
super
(
,
,
new
LogService
(
new
ConsoleMainLogger
(
)
)
,
)
;
this
.
=
;
}
toBackupPath
(
:
URI
|
string
)
:
string
{
const
=
instanceof
URI
?
super
.
getFolderHash
(
{
:
}
)
:
;
return
.
join
(
this
.
,
)
;
}
testGetFolderHash
(
:
)
:
string
{
return
super
.
getFolderHash
(
)
;
}
testGetWorkspaceBackups
(
)
:
[
]
{
return
super
.
getWorkspaceBackups
(
)
;
}
testGetFolderBackups
(
)
:
[
]
{
return
super
.
getFolderBackups
(
)
;
}
}
;
return
.
initialize
(
)
;
}
)
;
teardown
(
(
)
=>
{
return
.
rm
(
)
;
}
)
;
test
(
'service validates backup workspaces on startup and cleans up (folder workspaces)'
,
async
function
(
)
{
// 1) backup workspace path does not exist
.
registerFolderBackup
(
toFolderBackupInfo
(
)
)
;
.
registerFolderBackup
(
toFolderBackupInfo
(
)
)
;
await
.
initialize
(
)
;
assertEqualFolderInfos
(
.
testGetFolderBackups
(
)
,
[
]
)
;
// 2) backup workspace path exists with empty contents within
.
mkdirSync
(
.
toBackupPath
(
)
)
;
.
mkdirSync
(
.
toBackupPath
(
)
)
;
.
registerFolderBackup
(
toFolderBackupInfo
(
)
)
;
.
registerFolderBackup
(
toFolderBackupInfo
(
)
)
;
await
.
initialize
(
)
;
assertEqualFolderInfos
(
.
testGetFolderBackups
(
)
,
[
]
)
;
.
ok
(
!
.
existsSync
(
.
toBackupPath
(
)
)
)
;
.
ok
(
!
.
existsSync
(
.
toBackupPath
(
)
)
)
;
// 3) backup workspace path exists with empty folders within
.
mkdirSync
(
.
toBackupPath
(
)
)
;
.
mkdirSync
(
.
toBackupPath
(
)
)
;
.
mkdirSync
(
.
join
(
.
toBackupPath
(
)
,
.
)
)
;
.
mkdirSync
(
.
join
(
.
toBackupPath
(
)
,
.
)
)
;
.
registerFolderBackup
(
toFolderBackupInfo
(
)
)
;
.
registerFolderBackup
(
toFolderBackupInfo
(
)
)
;
await
.
initialize
(
)
;
assertEqualFolderInfos
(
.
testGetFolderBackups
(
)
,
[
]
)
;
.
ok
(
!
.
existsSync
(
.
toBackupPath
(
)
)
)
;
.
ok
(
!
.
existsSync
(
.
toBackupPath
(
)
)
)
;
// 4) backup workspace path points to a workspace that no longer exists
// so it should convert the backup worspace to an empty workspace backup
const
=
.
join
(
.
toBackupPath
(
)
,
.
)
;
.
mkdirSync
(
.
toBackupPath
(
)
)
;
.
mkdirSync
(
.
toBackupPath
(
)
)
;
.
mkdirSync
(
)
;
.
registerFolderBackup
(
toFolderBackupInfo
(
)
)
;
.
strictEqual
(
.
testGetFolderBackups
(
)
.
,
1
)
;
.
strictEqual
(
.
getEmptyWindowBackups
(
)
.
,
0
)
;
.
writeFileSync
(
.
join
(
,
'backup.txt'
)
,
''
)
;
await
.
initialize
(
)
;
.
strictEqual
(
.
testGetFolderBackups
(
)
.
,
0
)
;
.
strictEqual
(
.
getEmptyWindowBackups
(
)
.
,
1
)
;
}
)
;
test
(
'service validates backup workspaces on startup and cleans up (root workspaces)'
,
async
function
(
)
{
// 1) backup workspace path does not exist
.
registerWorkspaceBackup
(
toWorkspaceBackupInfo
(
.
)
)
;
.
registerWorkspaceBackup
(
toWorkspaceBackupInfo
(
.
)
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
// 2) backup workspace path exists with empty contents within
.
mkdirSync
(
.
toBackupPath
(
)
)
;
.
mkdirSync
(
.
toBackupPath
(
)
)
;
.
registerWorkspaceBackup
(
toWorkspaceBackupInfo
(
.
)
)
;
.
registerWorkspaceBackup
(
toWorkspaceBackupInfo
(
.
)
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
.
ok
(
!
.
existsSync
(
.
toBackupPath
(
)
)
)
;
.
ok
(
!
.
existsSync
(
.
toBackupPath
(
)
)
)
;
// 3) backup workspace path exists with empty folders within
.
mkdirSync
(
.
toBackupPath
(
)
)
;
.
mkdirSync
(
.
toBackupPath
(
)
)
;
.
mkdirSync
(
.
join
(
.
toBackupPath
(
)
,
.
)
)
;
.
mkdirSync
(
.
join
(
.
toBackupPath
(
)
,
.
)
)
;
.
registerWorkspaceBackup
(
toWorkspaceBackupInfo
(
.
)
)
;
.
registerWorkspaceBackup
(
toWorkspaceBackupInfo
(
.
)
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
.
ok
(
!
.
existsSync
(
.
toBackupPath
(
)
)
)
;
.
ok
(
!
.
existsSync
(
.
toBackupPath
(
)
)
)
;
// 4) backup workspace path points to a workspace that no longer exists
// so it should convert the backup worspace to an empty workspace backup
const
=
.
join
(
.
toBackupPath
(
)
,
.
)
;
.
mkdirSync
(
.
toBackupPath
(
)
)
;
.
mkdirSync
(
.
toBackupPath
(
)
)
;
.
mkdirSync
(
)
;
.
registerWorkspaceBackup
(
toWorkspaceBackupInfo
(
.
)
)
;
.
strictEqual
(
.
testGetWorkspaceBackups
(
)
.
,
1
)
;
.
strictEqual
(
.
getEmptyWindowBackups
(
)
.
,
0
)
;
.
writeFileSync
(
.
join
(
,
'backup.txt'
)
,
''
)
;
await
.
initialize
(
)
;
.
strictEqual
(
.
testGetWorkspaceBackups
(
)
.
,
0
)
;
.
strictEqual
(
.
getEmptyWindowBackups
(
)
.
,
1
)
;
}
)
;
test
(
'service supports to migrate backup data from another location'
,
async
(
)
=>
{
const
=
.
toBackupPath
(
)
;
.
mkdirSync
(
)
;
.
writeFileSync
(
.
join
(
,
'backup.txt'
)
,
'Some Data'
)
;
.
registerFolderBackup
(
toFolderBackupInfo
(
URI
.
file
(
)
)
)
;
const
=
await
.
registerWorkspaceBackup
(
toWorkspaceBackupInfo
(
.
)
,
)
;
.
ok
(
.
existsSync
(
)
)
;
.
ok
(
.
existsSync
(
.
join
(
,
'backup.txt'
)
)
)
;
.
ok
(
!
.
existsSync
(
)
)
;
const
=
.
getEmptyWindowBackups
(
)
;
.
strictEqual
(
0
,
.
)
;
}
)
;
test
(
'service backup migration makes sure to preserve existing backups'
,
async
(
)
=>
{
const
=
.
toBackupPath
(
)
;
.
mkdirSync
(
)
;
.
writeFileSync
(
.
join
(
,
'backup.txt'
)
,
'Some Data'
)
;
.
registerFolderBackup
(
toFolderBackupInfo
(
URI
.
file
(
)
)
)
;
const
=
.
toBackupPath
(
)
;
.
mkdirSync
(
)
;
.
writeFileSync
(
.
join
(
,
'backup.txt'
)
,
'Some Data'
)
;
.
registerFolderBackup
(
toFolderBackupInfo
(
URI
.
file
(
)
)
)
;
const
=
await
.
registerWorkspaceBackup
(
toWorkspaceBackupInfo
(
.
)
,
)
;
.
ok
(
.
existsSync
(
)
)
;
.
ok
(
.
existsSync
(
.
join
(
,
'backup.txt'
)
)
)
;
.
ok
(
!
.
existsSync
(
)
)
;
const
=
.
getEmptyWindowBackups
(
)
;
.
strictEqual
(
1
,
.
)
;
.
strictEqual
(
1
,
.
readdirSync
(
.
join
(
,
[
0
]
.
)
)
.
)
;
}
)
;
suite
(
'loadSync'
,
(
)
=>
{
test
(
'getFolderBackupPaths() should return [] when workspaces.json doesn\'t exist'
,
(
)
=>
{
assertEqualFolderInfos
(
.
testGetFolderBackups
(
)
,
[
]
)
;
}
)
;
test
(
'getFolderBackupPaths() should return [] when folders in workspaces.json is absent'
,
async
(
)
=>
{
writeWorkspacesMetadata
(
'{}'
)
;
await
.
initialize
(
)
;
assertEqualFolderInfos
(
.
testGetFolderBackups
(
)
,
[
]
)
;
}
)
;
test
(
'getFolderBackupPaths() should return [] when folders in workspaces.json is not a string array'
,
async
(
)
=>
{
writeWorkspacesMetadata
(
'{"folders":{}}'
)
;
await
.
initialize
(
)
;
assertEqualFolderInfos
(
.
testGetFolderBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"folders":{"foo": ["bar"]}}'
)
;
await
.
initialize
(
)
;
assertEqualFolderInfos
(
.
testGetFolderBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"folders":{"foo": []}}'
)
;
await
.
initialize
(
)
;
assertEqualFolderInfos
(
.
testGetFolderBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"folders":{"foo": "bar"}}'
)
;
await
.
initialize
(
)
;
assertEqualFolderInfos
(
.
testGetFolderBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"folders":"foo"}'
)
;
await
.
initialize
(
)
;
assertEqualFolderInfos
(
.
testGetFolderBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"folders":1}'
)
;
await
.
initialize
(
)
;
assertEqualFolderInfos
(
.
testGetFolderBackups
(
)
,
[
]
)
;
}
)
;
test
(
'getFolderBackupPaths() should return [] when files.hotExit = "onExitAndWindowClose"'
,
async
(
)
=>
{
const
=
toFolderBackupInfo
(
URI
.
file
(
.
.
toUpperCase
(
)
)
)
;
.
registerFolderBackup
(
)
;
assertEqualFolderInfos
(
.
testGetFolderBackups
(
)
,
[
]
)
;
.
setUserConfiguration
(
'files.hotExit'
,
.
ON_EXIT_AND_WINDOW_CLOSE
)
;
await
.
initialize
(
)
;
assertEqualFolderInfos
(
.
testGetFolderBackups
(
)
,
[
]
)
;
}
)
;
test
(
'getWorkspaceBackups() should return [] when workspaces.json doesn\'t exist'
,
(
)
=>
{
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
}
)
;
test
(
'getWorkspaceBackups() should return [] when folderWorkspaces in workspaces.json is absent'
,
async
(
)
=>
{
writeWorkspacesMetadata
(
'{}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
}
)
;
test
(
'getWorkspaceBackups() should return [] when rootWorkspaces in workspaces.json is not a object array'
,
async
(
)
=>
{
writeWorkspacesMetadata
(
'{"rootWorkspaces":{}}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"rootWorkspaces":{"foo": ["bar"]}}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"rootWorkspaces":{"foo": []}}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"rootWorkspaces":{"foo": "bar"}}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"rootWorkspaces":"foo"}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"rootWorkspaces":1}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
}
)
;
test
(
'getWorkspaceBackups() should return [] when workspaces in workspaces.json is not a object array'
,
async
(
)
=>
{
writeWorkspacesMetadata
(
'{"workspaces":{}}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"workspaces":{"foo": ["bar"]}}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"workspaces":{"foo": []}}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"workspaces":{"foo": "bar"}}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"workspaces":"foo"}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"workspaces":1}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
}
)
;
test
(
'getWorkspaceBackups() should return [] when files.hotExit = "onExitAndWindowClose"'
,
async
(
)
=>
{
const
=
.
.
toUpperCase
(
)
;
.
registerWorkspaceBackup
(
toWorkspaceBackupInfo
(
)
)
;
.
strictEqual
(
.
testGetWorkspaceBackups
(
)
.
,
1
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
.
map
(
=>
.
.
.
toString
(
)
)
,
[
URI
.
file
(
)
.
toString
(
)
]
)
;
.
setUserConfiguration
(
'files.hotExit'
,
.
ON_EXIT_AND_WINDOW_CLOSE
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
,
[
]
)
;
}
)
;
test
(
'getEmptyWorkspaceBackupPaths() should return [] when workspaces.json doesn\'t exist'
,
(
)
=>
{
.
deepStrictEqual
(
.
getEmptyWindowBackups
(
)
,
[
]
)
;
}
)
;
test
(
'getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is absent'
,
async
(
)
=>
{
writeWorkspacesMetadata
(
'{}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
getEmptyWindowBackups
(
)
,
[
]
)
;
}
)
;
test
(
'getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array'
,
async
function
(
)
{
writeWorkspacesMetadata
(
'{"emptyWorkspaces":{}}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
getEmptyWindowBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"emptyWorkspaces":{"foo": ["bar"]}}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
getEmptyWindowBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"emptyWorkspaces":{"foo": []}}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
getEmptyWindowBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"emptyWorkspaces":{"foo": "bar"}}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
getEmptyWindowBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"emptyWorkspaces":"foo"}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
getEmptyWindowBackups
(
)
,
[
]
)
;
writeWorkspacesMetadata
(
'{"emptyWorkspaces":1}'
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
getEmptyWindowBackups
(
)
,
[
]
)
;
}
)
;
}
)
;
suite
(
'dedupeFolderWorkspaces'
,
(
)
=>
{
test
(
'should ignore duplicates (folder workspace)'
,
async
(
)
=>
{
await
ensureFolderExists
(
)
;
const
:
=
{
:
[
]
,
:
[
{
:
.
toString
(
)
}
,
{
:
.
toString
(
)
}
]
,
:
[
]
}
;
writeWorkspacesMetadata
(
JSON
.
stringify
(
)
)
;
await
.
initialize
(
)
;
const
=
readWorkspacesMetadata
(
)
;
.
deepStrictEqual
(
.
,
[
{
:
.
toString
(
)
}
]
)
;
}
)
;
test
(
'should ignore duplicates on Windows and Mac (folder workspace)'
,
async
(
)
=>
{
await
ensureFolderExists
(
)
;
const
:
=
{
:
[
]
,
:
[
{
:
.
toString
(
)
}
,
{
:
.
toString
(
)
.
toLowerCase
(
)
}
]
,
:
[
]
}
;
writeWorkspacesMetadata
(
JSON
.
stringify
(
)
)
;
await
.
initialize
(
)
;
const
=
readWorkspacesMetadata
(
)
;
.
deepStrictEqual
(
.
,
[
{
:
.
toString
(
)
}
]
)
;
}
)
;
test
(
'should ignore duplicates on Windows and Mac (root workspace)'
,
async
(
)
=>
{
const
=
.
join
(
,
'Foo.code-workspace'
)
;
const
=
.
join
(
,
'FOO.code-workspace'
)
;
const
=
.
join
(
,
'foo.code-workspace'
)
;
const
=
await
ensureWorkspaceExists
(
toWorkspace
(
)
)
;
const
=
await
ensureWorkspaceExists
(
toWorkspace
(
)
)
;
const
=
await
ensureWorkspaceExists
(
toWorkspace
(
)
)
;
const
:
=
{
:
[
,
,
]
.
map
(
)
,
:
[
]
,
:
[
]
}
;
writeWorkspacesMetadata
(
JSON
.
stringify
(
)
)
;
await
.
initialize
(
)
;
const
=
readWorkspacesMetadata
(
)
;
.
strictEqual
(
.
.
,
.
?
3
:
1
)
;
if
(
.
)
{
.
deepStrictEqual
(
.
.
map
(
=>
.
)
,
[
URI
.
file
(
)
.
toString
(
)
,
URI
.
file
(
)
.
toString
(
)
,
URI
.
file
(
)
.
toString
(
)
]
)
;
}
else
{
.
deepStrictEqual
(
.
.
map
(
=>
.
)
,
[
URI
.
file
(
)
.
toString
(
)
]
,
'should return the first duplicated entry'
)
;
}
}
)
;
}
)
;
suite
(
'registerWindowForBackups'
,
(
)
=>
{
test
(
'should persist paths to workspaces.json (folder workspace)'
,
async
(
)
=>
{
.
registerFolderBackup
(
toFolderBackupInfo
(
)
)
;
.
registerFolderBackup
(
toFolderBackupInfo
(
)
)
;
assertEqualFolderInfos
(
.
testGetFolderBackups
(
)
,
[
toFolderBackupInfo
(
)
,
toFolderBackupInfo
(
)
]
)
;
const
=
readWorkspacesMetadata
(
)
;
.
deepStrictEqual
(
.
,
[
{
:
.
toString
(
)
}
,
{
:
.
toString
(
)
}
]
)
;
}
)
;
test
(
'should persist paths to workspaces.json (root workspace)'
,
async
(
)
=>
{
const
=
toWorkspaceBackupInfo
(
.
)
;
.
registerWorkspaceBackup
(
)
;
const
=
toWorkspaceBackupInfo
(
.
)
;
.
registerWorkspaceBackup
(
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
.
map
(
=>
.
.
.
toString
(
)
)
,
[
.
toString
(
)
,
.
toString
(
)
]
)
;
.
strictEqual
(
.
.
,
.
testGetWorkspaceBackups
(
)
[
0
]
.
.
)
;
.
strictEqual
(
.
.
,
.
testGetWorkspaceBackups
(
)
[
1
]
.
.
)
;
const
=
readWorkspacesMetadata
(
)
;
.
deepStrictEqual
(
.
.
map
(
=>
.
)
,
[
.
toString
(
)
,
.
toString
(
)
]
)
;
.
strictEqual
(
.
.
,
.
[
0
]
.
)
;
.
strictEqual
(
.
.
,
.
[
1
]
.
)
;
}
)
;
}
)
;
test
(
'should always store the workspace path in workspaces.json using the case given, regardless of whether the file system is case-sensitive (folder workspace)'
,
async
(
)
=>
{
.
registerFolderBackup
(
toFolderBackupInfo
(
URI
.
file
(
.
.
toUpperCase
(
)
)
)
)
;
assertEqualFolderInfos
(
.
testGetFolderBackups
(
)
,
[
toFolderBackupInfo
(
URI
.
file
(
.
.
toUpperCase
(
)
)
)
]
)
;
const
=
readWorkspacesMetadata
(
)
;
.
deepStrictEqual
(
.
,
[
{
:
URI
.
file
(
.
.
toUpperCase
(
)
)
.
toString
(
)
}
]
)
;
}
)
;
test
(
'should always store the workspace path in workspaces.json using the case given, regardless of whether the file system is case-sensitive (root workspace)'
,
async
(
)
=>
{
const
=
.
.
toUpperCase
(
)
;
.
registerWorkspaceBackup
(
toWorkspaceBackupInfo
(
)
)
;
.
deepStrictEqual
(
.
testGetWorkspaceBackups
(
)
.
map
(
=>
.
.
.
toString
(
)
)
,
[
URI
.
file
(
)
.
toString
(
)
]
)
;
const
=
readWorkspacesMetadata
(
)
;
.
deepStrictEqual
(
.
.
map
(
=>
.
)
,
[
URI
.
file
(
)
.
toString
(
)
]
)
;
}
)
;
suite
(
'getWorkspaceHash'
,
(
)
=>
{
(
.
?
.
:
)
(
'should ignore case on Windows and Mac'
,
(
)
=>
{
const
assertFolderHash
=
(
:
URI
,
:
URI
)
=>
{
.
strictEqual
(
.
testGetFolderHash
(
toFolderBackupInfo
(
)
)
,
.
testGetFolderHash
(
toFolderBackupInfo
(
)
)
)
;
}
;
if
(
.
)
{
assertFolderHash
(
URI
.
file
(
'/foo'
)
,
URI
.
file
(
'/FOO'
)
)
;
}
if
(
.
)
{
assertFolderHash
(
URI
.
file
(
'c:\\foo'
)
,
URI
.
file
(
'C:\\FOO'
)
)
;
}
}
)
;
}
)
;
suite
(
'mixed path casing'
,
(
)
=>
{
test
(
'should handle case insensitive paths properly (registerWindowForBackupsSync) (folder workspace)'
,
(
)
=>
{
.
registerFolderBackup
(
toFolderBackupInfo
(
)
)
;
.
registerFolderBackup
(
toFolderBackupInfo
(
URI
.
file
(
.
.
toUpperCase
(
)
)
)
)
;
if
(
.
)
{
.
strictEqual
(
.
testGetFolderBackups
(
)
.
,
2
)
;
}
else
{
.
strictEqual
(
.
testGetFolderBackups
(
)
.
,
1
)
;
}
}
)
;
test
(
'should handle case insensitive paths properly (registerWindowForBackupsSync) (root workspace)'
,
(
)
=>
{
.
registerWorkspaceBackup
(
toWorkspaceBackupInfo
(
.
)
)
;
.
registerWorkspaceBackup
(
toWorkspaceBackupInfo
(
.
.
toUpperCase
(
)
)
)
;
if
(
.
)
{
.
strictEqual
(
.
testGetWorkspaceBackups
(
)
.
,
2
)
;
}
else
{
.
strictEqual
(
.
testGetWorkspaceBackups
(
)
.
,
1
)
;
}
}
)
;
}
)
;
suite
(
'getDirtyWorkspaces'
,
(
)
=>
{
test
(
'should report if a workspace or folder has backups'