Add os based tests

This commit is contained in:
HaveAGitGat 2022-05-23 07:34:19 +01:00
parent ad646d04b5
commit b1815667d6
3 changed files with 142 additions and 83 deletions

View file

@ -11,17 +11,20 @@ const tests = [
otherArguments: {},
},
output: {
container: '.mkv',
processFile: true,
preset: ', -sn -map 0:v -c:v copy -b:v 758k -minrate 530k -maxrate 985k -bufsize 1517k -map 0:a -c:a copy ',
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: 'Converting video, NOT resizing. 720p, h264 --> 720p, hevc. bitrate = 1517 --> 758, multiplier 0.5. \n'
+ 'Not converting audio. \n'
+ '2 channels - \n'
+ '6 channels - und aac \n'
+ '8 channels - ',
win32: {
container: '.mkv',
processFile: true,
preset: ', -sn -map 0:v -c:v hevc_qsv -load_plugin hevc_hw -b:v 758k -minrate 530k -maxrate 985k -bufsize 1517k -map 0:a -c:a copy ',
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: 'Converting video, NOT resizing. 720p, h264 --> 720p, hevc. bitrate = 1517 --> 758, multiplier 0.5. \n'
+ 'Not converting audio. \n'
+ '2 channels - \n'
+ '6 channels - und aac \n'
+ '8 channels - ',
},
linux: undefined,
},
},
{
@ -70,17 +73,20 @@ const tests = [
otherArguments: {},
},
output: {
container: '.mkv',
processFile: true,
preset: ', -sn -map 0:v -c:v copy -b:v 3933k -minrate 2753k -maxrate 5112k -bufsize 7866k -map 0:a -c:a copy ',
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: 'Converting video, NOT resizing. 1080p, h264 --> 1080p, hevc. bitrate = 7866 --> 3933, multiplier 0.5. \n'
+ 'Not converting audio. \n'
+ '2 channels - eng flac \n'
+ '6 channels - \n'
+ '8 channels - ',
win32: {
container: '.mkv',
processFile: true,
preset: ', -sn -map 0:v -c:v hevc_qsv -load_plugin hevc_hw -b:v 3933k -minrate 2753k -maxrate 5112k -bufsize 7866k -map 0:a -c:a copy ',
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: 'Converting video, NOT resizing. 1080p, h264 --> 1080p, hevc. bitrate = 7866 --> 3933, multiplier 0.5. \n'
+ 'Not converting audio. \n'
+ '2 channels - eng flac \n'
+ '6 channels - \n'
+ '8 channels - ',
},
linux: undefined,
},
},
{

View file

@ -11,21 +11,40 @@ const tests = [
otherArguments: {},
},
output: {
processFile: true,
preset: '-fflags +genpts -hwaccel qsv -c:v h264_qsv<io> -map 0 -c:v hevc_qsv -b:v 759k -minrate 569k -maxrate 949k -bufsize 1517k -preset slow \n'
+ ' -c:a copy -c:s copy -max_muxing_queue_size 9999 ',
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: '☑ It looks like the current bitrate is 1517k. \n'
+ '\n'
+ 'Container for output selected as mkv. \n'
+ 'Encode variable bitrate settings: \n'
+ 'Target = 759k \n'
+ 'Minimum = 569k \n'
+ 'Maximum = 949k \n'
+ 'File Transcoding... \n',
container: '.mkv',
linux: {
processFile: true,
preset: '-fflags +genpts -hwaccel qsv -c:v h264_qsv<io> -map 0 -c:v hevc_qsv -b:v 759k -minrate 569k -maxrate 949k -bufsize 1517k -preset slow \n'
+ ' -c:a copy -c:s copy -max_muxing_queue_size 9999 ',
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: '☑ It looks like the current bitrate is 1517k. \n'
+ '\n'
+ 'Container for output selected as mkv. \n'
+ 'Encode variable bitrate settings: \n'
+ 'Target = 759k \n'
+ 'Minimum = 569k \n'
+ 'Maximum = 949k \n'
+ 'File Transcoding... \n',
container: '.mkv',
},
win32: {
processFile: true,
preset: '-fflags +genpts -hwaccel qsv -c:v h264_qsv<io> -map 0 -c:v hevc_qsv -load_plugin hevc_hw -b:v 759k -minrate 569k -maxrate 949k -bufsize 1517k -preset slow \n'
+ ' -c:a copy -c:s copy -max_muxing_queue_size 9999 ',
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: '☑ It looks like the current bitrate is 1517k. \n'
+ '\n'
+ 'Container for output selected as mkv. \n'
+ 'Encode variable bitrate settings: \n'
+ 'Target = 759k \n'
+ 'Minimum = 569k \n'
+ 'Maximum = 949k \n'
+ 'File Transcoding... \n',
container: '.mkv',
},
},
},
{
@ -40,22 +59,42 @@ const tests = [
otherArguments: {},
},
output: {
processFile: true,
preset: '-fflags +genpts -hwaccel qsv<io> -map 0 -c:v hevc_qsv -b:v 759k -minrate 569k -maxrate 949k -bufsize 1517k -preset fast \n'
+ ' -c:a copy -c:s copy -max_muxing_queue_size 9999 -profile:v main10 -pix_fmt p010le ',
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: '☑ It looks like the current bitrate is 1517k. \n'
+ '10 bit encode enabled. Setting Main10 Profile & 10 bit pixel format \n'
+ '\n'
+ 'Container for output selected as mp4. \n'
+ 'Encode variable bitrate settings: \n'
+ 'Target = 759k \n'
+ 'Minimum = 569k \n'
+ 'Maximum = 949k \n'
+ 'File Transcoding... \n',
container: '.mp4',
linux: {
processFile: true,
preset: '-fflags +genpts -hwaccel qsv<io> -map 0 -c:v hevc_qsv -b:v 759k -minrate 569k -maxrate 949k -bufsize 1517k -preset fast \n'
+ ' -c:a copy -c:s copy -max_muxing_queue_size 9999 -profile:v main10 -pix_fmt p010le ',
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: '☑ It looks like the current bitrate is 1517k. \n'
+ '10 bit encode enabled. Setting Main10 Profile & 10 bit pixel format \n'
+ '\n'
+ 'Container for output selected as mp4. \n'
+ 'Encode variable bitrate settings: \n'
+ 'Target = 759k \n'
+ 'Minimum = 569k \n'
+ 'Maximum = 949k \n'
+ 'File Transcoding... \n',
container: '.mp4',
},
win32: {
processFile: true,
preset: '-fflags +genpts -hwaccel qsv<io> -map 0 -c:v hevc_qsv -load_plugin hevc_hw -b:v 759k -minrate 569k -maxrate 949k -bufsize 1517k -preset fast \n'
+ ' -c:a copy -c:s copy -max_muxing_queue_size 9999 -profile:v main10 -pix_fmt p010le ',
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: '☑ It looks like the current bitrate is 1517k. \n'
+ '10 bit encode enabled. Setting Main10 Profile & 10 bit pixel format \n'
+ '\n'
+ 'Container for output selected as mp4. \n'
+ 'Encode variable bitrate settings: \n'
+ 'Target = 759k \n'
+ 'Minimum = 569k \n'
+ 'Maximum = 949k \n'
+ 'File Transcoding... \n',
container: '.mp4',
},
},
},
{

View file

@ -2,6 +2,7 @@ const path = require('path');
const chai = require('chai');
const _ = require('lodash');
const importFresh = require('import-fresh');
const os = require('os');
const scriptName = path.basename(process.mainModule.filename);
@ -12,37 +13,50 @@ const run = async (tests) => {
console.log(`${scriptName}: test ${i}`);
const test = tests[i];
let testOutput;
let errorEncountered = false;
// eslint-disable-next-line import/no-dynamic-require
const { plugin } = importFresh(`../../Community/${scriptName}`);
try {
// eslint-disable-next-line no-await-in-loop
testOutput = await plugin(
_.cloneDeep(test.input.file),
_.cloneDeep(test.input.librarySettings),
_.cloneDeep(test.input.inputs),
_.cloneDeep(test.input.otherArguments),
);
} catch (err1) {
errorEncountered = err1;
}
if (test.outputModify) {
testOutput = test.outputModify(test.output);
}
if (test.error && test.error.shouldThrow) {
if (errorEncountered !== false) {
// eslint-disable-next-line no-console
console.log(errorEncountered);
chai.assert.deepEqual(errorEncountered.message, test.output);
} else {
throw new Error('Expected plugin error but none was thrown!');
}
let expectedOutput;
if (test.output[os.platform()]) {
expectedOutput = test.output[os.platform()];
} else {
chai.assert.deepEqual(testOutput, test.output);
expectedOutput = test.output;
}
if (expectedOutput === undefined) {
// skip test due to OS
// eslint-disable-next-line no-console
console.log(`Test not meant to run on ${os.platform()}, skipping`);
} else {
let testOutput;
let errorEncountered = false;
// eslint-disable-next-line import/no-dynamic-require
const { plugin } = importFresh(`../../Community/${scriptName}`);
try {
// eslint-disable-next-line no-await-in-loop
testOutput = await plugin(
_.cloneDeep(test.input.file),
_.cloneDeep(test.input.librarySettings),
_.cloneDeep(test.input.inputs),
_.cloneDeep(test.input.otherArguments),
);
} catch (err1) {
errorEncountered = err1;
}
if (test.outputModify) {
testOutput = test.outputModify(testOutput);
}
if (test.error && test.error.shouldThrow) {
if (errorEncountered !== false) {
// eslint-disable-next-line no-console
console.log(errorEncountered);
chai.assert.deepEqual(errorEncountered.message, expectedOutput);
} else {
throw new Error('Expected plugin error but none was thrown!');
}
} else {
chai.assert.deepEqual(testOutput, expectedOutput);
}
}
}
} catch (err) {