Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test eol used by lua io.write() under different OSs #6

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 14 additions & 24 deletions .github/workflows/latex-three-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ defaults:

jobs:
run-on-three-os:
if: false
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
Expand Down Expand Up @@ -40,7 +39,7 @@ jobs:
fi
echo "os_null=$OS_NULL" >> $GITHUB_ENV

# env.unique_id
# env.artifact_id
OS_SHORT=${{ matrix.os }}
OS_SHORT=${OS_SHORT/-latest/}
SHA1_SHORT=$(git rev-parse --short HEAD)
Expand All @@ -49,27 +48,18 @@ jobs:
else
ID="$OS_SHORT-$SHA1_SHORT-${{ github.run_attempt }}"
fi
echo "unique_id=$ID" >> $GITHUB_ENV
echo "artifact_id=$ID" >> $GITHUB_ENV

# - name: Run example(s)
# working-directory: latex-examples
# run: |
# # ENGINES=("pdflatex" "lualatex")
# ENGINES=("pdflatex")
# for engine in ${ENGINES[@]}; do
# $engine l3benchmark-gh1182*.tex # > "${{ env.os_null }}"
# # use "%0A" to throw a multiline warning
# # https://github.com/actions/toolkit/issues/193#issuecomment-605394935
# log_filtered=$(\
# grep -rh "seconds\|\[debug\] " *.log | \
# awk 'BEGIN {RS=""}{gsub(/\n/,"%0A",$0); print $0}' \
# )
# # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message
# echo "::warning file=l3benchmark-gh1182-$engine*.log,line=1,col=1,endColumn=2::$log_filtered"
# done
- name: Test lua `io.write()`
shell: bash
working-directory: lua
run: |
texlua eol.lua
for file in `ls *.txt`; do echo $file; xxd $file; done

# - name: Archive
# uses: actions/upload-artifact@v3
# with:
# name: latex-examples-${{ env.unique_id }}
# path: latex-examples
- name: Archive
uses: actions/upload-artifact@v3
with:
name: lua-eol-${{ env.artifact_id }}
path: |
lua/*.txt
12 changes: 12 additions & 0 deletions lua/eol.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
local function test_eol(fname, content)
-- open file in binary mode, to avoid convertion from \n to \r\n in Win
-- http://lua-users.org/lists/lua-l/2015-05/msg00349.html
local file = io.open(fname, "wb")
io.output(file)
io.write(content)
io.close(file)
end

test_eol("eol-crlf.txt", "abc\r\nabc\r\n")
test_eol("eol-lf.txt", "abc\nabc\n")
test_eol("eol-mixed.txt", "abc\r\nabc\n")