From 124d2b04336397b81feae09268f6f6b09730f3c4 Mon Sep 17 00:00:00 2001 From: aaron <462826@qq.com> Date: Wed, 3 Jun 2020 10:56:15 +0800 Subject: [PATCH] test ddl to yaml files --- test/definition/_ddl.sql | 36 ++++++++++++++++++++++++++++++++++++ test/definition/inherit.yaml | 4 ++-- test/script/ddlToYaml.exp | 3 ++- test/script/ddlToYaml.php | 26 ++++++++++++++++++++++++++ test/script/fieldInherit.php | 2 +- 5 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 test/definition/_ddl.sql mode change 100644 => 100755 test/script/ddlToYaml.php diff --git a/test/definition/_ddl.sql b/test/definition/_ddl.sql new file mode 100644 index 0000000..6b9e787 --- /dev/null +++ b/test/definition/_ddl.sql @@ -0,0 +1,36 @@ +-- DROP TABLE IF EXISTS `zt_action`; +CREATE TABLE IF NOT EXISTS `zt_action` ( + `id` mediumint(8) unsigned NOT NULL auto_increment, + `objectType` varchar(30) NOT NULL default '', + `objectID` mediumint(8) unsigned NOT NULL default '0', + `product` varchar(255) NOT NULL, + `project` mediumint(9) NOT NULL, + `actor` varchar(100) NOT NULL default '', + `action` varchar(30) NOT NULL default '', + `date` datetime NOT NULL, + `comment` text NOT NULL, + `extra` text NOT NULL, + `read` enum('0','1') NOT NULL default '0', + PRIMARY KEY (`id`), + KEY `date` (`date`), + KEY `actor` (`actor`), + KEY `project` (`project`), + KEY `objectID` (`objectID`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +-- DROP TABLE IF EXISTS `zt_block`; +CREATE TABLE IF NOT EXISTS `zt_block` ( + `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `account` char(30) NOT NULL, + `module` varchar(20) NOT NULL, + `title` varchar(100) NOT NULL, + `source` varchar(20) NOT NULL, + `block` varchar(20) NOT NULL, + `params` text NOT NULL, + `order` tinyint(3) unsigned NOT NULL DEFAULT '0', + `grid` tinyint(3) unsigned NOT NULL DEFAULT '0', + `height` smallint(5) unsigned NOT NULL DEFAULT '0', + `hidden` tinyint(1) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `accountModuleOrder` (`account`,`module`,`order`), + KEY `account` (`account`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; \ No newline at end of file diff --git a/test/definition/inherit.yaml b/test/definition/inherit.yaml index b8654a4..c53289e 100644 --- a/test/definition/inherit.yaml +++ b/test/definition/inherit.yaml @@ -5,14 +5,14 @@ version: 1.0 fields: - field: basic - note: 继承基本字段 + note: inherit from basic field loop: 2 loopfix: " " prefix: "{" postfix: "}" - field: refer2 - note: 继承引用字段 + note: inherit from reference field loop: 2 prefix: "=" postfix: "-" \ No newline at end of file diff --git a/test/script/ddlToYaml.exp b/test/script/ddlToYaml.exp index d8efdba..509d833 100644 --- a/test/script/ddlToYaml.exp +++ b/test/script/ddlToYaml.exp @@ -1 +1,2 @@ ->> '192.168.0.1-192.168.1.2' \ No newline at end of file +>> 104 +>> field: id \ No newline at end of file diff --git a/test/script/ddlToYaml.php b/test/script/ddlToYaml.php old mode 100644 new mode 100755 index e69de29..3018596 --- a/test/script/ddlToYaml.php +++ b/test/script/ddlToYaml.php @@ -0,0 +1,26 @@ +#!/usr/bin/env php +> + 2. line of id field >> +[esac] +*/ + +$output = []; +exec('./zd-mac -i ../test/definition/_ddl.sql -o ../test/output', $output); +$str = join("\n", $output); +print("$str\n"); + +$content = file_get_contents('../test/output/zt_action.yaml'); +$arr = explode("\n", $content); +$count = sprintf("%d", count($arr)); +print(">> $count\n"); + +$line = $arr[5]; +print(">> $line\n"); \ No newline at end of file diff --git a/test/script/fieldInherit.php b/test/script/fieldInherit.php index f7c34a0..fbbc009 100755 --- a/test/script/fieldInherit.php +++ b/test/script/fieldInherit.php @@ -2,7 +2,7 @@