Skip to content

Commit

Permalink
Solved issue #10.
Browse files Browse the repository at this point in the history
Updated .gitignore file with TMC-file, which according to Beckhoff documentation should not be version controlled from TwinCAT 3.1.4018 and onward.
  • Loading branch information
sagatowski committed Dec 13, 2018
1 parent 9b62e21 commit c859eee
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 40 deletions.
15 changes: 1 addition & 14 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,6 @@
# This file makes sure everything in this folder (recursively) according to the
# rules specified here is ignored by GIT version controlling. It's adapted
# specifically for TwinCAT3.1 projects.
#
# Revision history:
#
# 1.0/2015-09-09/Jakob Sagatowski
# First revision. Created a default ignorefile with some TwinCAT
# files extensions recommended by Beckhoff.
# 1.1/2016-11-28/Jakob Sagatowski
# Removed included libraries
# 1.2/2017-04-27/Jakob Sagatowski
# Removed *.tmc from the git ignore. Now *.tmc-files are included.
# 1.3/2017-12-14/Jakob Sagatowski
# Added *.~u.
# 1.4/2018-10-03/Jakob Sagatowksi
# Added .vs/
#
# //////////////////////////////////////////////////////////////////////////////

Expand All @@ -25,6 +11,7 @@
*.tclrs
*.compiled-library
*.compileinfo
*.tmc
_Boot/
_CompileInfo/
_Libraries/
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Jakob Sagatowski and other contributors, see AUTHORS file
Copyright (c) 2018 Jakob Sagatowski and CONTRIBUTORS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
7 changes: 6 additions & 1 deletion TcUnit/TcUnit/GVLs/GVL.TcGVL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.12">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.16">
<GVL Name="GVL" Id="{78472b76-c9a4-4b27-a580-8e7898edc3d7}">
<Declaration><![CDATA[{attribute 'no_assign'}
{attribute 'qualified_only'}
Expand All @@ -16,6 +16,11 @@ VAR_GLOBAL
(* Current name of test being called *)
CurrentTestNameBeingCalled : Tc2_System.T_MaxString;
(* This is a flag that indicates that the current test should be ignored, and
thus that all assertions under it should be ignored as well. A test can be ignored either
because the user has requested so, or because the test is a duplicate name *)
IgnoreCurrentTest : BOOL;
(* The assert function block instance should be 1:1 mapped to
the test suite instance path. *)
AmountOfInitializedTestSuites : UINT := 0;
Expand Down
74 changes: 54 additions & 20 deletions TcUnit/TcUnit/POUs/FB_TestSuite.TcPOU
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.12">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.16">
<POU Name="FB_TestSuite" Id="{f80c23f2-119d-406b-ae11-06d1991bf64d}" SpecialFunc="None">
<Declaration><![CDATA[(* This function block is responsible for holding the internal state of the test suite.
Every test suite can have one or more tests, and every test can do one or more asserts.
Expand All @@ -16,9 +16,20 @@ VAR
in order for us to have a reference to calling the actual execution of the tests *)
_RunnableTestSuite : I_RunnableTestSuite;
(* We need to have access to specific information of the current task that this test suite
is executed in. This is for instance necessary when we need to know whether a test is
defined already. The definition of a test that is defined already is that we call on it
with the same name twice in the same cycle *)
GetCurrentTaskIndex : Tc2_System.GETCURTASKINDEX;
NumberOfTests : UINT := 0;
Tests : ARRAY[1..GVL_Constants.MaxAmountOfTestsForEachTestSuite] OF FB_Test;
TestDuplicateNameTrigger : ARRAY[1..GVL_Constants.MaxAmountOfTestsForEachTestSuite] OF Tc2_Standard.R_TRIG; // Rising trigger of whether we have already notified the user of that the test name pointed to by the current position is a duplicate
(* Rising trigger of whether we have already notified the user of that the test name pointed to by the current
position is a duplicate *)
TestDuplicateNameTrigger : ARRAY[1..GVL_Constants.MaxAmountOfTestsForEachTestSuite] OF Tc2_Standard.R_TRIG;
(* Last cycle count index for a specific test. Used to detect whether this test has already been run defined in the
current test suite *)
TestCycleCountIndex : ARRAY[1..GVL_Constants.MaxAmountOfTestsForEachTestSuite] OF UDINT;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[]]></ST>
Expand All @@ -33,34 +44,46 @@ VAR
ErrorMessage : Tc2_System.T_MaxString;
TestInstancePath : Tc2_System.T_MaxString;
FunctionCallResult : DINT;
CycleCount : UDINT;
TestWithThisNameAlreadyExists : BOOL := FALSE;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[(* Check if the test name already exists Make sure there are no other tests with the same name already
<ST><![CDATA[GetCurrentTaskIndex(); // Gets the task index of where this function block instance is being run in
(* Check if the test name already exists. Make sure there are no other tests with the same name already
added for this test suite *)
CycleCount := TwinCAT_SystemInfoVarList._TaskInfo[GetCurrentTaskIndex.index].CycleCount;
(* Iterate all the test names that up to this point have been added for this test suite *)
FOR IteratorCounter := 1 TO NumberOfTests BY 1 DO
IF Tests[IteratorCounter].GetName() = TestName THEN
(* A test with this name already exists for this test suite. *)
(* Send a message notification, but only if we have not done so already. *)
TestDuplicateNameTrigger[IteratorCounter](CLK := TRUE);
IF TestDuplicateNameTrigger[IteratorCounter].Q THEN // Rising edge detected. We have not reported this before
TestInstancePath := F_RemoveInstancePathAndProjectNameFromTestInstancePath(TestInstancePath :=
GVL.CurrentTestSuiteBeingCalled.GetInstancePath());
ErrorMessage := 'Test with name $'%s$' already exists in test suite $'';
ErrorMessage := Tc2_Standard.CONCAT(STR1 := ErrorMessage, STR2 := TestInstancePath);
ErrorMessage := Tc2_Standard.CONCAT(STR1 := ErrorMessage, STR2 := '$'');
FunctionCallResult := Tc2_System.ADSLOGSTR(msgCtrlMask := Tc2_System.ADSLOG_MSGTYPE_ERROR,
msgFmtStr := ErrorMessage,
strArg := TestName);
TestWithThisNameAlreadyExists := TRUE;
(* Check if a test with this name has already been called in this cycle *)
IF TestCycleCountIndex[IteratorCounter] = CycleCount THEN
(* A test with this name already exists for this test suite and has already been called in this cycle.
Send a message notification, but only if we have not done so already. *)
TestDuplicateNameTrigger[IteratorCounter](CLK := TRUE);
IF TestDuplicateNameTrigger[IteratorCounter].Q THEN // Rising edge detected. We have not reported this before
TestInstancePath := F_RemoveInstancePathAndProjectNameFromTestInstancePath(TestInstancePath :=
GVL.CurrentTestSuiteBeingCalled.GetInstancePath());
ErrorMessage := 'Test with name $'%s$' already exists in test suite $'';
ErrorMessage := Tc2_Standard.CONCAT(STR1 := ErrorMessage, STR2 := TestInstancePath);
ErrorMessage := Tc2_Standard.CONCAT(STR1 := ErrorMessage, STR2 := '$'');
FunctionCallResult := Tc2_System.ADSLOGSTR(msgCtrlMask := Tc2_System.ADSLOG_MSGTYPE_ERROR,
msgFmtStr := ErrorMessage,
strArg := TestName);
END_IF
END_IF
RETURN;
END_IF
TestCycleCountIndex[IteratorCounter] := CycleCount;
END_FOR
(* Test has not been found. Add it. *)
Tests[IteratorCounter].SetName(Name := TestName);
NumberOfTests := NumberOfTests + 1;]]></ST>
IF NOT TestWithThisNameAlreadyExists THEN
(* Test has not been found. Add it. *)
Tests[IteratorCounter].SetName(Name := TestName);
NumberOfTests := NumberOfTests + 1;
END_IF]]></ST>
</Implementation>
</Method>
<Method Name="GetAmountOfFailedTests" Id="{12e4522b-e67f-439a-af1d-8713231888aa}">
Expand Down Expand Up @@ -150,12 +173,19 @@ END_IF]]></ST>
<LineId Id="9" Count="0" />
</LineIds>
<LineIds Name="FB_TestSuite.AddTest">
<LineId Id="108" Count="0" />
<LineId Id="110" Count="0" />
<LineId Id="15" Count="0" />
<LineId Id="79" Count="0" />
<LineId Id="130" Count="0" />
<LineId Id="129" Count="0" />
<LineId Id="78" Count="0" />
<LineId Id="77" Count="0" />
<LineId Id="10" Count="0" />
<LineId Id="90" Count="0" />
<LineId Id="142" Count="0" />
<LineId Id="127" Count="0" />
<LineId Id="125" Count="0" />
<LineId Id="80" Count="0" />
<LineId Id="92" Count="0" />
<LineId Id="94" Count="0" />
Expand All @@ -167,13 +197,17 @@ END_IF]]></ST>
<LineId Id="41" Count="0" />
<LineId Id="58" Count="0" />
<LineId Id="46" Count="0" />
<LineId Id="96" Count="1" />
<LineId Id="96" Count="0" />
<LineId Id="13" Count="0" />
<LineId Id="126" Count="0" />
<LineId Id="122" Count="0" />
<LineId Id="9" Count="0" />
<LineId Id="143" Count="0" />
<LineId Id="14" Count="0" />
<LineId Id="18" Count="0" />
<LineId Id="91" Count="0" />
<LineId Id="32" Count="0" />
<LineId Id="144" Count="0" />
</LineIds>
<LineIds Name="FB_TestSuite.GetAmountOfFailedTests">
<LineId Id="10" Count="1" />
Expand Down
4 changes: 2 additions & 2 deletions TcUnit/TcUnit/TcUnit.plcproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Documentation and examples are available at www.tcunit.org</Description>
<Id>{78515825-a6f1-476c-a7b7-6595f51e6013}</Id>
</SelectedLibraryCategories>
<Company>www.tcunit.org</Company>
<Author>Jakob Sagatowski and other contributors, see AUTHORS file on www.github.com/tcunit/TcUnit</Author>
<ProjectVersion>0.4.0.0</ProjectVersion>
<Author>Jakob Sagatowski and other contributors, see CONTRIBUTORS file on www.github.com/tcunit/TcUnit</Author>
<ProjectVersion>0.4.1.0</ProjectVersion>
<!-- <OutputType>Exe</OutputType>
<RootNamespace>MyApplication</RootNamespace>
<AssemblyName>MyApplication</AssemblyName>-->
Expand Down
4 changes: 2 additions & 2 deletions TcUnit/TcUnit/Version/Global_Version.TcGVL
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.12">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.16">
<GVL Name="Global_Version" Id="{899e68fc-21fd-4d89-beb5-fc369f4dda74}">
<Declaration><![CDATA[{attribute 'TcGenerated'}
{attribute 'no-analysis'}
{attribute 'linkalways'}
// This function has been automatically generated from the project information.
VAR_GLOBAL CONSTANT
{attribute 'const_non_replaced'}
stLibVersion_TcUnit : ST_LibVersion := (iMajor := 0, iMinor := 4, iBuild := 0, iRevision := 0, sVersion := '0.4.0.0');
stLibVersion_TcUnit : ST_LibVersion := (iMajor := 0, iMinor := 4, iBuild := 1, iRevision := 0, sVersion := '0.4.1.0');
END_VAR
]]></Declaration>
</GVL>
Expand Down

0 comments on commit c859eee

Please sign in to comment.