فهرست منبع

only run chktex on .tex files, not .Rtex files

the .tex files produced from knitr have macros which confuse chktex
Brian Gough 10 سال پیش
والد
کامیت
56429178df
2فایلهای تغییر یافته به همراه38 افزوده شده و 1 حذف شده
  1. 3 1
      services/clsi/app/coffee/CompileManager.coffee
  2. 35 0
      services/clsi/test/unit/coffee/CompileManagerTests.coffee

+ 3 - 1
services/clsi/app/coffee/CompileManager.coffee

@@ -44,7 +44,9 @@ module.exports = CompileManager =
 
 
 			# set up environment variables for chktex
 			# set up environment variables for chktex
 			env = {}
 			env = {}
-			if request.check?
+			# only run chktex on LaTeX files (not knitr .Rtex files or any others)
+			isLaTeXFile = request.rootResourcePath?.match(/\.tex$/i)
+			if request.check? and isLaTeXFile
 				env['CHKTEX_OPTIONS'] = '-nall -e9 -e10 -w15 -w16'
 				env['CHKTEX_OPTIONS'] = '-nall -e9 -e10 -w15 -w16'
 				if request.check is 'error'
 				if request.check is 'error'
 					env['CHKTEX_EXIT_ON_ERROR'] =  1
 					env['CHKTEX_EXIT_ON_ERROR'] =  1

+ 35 - 0
services/clsi/test/unit/coffee/CompileManagerTests.coffee

@@ -98,6 +98,41 @@ describe "CompileManager", ->
 					.calledWith(@compileDir + "/" + @rootResourcePath)
 					.calledWith(@compileDir + "/" + @rootResourcePath)
 					.should.equal true
 					.should.equal true
 
 
+		describe "with a check option", ->
+			beforeEach ->
+				@request.check = "error"
+				@CompileManager.doCompile @request, @callback
+
+			it "should run chktex", ->
+				@LatexRunner.runLatex
+					.calledWith("#{@project_id}-#{@user_id}", {
+						directory: @compileDir
+						mainFile:  @rootResourcePath
+						compiler:  @compiler
+						timeout:   @timeout
+						image:     @image
+						environment: {'CHKTEX_OPTIONS': '-nall -e9 -e10 -w15 -w16', 'CHKTEX_EXIT_ON_ERROR':1}
+					})
+					.should.equal true
+
+		describe "with a knitr file and check options", ->
+			beforeEach ->
+				@request.rootResourcePath = "main.Rtex"
+				@request.check = "error"
+				@CompileManager.doCompile @request, @callback
+
+			it "should not run chktex", ->
+				@LatexRunner.runLatex
+					.calledWith("#{@project_id}-#{@user_id}", {
+						directory: @compileDir
+						mainFile:  "main.Rtex"
+						compiler:  @compiler
+						timeout:   @timeout
+						image:     @image
+						environment: @env
+					})
+					.should.equal true
+
 	describe "clearProject", ->
 	describe "clearProject", ->
 		describe "succesfully", ->
 		describe "succesfully", ->
 			beforeEach ->
 			beforeEach ->