MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / addTestdata

Method addTestdata

packages/fps-importer/index.ts:45–53  ·  view source on GitHub ↗
(node: any, index: string, ext: string)

Source from the content-addressed store, hash-verified

43 const tasks: Promise<any>[] = [ProblemModel.addTestdata(domainId, pid, 'config.yaml', Buffer.from(yaml.dump(config)))];
44 if (!markdown) tasks.push(ProblemModel.edit(domainId, pid, { html: true }));
45 const addTestdata = (node: any, index: string, ext: string) => {
46 if (!node || !['object', 'string'].includes(typeof node)) return; // Ignore file not exist
47 const id = node.$?.name || `${index}`;
48 // `filename` attribute introduced by winterant/OnlineJudge
49 // PLEASE, respect the spec
50 const filename = node.$?.filename || `${id}.${ext}`;
51 const c = node._ || (typeof node === 'string' ? node : '');
52 tasks.push(ProblemModel.addTestdata(domainId, pid, filename, Buffer.from(c)));
53 };
54 if (p.test_output) {
55 for (let i = 0; i < p.test_input.length; i++) {
56 addTestdata(p.test_input[i], `${i + 1}`, 'in');

Callers 1

runMethod · 0.45

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected