mirror of
https://github.com/webodf/WebODF.git
synced 2026-11-30 16:47:58 +01:00
target "webodf.js-tests" with all tests, only run tests on change
This commit is contained in:
+13
-1
@@ -305,7 +305,6 @@ macro(COPY_FILES _varname _srcdir _tgtdir)
|
||||
endforeach(_file)
|
||||
endmacro(COPY_FILES _directory _files)
|
||||
|
||||
|
||||
#############################
|
||||
## Define some files and dirs
|
||||
#############################
|
||||
@@ -335,6 +334,19 @@ set(FIREFOX_EXTENSION_ODFVIEWER_DIR ${CMAKE_CURRENT_BINARY_DIR}/firefox-extensio
|
||||
set(FIREFOX_EXTENSION_ODFVIEWER ${FIREFOX_EXTENSION_ODFVIEWER_DIR}.xpi)
|
||||
|
||||
|
||||
####################
|
||||
## WORKAROUND HELPER
|
||||
####################
|
||||
|
||||
# cmake -E touch truncates time to seconds in older versions
|
||||
# see http://www.cmake.org/Bug/view.php?id=14020
|
||||
if (CMAKE_VERSION VERSION_LESS 2.8.12)
|
||||
set(TOUCHFILE ${NODE} ${TOOLS_DIR}/touchfile.js)
|
||||
else()
|
||||
set(TOUCHFILE ${CMAKE_COMMAND} -E touch)
|
||||
endif()
|
||||
|
||||
|
||||
#############################
|
||||
## Build Library and programs
|
||||
#############################
|
||||
|
||||
@@ -193,11 +193,15 @@ add_custom_command(
|
||||
DEPENDS ${LIBJSFILES} JsDoc
|
||||
)
|
||||
add_custom_target(doc DEPENDS docs/index.html)
|
||||
add_custom_target(simplenodetest ALL
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/simplenodetest.timestamp
|
||||
COMMAND ${NODE} ${CMAKE_CURRENT_BINARY_DIR}/simplecompiled.js
|
||||
DEPENDS ${NODE} simplecompiled.js-target copy_node_modules
|
||||
COMMAND ${TOUCHFILE} ${CMAKE_CURRENT_BINARY_DIR}/simplenodetest.timestamp
|
||||
DEPENDS ${NODE} simplecompiled.js copy_node_modules
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests
|
||||
)
|
||||
add_custom_target(simplenodetest ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/simplenodetest.timestamp)
|
||||
|
||||
if (NOT APPLE)
|
||||
add_custom_command(
|
||||
@@ -211,6 +215,7 @@ if (NOT APPLE)
|
||||
add_custom_target(instrumented DEPENDS instrumented/index.html)
|
||||
endif(NOT APPLE)
|
||||
|
||||
add_custom_target(webodf.js-tests DEPENDS syntaxcheck simplenodetest)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${WEBODFJS_DIR}
|
||||
|
||||
+35
-13
@@ -13,23 +13,45 @@ FILE( GLOB_RECURSE TESTS_TESTFILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
|
||||
COPY_FILES(tests_nodetests ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/_nodetest ${TESTS_TESTFILES} )
|
||||
add_custom_target(nodetest ALL
|
||||
COMMAND ${NODE} ${RUNTIMEJS} tests.js
|
||||
WORKING_DIRECTORY _nodetest
|
||||
DEPENDS ${tests_nodetests}
|
||||
|
||||
# create copy of list with path relative to this folder
|
||||
foreach(JSFILE ${LIBJSFILES})
|
||||
if (IS_ABSOLUTE ${JSFILE})
|
||||
list(APPEND TESTS_LIBJSFILES ${JSFILE})
|
||||
else (IS_ABSOLUTE ${JSFILE})
|
||||
list(APPEND TESTS_LIBJSFILES "../${JSFILE}")
|
||||
endif (IS_ABSOLUTE ${JSFILE})
|
||||
endforeach(JSFILE ${LIBJSFILES})
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT _nodetest/nodetest.timestamp
|
||||
COMMAND ${NODE} ${RUNTIMEJS} tests.js
|
||||
COMMAND ${TOUCHFILE} nodetest.timestamp
|
||||
WORKING_DIRECTORY _nodetest
|
||||
DEPENDS ${NODE} manifest.json-target ${TESTS_LIBJSFILES} ${tests_nodetests}
|
||||
)
|
||||
add_dependencies(nodetest ${NODE} manifest.json-target)
|
||||
add_custom_target(nodetest ALL DEPENDS _nodetest/nodetest.timestamp)
|
||||
add_dependencies(webodf.js-tests nodetest)
|
||||
|
||||
if (BUILD_QTJSRUNTIME)
|
||||
COPY_FILES(tests_qtjsruntimetest ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/_qtjsruntimetest ${TESTS_TESTFILES} )
|
||||
COPY_FILES(tests_qtjsruntimetest ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/_qtjsruntimetest ${TESTS_TESTFILES} )
|
||||
COPY_FILES(tests_qtjsruntimetest2 ${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
${CMAKE_CURRENT_BINARY_DIR} webodf.css)
|
||||
add_custom_target(qtjsruntimetest ALL
|
||||
COMMAND qtjsruntime ${RUNTIMEJS} tests.js
|
||||
WORKING_DIRECTORY _qtjsruntimetest
|
||||
DEPENDS ${tests_qtjsruntimetest} ${tests_qtjsruntimetest2}
|
||||
)
|
||||
add_dependencies(qtjsruntimetest ${NODE} qtjsruntime manifest.json-target)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT _qtjsruntimetest/qtjsruntimetest.timestamp
|
||||
COMMAND qtjsruntime ${RUNTIMEJS} tests.js
|
||||
COMMAND ${TOUCHFILE} qtjsruntimetest.timestamp
|
||||
WORKING_DIRECTORY _qtjsruntimetest
|
||||
DEPENDS
|
||||
qtjsruntime
|
||||
manifest.json-target
|
||||
${TESTS_LIBJSFILES}
|
||||
${tests_qtjsruntimetest}
|
||||
${tests_qtjsruntimetest2}
|
||||
)
|
||||
add_custom_target(qtjsruntimetest ALL DEPENDS _qtjsruntimetest/qtjsruntimetest.timestamp)
|
||||
add_dependencies(webodf.js-tests qtjsruntimetest)
|
||||
endif (BUILD_QTJSRUNTIME)
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Copyright (C) 2014 KO GmbH <copyright@kogmbh.com>
|
||||
*
|
||||
* @licstart
|
||||
* This file is part of WebODF.
|
||||
*
|
||||
* WebODF is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License (GNU AGPL)
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* WebODF is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with WebODF. If not, see <http://www.gnu.org/licenses/>.
|
||||
* @licend
|
||||
*
|
||||
* @source: http://www.webodf.org/
|
||||
* @source: https://github.com/kogmbh/WebODF/
|
||||
*/
|
||||
|
||||
/*global require, process*/
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
var fs = require("fs"),
|
||||
filePath;
|
||||
|
||||
if (process.argv.length !== 3) {
|
||||
process.stderr.write('Usage: touchfile.js file\n');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function reportErrorAndQuit(err) {
|
||||
process.stderr.write('Error on touching file "' + filePath + '": '+err.message+'\n');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
filePath = process.argv[2];
|
||||
fs.open(filePath, 'a', function(err, fd) {
|
||||
var nowTime = Date.now() / 1000; // in secs
|
||||
|
||||
if (err) {
|
||||
reportErrorAndQuit(err);
|
||||
}
|
||||
fs.futimes(fd, nowTime, nowTime, function(err) {
|
||||
if (err) {
|
||||
reportErrorAndQuit(err);
|
||||
}
|
||||
fs.close(fd, function(err) {
|
||||
if (err) {
|
||||
reportErrorAndQuit(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}());
|
||||
Reference in New Issue
Block a user