[hotfix] Ignore type checking for edge
[platform/framework/web/wrtjs.git] / device_home / node_modules / jake / test / integration / rule.js
1 const PROJECT_DIR=process.env.PROJECT_DIR;let assert=require("assert"),exec=require("child_process").execSync,fs=require("fs"),{Rule:Rule}=require(`${PROJECT_DIR}/lib/rule`),{rmRf:rmRf}=require(`${PROJECT_DIR}/lib/jake`),cleanUpAndNext=function(e){["tmp","tmp_ns","tmp_cr","tmp_p","tmp_pf","tmpbin","tmpsrc","tmp_dep1.c","tmp_dep1.o","tmp_dep1.oo","tmp_dep2.c","tmp_dep2.o","tmp_dep2.oo","foo","foo.html"].forEach((function(e){rmRf(e,{silent:!0})})),e&&e()};suite("rule",(function(){this.timeout(7e3),setup((function(e){cleanUpAndNext(e)})),test("Rule.getSource",(function(){let e=Rule.getSource("foo:bin/main.o","bin/%.o","src/%.c");assert.equal("foo:src/main.c",e)})),test("rule w/o pattern",(function(){let e=exec("./node_modules/.bin/jake -q  tmp").toString().trim();assert.equal(["tmp_dep2.c task","tmp_dep1.c task","cp tmp_dep1.c tmp_dep1.o task","cp tmp_dep2.c tmp_dep2.o task","tmp task"].join("\n"),e);let t=fs.readFileSync(process.cwd()+"/tmp");assert.equal("src_1src_2",t.toString()),cleanUpAndNext()})),test("rule w pattern w/o folder w/o namespace",(function(){let e,t=exec("./node_modules/.bin/jake  -q  tmp_p").toString().trim();assert.equal(["tmp_dep2.c task","tmp_dep1.c task","cp tmp_dep1.c tmp_dep1.oo task","cp tmp_dep2.c tmp_dep2.oo task","tmp pattern task"].join("\n"),t),e=fs.readFileSync(process.cwd()+"/tmp_p"),assert.equal("src_1src_2 pattern",e.toString()),cleanUpAndNext()})),test("rule w pattern w folder w/o namespace",(function(){let e,t=exec("./node_modules/.bin/jake  -q  tmp_pf").toString().trim();assert.equal(["tmpsrc/tmp_dep1.c task","cp tmpsrc/tmp_dep1.c tmpbin/tmp_dep1.oo task","tmpsrc/tmp_dep2.c task","cp tmpsrc/tmp_dep2.c tmpbin/tmp_dep2.oo task","tmp pattern folder task"].join("\n"),t),e=fs.readFileSync(process.cwd()+"/tmp_pf"),assert.equal("src/src_1src/src_2 pattern folder",e.toString()),cleanUpAndNext()})),test.skip("rule w pattern w folder w namespace",(function(){let e,t=exec("./node_modules/.bin/jake -q   tmp_ns").toString().trim();assert.equal(["tmpsrc/file2.c init task","tmpsrc/tmp_dep2.c task","cp tmpsrc/tmp_dep2.c tmpbin/tmp_dep2.oo task","tmpsrc/dep1.c task","cp tmpsrc/dep1.c tmpbin/dep1.oo ns task","cp tmpsrc/file2.c tmpbin/file2.oo ns task","tmp pattern folder namespace task"].join("\n"),t),e=fs.readFileSync(process.cwd()+"/tmp_ns"),assert.equal("src/src_1src/src_2src/src_3 pattern folder namespace",e.toString()),cleanUpAndNext()})),test.skip("rule w chain w pattern w folder w namespace",(function(){let e,t=exec("./node_modules/.bin/jake -q tmp_cr").toString().trim();assert.equal(["chainrule init task","cp tmpsrc/file1.tex tmpbin/file1.dvi tex->dvi task","cp tmpbin/file1.dvi tmpbin/file1.pdf dvi->pdf task","cp tmpsrc/file2.tex tmpbin/file2.dvi tex->dvi task","cp tmpbin/file2.dvi tmpbin/file2.pdf dvi->pdf task","tmp chainrule namespace task"].join("\n"),t),e=fs.readFileSync(process.cwd()+"/tmp_cr"),assert.equal("tex1 tex2  chainrule namespace",e.toString()),cleanUpAndNext()})),["precedence","regexPattern","sourceFunction"].forEach((function(e){test("rule with source file not created yet ("+e+")",(function(){let t=process.stderr.write;process.stderr.write=()=>{},rmRf("foo.txt",{silent:!0}),rmRf("foo.html",{silent:!0});try{exec("./node_modules/.bin/jake  "+e+":test")}catch(e){assert.ok(e.message.indexOf('Unknown task "foo.html"')>-1)}process.stderr.write=t})),test("rule with source file now created ("+e+")",(function(){fs.writeFileSync("foo.txt","");let t=exec("./node_modules/.bin/jake -q  "+e+":test").toString().trim();assert.equal(["created html","ran test"].join("\n"),t)})),test("rule with source file modified ("+e+")",(function(t){setTimeout((function(){fs.writeFileSync("foo.txt","");let s=exec("./node_modules/.bin/jake -q  "+e+":test").toString().trim();assert.equal(["created html","ran test"].join("\n"),s),cleanUpAndNext(t)}),1e3)})),test("rule with existing objective file and no source  (should be normal file-task) ("+e+")",(function(){fs.writeFileSync("foo.html",""),rmRf("foo.txt",{silent:!0});let t=exec("./node_modules/.bin/jake -q  "+e+":test").toString().trim();assert.equal(["ran test"].join("\n"),t),cleanUpAndNext()}))}))}));