Skip to content

Commit

Permalink
ci: up
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Jun 26, 2024
1 parent b0d6768 commit 1b7238e
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 63 deletions.
7 changes: 5 additions & 2 deletions packages/win32-api/test/root.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import { isWinLocaleChinese } from './util.js'
export const testDir = genCurrentDirname(import.meta.url)
export const baseDir = join(testDir, '..')

export const CI = !! ((process.env['CI']
?? process.env['MIDWAY_SERVER_ENV'] === 'unittest')
export const CI = !! process.env['CI'] // GithubAction
export const TEST = !! (CI
|| process.env['MIDWAY_SERVER_ENV'] === 'unittest'
|| process.env['MIDWAY_SERVER_ENV'] === 'local'
|| process.env['NODE_ENV'] === 'unittest'
|| process.env['NODE_ENV'] === 'local'
Expand All @@ -20,6 +21,7 @@ export interface TestConfig {
testDir: string
testAppDir: string
CI: boolean
TEST: boolean
isWinChinese: boolean
notepadTitle: string
}
Expand All @@ -31,6 +33,7 @@ export const testConfig = {
testDir,
testAppDir,
CI,
TEST,
isWinChinese,
notepadTitle: isWinChinese ? '无标题 - 记事本' : 'Untitled - Notepad',
} as TestConfig
Expand Down
7 changes: 3 additions & 4 deletions packages/win32-def/demo/EnumPrintersW.mts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,19 @@ const lib = ffi.load('winspool.drv')
const func1 = lib.func(
'EnumPrintersW',
D.BOOL,
[D.DWORD, 'str16', D.DWORD, `_Out_ ${S.PPRINTER_INFO_1}`, D.DWORD, D.LPDWORD, D.LPDWORD]
[D.DWORD, 'str16', D.DWORD, `_Out_ ${S.PPRINTER_INFO_1}`, D.DWORD, D.LPDWORD, D.LPDWORD],
)

const func4 = lib.func(
'EnumPrintersW',
D.BOOL,
[D.DWORD, 'str16', D.DWORD, `_Out_ ${S.PPRINTER_INFO_4}`, D.DWORD, D.LPDWORD, D.LPDWORD]
[D.DWORD, 'str16', D.DWORD, `_Out_ ${S.PPRINTER_INFO_4}`, D.DWORD, D.LPDWORD, D.LPDWORD],
)

const flags = PrinterEnumFlags.PRINTER_ENUM_LOCAL
const name = ''

const cbBuf = 4096
assert(cbBuf > 2, 'cbBuf must be > 2')

const printerInfo1 = {} as S.PRINTER_INFO_1_Type
const printerInfo4 = {} as S.PRINTER_INFO_4_Type
Expand Down Expand Up @@ -58,7 +57,7 @@ const ret4 = func4(
pcReturned,
) as number

console.log({ ret1, ret4, printerInfo1, printerInfo4 })
console.info({ ret1, ret4, printerInfo1, printerInfo4 })

assert(ret1, 'EnumPrintersW(PRINTER_INFO_1) failed')
assert(ret4, 'EnumPrintersW(PRINTER_INFO_4) failed')
Expand Down
2 changes: 1 addition & 1 deletion packages/win32-def/test/def.class/20.loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe(fileShortPath(import.meta.url), () => {
const lib = load<Win32>(options)
const { payload: pos } = POINT_Factory()

const res = lib.GetCursorPos(pos)
const res = await lib.GetCursorPos_Async(pos)
assert(res > 0)
console.info({ res, pos })
assert(pos.x >= 0 && pos.y >= 0)
Expand Down
23 changes: 11 additions & 12 deletions packages/win32-def/test/def.class/21.loader-multiple-choice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import type {
PRINTER_INFO_5_Type,
} from '##/index.struct.js'
import { multipleChoiceMapperList, multipleChoiceMapperSet } from '#@/mapper/EnumPrintersW.mapper.js'
import { expectPrinterInfo } from '#@/test.config.js'

import { DefWinspool, Winspool } from './api.helper.js'


describe(fileShortPath(import.meta.url), () => {
const expectName = 'Microsoft Print to PDF'

const flags = PrinterEnumFlags.PRINTER_ENUM_LOCAL
const name = ''
const cbBuf = 4096
Expand Down Expand Up @@ -47,8 +46,8 @@ describe(fileShortPath(import.meta.url), () => {
pcReturned,
)
assert(ret, 'EnumPrintersW(PRINTER_INFO_1) failed')
assert(printerInfo.pName === expectName)
assert(printerInfo.pDescription.includes(expectName))
assert(printerInfo.pName === expectPrinterInfo.name)
assert(printerInfo.pDescription.includes(expectPrinterInfo.name))
assert(printerInfo.pComment === '')
assert(printerInfo.Flags === 8388608)
})
Expand Down Expand Up @@ -79,10 +78,10 @@ describe(fileShortPath(import.meta.url), () => {
pcReturned,
)
assert(ret, 'EnumPrintersW(PRINTER_INFO_1) failed')
assert(printerInfo.pName === expectName)
assert(printerInfo.pDescription.includes(expectName))
assert(printerInfo.pName === expectPrinterInfo.name)
assert(printerInfo.pDescription.includes(expectPrinterInfo.name))
assert(printerInfo.pComment === '')
assert(printerInfo.Flags === 8388608)
assert(printerInfo.Flags === expectPrinterInfo.flags)
})

it('multi params Level=1', async () => {
Expand All @@ -107,10 +106,10 @@ describe(fileShortPath(import.meta.url), () => {
)
console.log({ ret, level, printerInfo })
assert(ret, 'EnumPrintersW(PRINTER_INFO_1) failed')
assert(printerInfo.pName === expectName)
assert(printerInfo.pDescription.includes(expectName))
assert(printerInfo.pName === expectPrinterInfo.name)
assert(printerInfo.pDescription.includes(expectPrinterInfo.name))
assert(printerInfo.pComment === '')
assert(printerInfo.Flags === 8388608)
assert(printerInfo.Flags === expectPrinterInfo.flags)
})

it('multi params Level=4', async () => {
Expand All @@ -136,7 +135,7 @@ describe(fileShortPath(import.meta.url), () => {
console.log({ ret, level, printerInfo })
assert(ret, 'EnumPrintersW(PRINTER_INFO_4) failed')

assert(printerInfo.pPrinterName === expectName)
assert(printerInfo.pPrinterName === expectPrinterInfo.name)
assert(printerInfo.pServerName === null)
assert(printerInfo.Attributes === 576)
})
Expand Down Expand Up @@ -164,7 +163,7 @@ describe(fileShortPath(import.meta.url), () => {
console.log({ ret, level, printerInfo })
assert(ret, 'EnumPrintersW(PRINTER_INFO_5) failed')

assert(printerInfo.pPrinterName === expectName)
assert(printerInfo.pPrinterName === expectPrinterInfo.name)
assert(printerInfo.pPortName === 'PORTPROMPT:')
assert(printerInfo.Attributes === 576)
assert(printerInfo.DeviceNotSelectedTimeout === 45000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import { PrinterEnumFlags } from '##/index.consts.js'
import { load } from '##/index.js'
import { PRINTER_INFO_1_Type, PRINTER_INFO_4_Type } from '##/index.struct.js'
import { multipleChoiceMapperList } from '#@/mapper/EnumPrintersW.mapper.js'
import { expectPrinterInfo } from '#@/test.config.js'

import { DefWinspool, Winspool } from './api.helper.js'


describe(fileShortPath(import.meta.url), () => {
const expectName = 'Microsoft Print to PDF'

const flags = PrinterEnumFlags.PRINTER_ENUM_LOCAL
const name = ''
const cbBuf = 4096
Expand All @@ -32,7 +31,7 @@ describe(fileShortPath(import.meta.url), () => {
})
lib.updateMultipleChoiceMapper({ mapperList: multipleChoiceMapperList })

const ret1 = lib.EnumPrintersW(
const ret1 = await lib.EnumPrintersW_Async(
flags,
name,
1,
Expand All @@ -43,12 +42,12 @@ describe(fileShortPath(import.meta.url), () => {
)
console.log({ ret1, printerInfo1 })
assert(ret1, 'EnumPrintersW(PRINTER_INFO_1) failed')
assert(printerInfo1.pName === expectName)
assert(printerInfo1.pDescription.includes(expectName))
assert(printerInfo1.pName === expectPrinterInfo.name)
assert(printerInfo1.pDescription.includes(expectPrinterInfo.name))
assert(printerInfo1.pComment === '')
assert(printerInfo1.Flags === 8388608)
assert(printerInfo1.Flags === expectPrinterInfo.flags)

const ret4 = lib.EnumPrintersW(
const ret4 = await lib.EnumPrintersW_Async(
flags,
name,
4,
Expand All @@ -60,7 +59,7 @@ describe(fileShortPath(import.meta.url), () => {
console.log({ ret4, printerInfo4 })
assert(ret4, 'EnumPrintersW(PRINTER_INFO_4) failed')

assert(printerInfo4.pPrinterName === expectName)
assert(printerInfo4.pPrinterName === expectPrinterInfo.name)
assert(printerInfo4.pServerName === null)
assert(printerInfo4.Attributes === 576)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import { PrinterEnumFlags } from '##/index.consts.js'
import { load } from '##/index.js'
import { PRINTER_INFO_1_Type, PRINTER_INFO_4_Type } from '##/index.struct.js'
import { fnName, multipleChoiceMapperSet } from '#@/mapper/EnumPrintersW.mapper.js'
import { expectPrinterInfo } from '#@/test.config.js'

import { DefWinspool, Winspool } from './api.helper.js'


describe(fileShortPath(import.meta.url), () => {
const expectName = 'Microsoft Print to PDF'

const flags = PrinterEnumFlags.PRINTER_ENUM_LOCAL
const name = ''
const cbBuf = 4096
Expand All @@ -35,7 +34,7 @@ describe(fileShortPath(import.meta.url), () => {
mapperSet: multipleChoiceMapperSet,
})

const ret1 = lib.EnumPrintersW(
const ret1 = await lib.EnumPrintersW_Async(
flags,
name,
1,
Expand All @@ -46,10 +45,10 @@ describe(fileShortPath(import.meta.url), () => {
)
console.log({ ret1, printerInfo1 })
assert(ret1, 'EnumPrintersW(PRINTER_INFO_1) failed')
assert(printerInfo1.pName === expectName)
assert(printerInfo1.pDescription.includes(expectName))
assert(printerInfo1.pName === expectPrinterInfo.name)
assert(printerInfo1.pDescription.includes(expectPrinterInfo.name))
assert(printerInfo1.pComment === '')
assert(printerInfo1.Flags === 8388608)
assert(printerInfo1.Flags === expectPrinterInfo.flags)

const ret4 = lib.EnumPrintersW(
flags,
Expand All @@ -63,7 +62,7 @@ describe(fileShortPath(import.meta.url), () => {
console.log({ ret4, printerInfo4 })
assert(ret4, 'EnumPrintersW(PRINTER_INFO_4) failed')

assert(printerInfo4.pPrinterName === expectName)
assert(printerInfo4.pPrinterName === expectPrinterInfo.name)
assert(printerInfo4.pServerName === null)
assert(printerInfo4.Attributes === 576)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import type {
PRINTER_INFO_5_Type,
} from '##/index.struct.js'
import { multipleChoiceMapperList, multipleChoiceMapperSet } from '#@/mapper/EnumPrintersW.mapper.js'
import { expectPrinterInfo } from '#@/test.config.js'

import { defWinspool, WinspoolFns } from './api.helper.js'


describe(fileShortPath(import.meta.url), () => {
const expectName = 'Microsoft Print to PDF'

const flags = PrinterEnumFlags.PRINTER_ENUM_LOCAL
const name = ''
const cbBuf = 4096
Expand Down Expand Up @@ -47,10 +46,10 @@ describe(fileShortPath(import.meta.url), () => {
pcReturned,
)
assert(ret, 'EnumPrintersW(PRINTER_INFO_1) failed')
assert(printerInfo.pName === expectName)
assert(printerInfo.pDescription.includes(expectName))
assert(printerInfo.pName === expectPrinterInfo.name)
assert(printerInfo.pDescription.includes(expectPrinterInfo.name))
assert(printerInfo.pComment === '')
assert(printerInfo.Flags === 8388608)
assert(printerInfo.Flags === expectPrinterInfo.flags)
})

it('using fnName+Map (before)', async () => {
Expand All @@ -65,7 +64,6 @@ describe(fileShortPath(import.meta.url), () => {
mapperSet: multipleChoiceMapperSet,
})


const level = 1
const printerInfo = {} as PRINTER_INFO_1_Type

Expand All @@ -79,10 +77,10 @@ describe(fileShortPath(import.meta.url), () => {
pcReturned,
)
assert(ret, 'EnumPrintersW(PRINTER_INFO_1) failed')
assert(printerInfo.pName === expectName)
assert(printerInfo.pDescription.includes(expectName))
assert(printerInfo.pName === expectPrinterInfo.name)
assert(printerInfo.pDescription.includes(expectPrinterInfo.name))
assert(printerInfo.pComment === '')
assert(printerInfo.Flags === 8388608)
assert(printerInfo.Flags === expectPrinterInfo.flags)
})

it('multi params Level=1', async () => {
Expand All @@ -107,10 +105,10 @@ describe(fileShortPath(import.meta.url), () => {
)
console.log({ ret, level, printerInfo })
assert(ret, 'EnumPrintersW(PRINTER_INFO_1) failed')
assert(printerInfo.pName === expectName)
assert(printerInfo.pDescription.includes(expectName))
assert(printerInfo.pName === expectPrinterInfo.name)
assert(printerInfo.pDescription.includes(expectPrinterInfo.name))
assert(printerInfo.pComment === '')
assert(printerInfo.Flags === 8388608)
assert(printerInfo.Flags === expectPrinterInfo.flags)
})

it('multi params Level=4', async () => {
Expand All @@ -136,7 +134,7 @@ describe(fileShortPath(import.meta.url), () => {
console.log({ ret, level, printerInfo })
assert(ret, 'EnumPrintersW(PRINTER_INFO_4) failed')

assert(printerInfo.pPrinterName === expectName)
assert(printerInfo.pPrinterName === expectPrinterInfo.name)
assert(printerInfo.pServerName === null)
assert(printerInfo.Attributes === 576)
})
Expand Down Expand Up @@ -164,7 +162,7 @@ describe(fileShortPath(import.meta.url), () => {
console.log({ ret, level, printerInfo })
assert(ret, 'EnumPrintersW(PRINTER_INFO_5) failed')

assert(printerInfo.pPrinterName === expectName)
assert(printerInfo.pPrinterName === expectPrinterInfo.name)
assert(printerInfo.pPortName === 'PORTPROMPT:')
assert(printerInfo.Attributes === 576)
assert(printerInfo.DeviceNotSelectedTimeout === 45000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import { PrinterEnumFlags } from '##/index.consts.js'
import { load } from '##/index.js'
import { PRINTER_INFO_1_Type, PRINTER_INFO_4_Type } from '##/index.struct.js'
import { multipleChoiceMapperList } from '#@/mapper/EnumPrintersW.mapper.js'
import { expectPrinterInfo } from '#@/test.config.js'

import { defWinspool, WinspoolFns } from './api.helper.js'


describe(fileShortPath(import.meta.url), () => {
const expectName = 'Microsoft Print to PDF'

const flags = PrinterEnumFlags.PRINTER_ENUM_LOCAL
const name = ''
const cbBuf = 4096
Expand All @@ -32,7 +31,7 @@ describe(fileShortPath(import.meta.url), () => {
})
lib.updateMultipleChoiceMapper({ mapperList: multipleChoiceMapperList })

const ret1 = lib.EnumPrintersW(
const ret1 = await lib.EnumPrintersW_Async(
flags,
name,
1,
Expand All @@ -43,10 +42,10 @@ describe(fileShortPath(import.meta.url), () => {
)
console.log({ ret1, printerInfo1 })
assert(ret1, 'EnumPrintersW(PRINTER_INFO_1) failed')
assert(printerInfo1.pName === expectName)
assert(printerInfo1.pDescription.includes(expectName))
assert(printerInfo1.pName === expectPrinterInfo.name)
assert(printerInfo1.pDescription.includes(expectPrinterInfo.name))
assert(printerInfo1.pComment === '')
assert(printerInfo1.Flags === 8388608)
assert(printerInfo1.Flags === expectPrinterInfo.flags)

const ret4 = lib.EnumPrintersW(
flags,
Expand All @@ -60,7 +59,7 @@ describe(fileShortPath(import.meta.url), () => {
console.log({ ret4, printerInfo4 })
assert(ret4, 'EnumPrintersW(PRINTER_INFO_4) failed')

assert(printerInfo4.pPrinterName === expectName)
assert(printerInfo4.pPrinterName === expectPrinterInfo.name)
assert(printerInfo4.pServerName === null)
assert(printerInfo4.Attributes === 576)
})
Expand Down
Loading

0 comments on commit 1b7238e

Please sign in to comment.