From cf35548afa28310d4b648b6040ecfb0b8f7f7d97 Mon Sep 17 00:00:00 2001 From: Claudio Benghi Date: Fri, 3 May 2024 08:59:39 +0100 Subject: [PATCH] Updated audit tool and fixed #111 --- .nuke/build.schema.json | 6 ++- ...predefined_type_must_match_exactly_1_2.ifc | 2 +- ...predefined_type_must_match_exactly_1_2.ifc | 2 +- ...predefined_type_must_match_exactly_2_2.ifc | 2 +- ...predefined_type_must_match_exactly_2_2.ifc | 2 +- ...predefined_type_must_match_exactly_2_2.ifc | 2 +- ...predefined_type_must_match_exactly_2_2.ifc | 2 +- build/Build.cs | 50 ++++++++++++++++--- build/_build.csproj | 2 +- 9 files changed, 55 insertions(+), 15 deletions(-) diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index b5d90f6..29858bd 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -77,7 +77,8 @@ "AuditDocTestCases", "CleanSchemaProject", "CompileSchemaProject", - "CreateTestCases" + "CreateTestCases", + "TestAccurateInvalid" ] } }, @@ -92,7 +93,8 @@ "AuditDocTestCases", "CleanSchemaProject", "CompileSchemaProject", - "CreateTestCases" + "CreateTestCases", + "TestAccurateInvalid" ] } }, diff --git a/Documentation/testcases/partof/fail-the_container_predefined_type_must_match_exactly_1_2.ifc b/Documentation/testcases/partof/fail-the_container_predefined_type_must_match_exactly_1_2.ifc index 73cc5e5..d300465 100644 --- a/Documentation/testcases/partof/fail-the_container_predefined_type_must_match_exactly_1_2.ifc +++ b/Documentation/testcases/partof/fail-the_container_predefined_type_must_match_exactly_1_2.ifc @@ -6,7 +6,7 @@ FILE_SCHEMA(('IFC4')); ENDSEC; DATA; #1=IFCELEMENTASSEMBLY('1hqIFTRjfV6AWq_bMtnZwI',$,$,$,$,$,$,$,$,$); -#2=IFCSPACE('0eA6m4fELI9QBIhP3wiLAp',$,$,$,'BURROW',$,$,$,$,$,$); +#2=IFCSPACE('0eA6m4fELI9QBIhP3wiLAp',$,$,$,'BURROW',$,$,$,$,.USERDEFINED.,$,$); #3=IFCRELCONTAINEDINSPATIALSTRUCTURE('05rScmOVzMoQXOfbYdtLYj',$,$,$,(#1),#2); ENDSEC; END-ISO-10303-21; diff --git a/Documentation/testcases/partof/fail-the_nest_predefined_type_must_match_exactly_1_2.ifc b/Documentation/testcases/partof/fail-the_nest_predefined_type_must_match_exactly_1_2.ifc index 9097585..dd10ef9 100644 --- a/Documentation/testcases/partof/fail-the_nest_predefined_type_must_match_exactly_1_2.ifc +++ b/Documentation/testcases/partof/fail-the_nest_predefined_type_must_match_exactly_1_2.ifc @@ -5,7 +5,7 @@ FILE_NAME('','2022-10-07T13:48:44',(),(),'IfcOpenShell v0.7.0-dc67287d','IfcOpen FILE_SCHEMA(('IFC4')); ENDSEC; DATA; -#1=IFCFURNITURE('1hqIFTRjfV6AWq_bMtnZwI',$,$,$,'WATERBOTTLE',$,$,$,$); +#1=IFCFURNITURE('1hqIFTRjfV6AWq_bMtnZwI',$,$,$,'WATERBOTTLE',$,$,$,.USERDEFINED.); #2=IFCDISCRETEACCESSORY('0eA6m4fELI9QBIhP3wiLAp',$,$,$,$,$,$,$,$); #3=IFCRELNESTS('05rScmOVzMoQXOfbYdtLYj',$,$,$,#1,(#2)); ENDSEC; diff --git a/Documentation/testcases/partof/invalid-a_group_predefined_type_must_match_exactly_2_2.ifc b/Documentation/testcases/partof/invalid-a_group_predefined_type_must_match_exactly_2_2.ifc index 3aa1ea3..38d4a07 100644 --- a/Documentation/testcases/partof/invalid-a_group_predefined_type_must_match_exactly_2_2.ifc +++ b/Documentation/testcases/partof/invalid-a_group_predefined_type_must_match_exactly_2_2.ifc @@ -6,7 +6,7 @@ FILE_SCHEMA(('IFC4')); ENDSEC; DATA; #1=IFCELEMENTASSEMBLY('1hqIFTRjfV6AWq_bMtnZwI',$,$,$,$,$,$,$,$,$); -#2=IFCINVENTORY('0eA6m4fELI9QBIhP3wiLAp',$,$,$,'BUNNY',$,$,$,$,$,$); +#2=IFCINVENTORY('0eA6m4fELI9QBIhP3wiLAp',$,$,$,'BUNNY',.USERDEFINED.,$,$,$,$,$); #3=IFCRELASSIGNSTOGROUP('05rScmOVzMoQXOfbYdtLYj',$,$,$,(#1),$,#2); ENDSEC; END-ISO-10303-21; diff --git a/Documentation/testcases/partof/pass-a_group_predefined_type_must_match_exactly_2_2.ifc b/Documentation/testcases/partof/pass-a_group_predefined_type_must_match_exactly_2_2.ifc index 3aa1ea3..38d4a07 100644 --- a/Documentation/testcases/partof/pass-a_group_predefined_type_must_match_exactly_2_2.ifc +++ b/Documentation/testcases/partof/pass-a_group_predefined_type_must_match_exactly_2_2.ifc @@ -6,7 +6,7 @@ FILE_SCHEMA(('IFC4')); ENDSEC; DATA; #1=IFCELEMENTASSEMBLY('1hqIFTRjfV6AWq_bMtnZwI',$,$,$,$,$,$,$,$,$); -#2=IFCINVENTORY('0eA6m4fELI9QBIhP3wiLAp',$,$,$,'BUNNY',$,$,$,$,$,$); +#2=IFCINVENTORY('0eA6m4fELI9QBIhP3wiLAp',$,$,$,'BUNNY',.USERDEFINED.,$,$,$,$,$); #3=IFCRELASSIGNSTOGROUP('05rScmOVzMoQXOfbYdtLYj',$,$,$,(#1),$,#2); ENDSEC; END-ISO-10303-21; diff --git a/Documentation/testcases/partof/pass-the_container_predefined_type_must_match_exactly_2_2.ifc b/Documentation/testcases/partof/pass-the_container_predefined_type_must_match_exactly_2_2.ifc index 73cc5e5..ac3dfe6 100644 --- a/Documentation/testcases/partof/pass-the_container_predefined_type_must_match_exactly_2_2.ifc +++ b/Documentation/testcases/partof/pass-the_container_predefined_type_must_match_exactly_2_2.ifc @@ -6,7 +6,7 @@ FILE_SCHEMA(('IFC4')); ENDSEC; DATA; #1=IFCELEMENTASSEMBLY('1hqIFTRjfV6AWq_bMtnZwI',$,$,$,$,$,$,$,$,$); -#2=IFCSPACE('0eA6m4fELI9QBIhP3wiLAp',$,$,$,'BURROW',$,$,$,$,$,$); +#2=IFCSPACE('0eA6m4fELI9QBIhP3wiLAp',$,$,$,'BURROW',$,$,$,$,.USERDEFINED.,$); #3=IFCRELCONTAINEDINSPATIALSTRUCTURE('05rScmOVzMoQXOfbYdtLYj',$,$,$,(#1),#2); ENDSEC; END-ISO-10303-21; diff --git a/Documentation/testcases/partof/pass-the_nest_predefined_type_must_match_exactly_2_2.ifc b/Documentation/testcases/partof/pass-the_nest_predefined_type_must_match_exactly_2_2.ifc index 9097585..dd10ef9 100644 --- a/Documentation/testcases/partof/pass-the_nest_predefined_type_must_match_exactly_2_2.ifc +++ b/Documentation/testcases/partof/pass-the_nest_predefined_type_must_match_exactly_2_2.ifc @@ -5,7 +5,7 @@ FILE_NAME('','2022-10-07T13:48:44',(),(),'IfcOpenShell v0.7.0-dc67287d','IfcOpen FILE_SCHEMA(('IFC4')); ENDSEC; DATA; -#1=IFCFURNITURE('1hqIFTRjfV6AWq_bMtnZwI',$,$,$,'WATERBOTTLE',$,$,$,$); +#1=IFCFURNITURE('1hqIFTRjfV6AWq_bMtnZwI',$,$,$,'WATERBOTTLE',$,$,$,.USERDEFINED.); #2=IFCDISCRETEACCESSORY('0eA6m4fELI9QBIhP3wiLAp',$,$,$,$,$,$,$,$); #3=IFCRELNESTS('05rScmOVzMoQXOfbYdtLYj',$,$,$,#1,(#2)); ENDSEC; diff --git a/build/Build.cs b/build/Build.cs index da9433b..27fa54a 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -10,7 +10,7 @@ class Build : NukeBuild { public static int Main() => Execute(x => x.AuditAllIdsFiles); - + [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] private readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; @@ -184,15 +184,53 @@ class Build : NukeBuild var inputFolder = RootDirectory / "Documentation" / "testcases"; var arguments = $"audit \"{inputFolder}\" --omitContentAuditPattern \"[\\\\|/]invalid-\" -x \"{schemaFile}\""; IdsTool(arguments, workingDirectory: IdsToolPath); - }); + }); - /// - /// Perform all quality assurance of published IDS files; this is the one invoked by default - /// - Target AuditAllIdsFiles => _ => _ + /// + /// Audits the validity of Documentation/testcases folder in the repository, using ids-tool. + /// The tool is deployed by the annotated . + /// The schema is loaded from the repository to ensure internal coherence. + /// + Target TestAccurateInvalid => _ => _ + .AssuredAfterFailure() + .Executes(() => + { + // we are omitting tests on the content of the Documentation/testcases folder, + // because they include IDSs that intentionally contain errors + // + // todo: once stable, this could be improved to omit contents based on failure patter name + // todo: once stable, constrained on expected auditing failures on the "fail-" cases should be added + var schemaFile = RootDirectory / "Development" / "ids.xsd"; + var inputFolder = RootDirectory / "Documentation" / "testcases"; + + DirectoryInfo d = new DirectoryInfo(inputFolder); + foreach (var invalidFile in d.GetFiles("invalid-*.ids", SearchOption.AllDirectories)) + { + Console.WriteLine(invalidFile.FullName); + var arguments = $"audit \"{invalidFile}\" -x \"{schemaFile}\""; + try + { + var t = IdsTool(arguments, workingDirectory: IdsToolPath); + } + catch (ProcessException ex) + { + if (ex.ExitCode != 16) + throw new Exception("Unexpected exit code"); + + } + } + + + }); + + /// + /// Perform all quality assurance of published IDS files; this is the one invoked by default + /// + Target AuditAllIdsFiles => _ => _ .AssuredAfterFailure() .DependsOn(AuditDocTestCases) .DependsOn(AuditDevelopment) + .DependsOn(TestAccurateInvalid) .Executes(() => { Console.WriteLine("This is an utility target that launches all available IDS auditing targets."); diff --git a/build/_build.csproj b/build/_build.csproj index c668caf..f875ec6 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -13,7 +13,7 @@ - +