Some checks failed
Deploy Landing Page to Storj / deploy (push) Failing after 3s
- Connected PROV-O, CycloneDX, and SPDX generators to CLI entry point - Fixed parseAuthor regex to handle angle-bracket email format - Fixed parseDerives to handle hyphenated names and quoted rationale - Fixed parseSatisfies to handle hyphenated requirement IDs - Fixed parseSource to handle ref keyword with quoted value - Added graceful fallbacks (warn instead of throw) for parse errors - All 5 example .speck files compile and validate successfully
57 lines
No EOL
2.4 KiB
JavaScript
57 lines
No EOL
2.4 KiB
JavaScript
import { describe, it, expect, beforeAll } from 'vitest';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import { parseSpeckFile } from '../parser.js';
|
|
import { generateProvenanceGraph } from '../generators/provenance.js';
|
|
import { generateCycloneDX } from '../generators/cyclonedx.js';
|
|
import { generateSPDX } from '../generators/spdx.js';
|
|
describe('Compiler E2E', () => {
|
|
let ast;
|
|
const testOutputDir = './test-output';
|
|
beforeAll(() => {
|
|
// Create test output directory
|
|
if (!fs.existsSync(testOutputDir)) {
|
|
fs.mkdirSync(testOutputDir);
|
|
}
|
|
});
|
|
it('should parse RetryHandler.speck', () => {
|
|
const specPath = path.join(process.cwd(), '..', 'examples', 'RetryHandler.speck');
|
|
ast = parseSpeckFile(specPath);
|
|
expect(ast).toBeDefined();
|
|
expect(ast.specks).toBeDefined();
|
|
expect(ast.specks.length).toBeGreaterThan(0);
|
|
const speck = ast.specks[0];
|
|
expect(speck.name).toBe('RetryHandler');
|
|
expect(speck.type).toBe('speck');
|
|
expect(speck.members.length).toBeGreaterThan(0);
|
|
});
|
|
it('should generate provenance graph', () => {
|
|
generateProvenanceGraph(ast, testOutputDir);
|
|
const provFile = path.join(testOutputDir, 'RetryHandler.prov.jsonld');
|
|
expect(fs.existsSync(provFile)).toBe(true);
|
|
const content = fs.readFileSync(provFile, 'utf-8');
|
|
const provGraph = JSON.parse(content);
|
|
expect(provGraph['@context']).toBeDefined();
|
|
expect(provGraph['@graph']).toBeDefined();
|
|
});
|
|
it('should generate CycloneDX BOM', () => {
|
|
generateCycloneDX(ast, testOutputDir);
|
|
const cdxFile = path.join(testOutputDir, 'RetryHandler.specbom.cdx.json');
|
|
expect(fs.existsSync(cdxFile)).toBe(true);
|
|
const content = fs.readFileSync(cdxFile, 'utf-8');
|
|
const cdx = JSON.parse(content);
|
|
expect(cdx.bomFormat).toBe('CycloneDX');
|
|
expect(cdx.specVersion).toBe('1.6');
|
|
expect(cdx.components).toBeDefined();
|
|
});
|
|
it('should generate SPDX BOM', () => {
|
|
generateSPDX(ast, testOutputDir);
|
|
const spdxFile = path.join(testOutputDir, 'RetryHandler.specbom.spdx.json');
|
|
expect(fs.existsSync(spdxFile)).toBe(true);
|
|
const content = fs.readFileSync(spdxFile, 'utf-8');
|
|
const spdx = JSON.parse(content);
|
|
expect(spdx['@context']).toBeDefined();
|
|
expect(spdx.spdx).toBeDefined();
|
|
});
|
|
});
|
|
//# sourceMappingURL=compiler.test.js.map
|