From 7bc99257be6b974049c69cf37272fd9dd1e20e5b Mon Sep 17 00:00:00 2001 From: Jesse Portnoy Date: Mon, 17 Jul 2023 23:07:25 +0100 Subject: [PATCH] Commit test inputs --- go.mod | 9 +++ test_inputs/1.c | 5 ++ test_inputs/1.cmake | 126 +++++++++++++++++++++++++++++++++++++++++ test_inputs/1.ini | 3 + test_inputs/1.markdown | 69 ++++++++++++++++++++++ test_inputs/1.php | 5 ++ test_inputs/1.shell | 15 +++++ test_inputs/1.yaml | 12 ++++ 8 files changed, 244 insertions(+) create mode 100644 go.mod create mode 100644 test_inputs/1.c create mode 100644 test_inputs/1.cmake create mode 100644 test_inputs/1.ini create mode 100644 test_inputs/1.markdown create mode 100644 test_inputs/1.php create mode 100644 test_inputs/1.shell create mode 100644 test_inputs/1.yaml diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..cbd43aa --- /dev/null +++ b/go.mod @@ -0,0 +1,9 @@ +module gohighlight + +go 1.19 + +require ( + github.com/jessp01/gohighlight v0.21.1-1 + github.com/zyedidia/highlight v0.0.0-20200217010119-291680feaca1 + gopkg.in/yaml.v2 v2.4.0 +) diff --git a/test_inputs/1.c b/test_inputs/1.c new file mode 100644 index 0000000..46ade95 --- /dev/null +++ b/test_inputs/1.c @@ -0,0 +1,5 @@ +#include +int main(int argc, char *argv[]) { + printf("%s\n", "Hello world!"); +} + diff --git a/test_inputs/1.cmake b/test_inputs/1.cmake new file mode 100644 index 0000000..3cdaaae --- /dev/null +++ b/test_inputs/1.cmake @@ -0,0 +1,126 @@ +cmake_minimum_required(VERSION 3.15) + +# set the project name and version +project(Tutorial VERSION 1.0) + +set(CMAKE_DEBUG_POSTFIX d) + +add_library(tutorial_compiler_flags INTERFACE) +target_compile_features(tutorial_compiler_flags INTERFACE cxx_std_11) + +# add compiler warning flags just when building this project via +# the BUILD_INTERFACE genex +set(gcc_like_cxx "$") +set(msvc_cxx "$") +target_compile_options(tutorial_compiler_flags INTERFACE + "$<${gcc_like_cxx}:$>" + "$<${msvc_cxx}:$>" +) + +# control where the static and shared libraries are built so that on windows +# we don't need to tinker with the path to run the executable +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") + +option(BUILD_SHARED_LIBS "Build using shared libraries" ON) + +if(APPLE) + set(CMAKE_INSTALL_RPATH "@executable_path/../lib") +elseif(UNIX) + set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib") +endif() + +# configure a header file to pass the version number only +configure_file(TutorialConfig.h.in TutorialConfig.h) + +# add the MathFunctions library +add_subdirectory(MathFunctions) + +# add the executable +add_executable(Tutorial tutorial.cxx) +set_target_properties(Tutorial PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) + +target_link_libraries(Tutorial PUBLIC MathFunctions tutorial_compiler_flags) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) + +# add the install targets +install(TARGETS Tutorial DESTINATION bin) +install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include + ) + +# enable testing +enable_testing() + +# does the application run +add_test(NAME Runs COMMAND Tutorial 25) + +# does the usage message work? +add_test(NAME Usage COMMAND Tutorial) +set_tests_properties(Usage + PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number" + ) + +# define a function to simplify adding tests +function(do_test target arg result) + add_test(NAME Comp${arg} COMMAND ${target} ${arg}) + set_tests_properties(Comp${arg} + PROPERTIES PASS_REGULAR_EXPRESSION ${result} + ) +endfunction() + +# do a bunch of result based tests +do_test(Tutorial 4 "4 is 2") +do_test(Tutorial 9 "9 is 3") +do_test(Tutorial 5 "5 is 2.236") +do_test(Tutorial 7 "7 is 2.645") +do_test(Tutorial 25 "25 is 5") +do_test(Tutorial -25 "-25 is (-nan|nan|0)") +do_test(Tutorial 0.0001 "0.0001 is 0.01") + +# setup installer +include(InstallRequiredSystemLibraries) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") +set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}") +set(CPACK_SOURCE_GENERATOR "TGZ") +include(CPack) + +# install the configuration targets +install(EXPORT MathFunctionsTargets + FILE MathFunctionsTargets.cmake + DESTINATION lib/cmake/MathFunctions +) + +include(CMakePackageConfigHelpers) +# generate the config file that is includes the exports +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake" + INSTALL_DESTINATION "lib/cmake/example" + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO + ) +# generate the version file for the config file +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake" + VERSION "${Tutorial_VERSION_MAJOR}.${Tutorial_VERSION_MINOR}" + COMPATIBILITY AnyNewerVersion +) + +# install the configuration file +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake + DESTINATION lib/cmake/MathFunctions + ) + +# generate the export targets for the build tree +# needs to be after the install(TARGETS ) command +export(EXPORT MathFunctionsTargets + FILE "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsTargets.cmake" +) diff --git a/test_inputs/1.ini b/test_inputs/1.ini new file mode 100644 index 0000000..376f024 --- /dev/null +++ b/test_inputs/1.ini @@ -0,0 +1,3 @@ +; configuration for php mysql module +; priority=10 +extension=mysqlnd.so diff --git a/test_inputs/1.markdown b/test_inputs/1.markdown new file mode 100644 index 0000000..3eef014 --- /dev/null +++ b/test_inputs/1.markdown @@ -0,0 +1,69 @@ +%title: a crash course on handling deb packages +%author: jesse portnoy +%date: 2023-07-11 + +---------------------------------------------------------------------------- + +## topics covered in this course + +- what is a `deb` package? +- what is dpkg? +- what is apt? +- the `apt` util +- `apt-get` +- `apt-cache` +- `apt-file` +- fetching and installing packages +- install vs. upgrade +- non-interactive operations +- a note on dependencies +- package dependencies & relationships +- querying the local packages db +- querying remote repos +- configuration operations +- downloading & building packages from source +- automating the installation of packages that require inputs +- removing packages +- thanks & final note + +```c +#include +int main() +{ + return 0; +} +``` + +```php + +``` + +---------------------------------------------------------------------------- + +## What is a `deb` package? + +*deb* is the format, as well as filename extension of the software package format for the Debian Linux distribution +and its derivatives. Debian packages are standard UNIX *ar* archives that include two tar archives. +One archive holds the control information and another contains the installable data. + +## What is dpkg? + +*dpkg* is a tool to install, build, remove and manage Debian packages. + +*dpkg* is controlled entirely via command line parameters, which consist of exactly one action and zero or more options. +The action parameter tells *dpkg* what to do and options control the behavior of the action in some way. + +*dpkg* maintains some usable information about available packages. The information is divided in three classes: states, +selection states and flags. + +## What is APT? + +Advanced Package Tool, or APT, is a free-software user interface that works with core libraries to handle the installation +and removal of software on Debian, and Debian-based Linux distributions. APT simplifies the process of managing software by +automating the retrieval, configuration and installation of software packages. + +In the next slide, we'll review some important APT utils and their respective functionality. diff --git a/test_inputs/1.php b/test_inputs/1.php new file mode 100644 index 0000000..c3cbc3f --- /dev/null +++ b/test_inputs/1.php @@ -0,0 +1,5 @@ + diff --git a/test_inputs/1.shell b/test_inputs/1.shell new file mode 100644 index 0000000..674399d --- /dev/null +++ b/test_inputs/1.shell @@ -0,0 +1,15 @@ +#!/bin/sh +prompt () +{ + FCM=$(fc -ln -0) + CM=$(echo "$FCM"|awk -F " " '{print $1}') + if ls /etc/supercat/spcrc-"$CM"* > /dev/null 2>&1; then + echo "Rerun with colour [y/n]?" + read -r YN + if [ "$YN" = 'y' ] || [ "$YN" = 'Y' ] ;then + eval "$FCM"| spc -c /etc/supercat/spcrc-"$CM"* + fi + fi +} + +export PROMPT_COMMAND=prompt diff --git a/test_inputs/1.yaml b/test_inputs/1.yaml new file mode 100644 index 0000000..9c286f5 --- /dev/null +++ b/test_inputs/1.yaml @@ -0,0 +1,12 @@ +filetype: diff + +detect: + filename: "\\.diff$" + header: "^((---.*)|(\\+\\+\\+.*))" + +rules: + - statement: "(^\\+\\+\\+.*)" + - statement: "(^---.*)" + - type: "(^@@.*)" + - constant.number: "(^\\+.*)" + - preproc: "(^-.*)"